@Override
  public void updateView() {
    if (spinnerSetGov == null) {
      // we have no been created yet
      return;
    }
    IGovernorModel governorModel = getGovernorModel();
    String curGov = governorModel.getGov();
    if (spinnerSetGov == null) {
      // we have no been created yet
      return;
    }
    for (int i = 0; i < availCpuGovs.length; i++) {
      if (curGov.equals(availCpuGovs[i])) {
        spinnerSetGov.setSelection(i);
      }
    }
    tvExplainGov.setText(GuiUtils.getExplainGovernor(getActivity(), curGov));
    if (SettingsStorage.getInstance().isPowerUser()) {
      etScript.setText(governorModel.getScript());
    }
    sbPowersaveBias.setProgress(governorModel.getPowersaveBias());
    updateGovernorFeatures();

    int position = numberOfCpus - governorModel.getUseNumberOfCpus();
    if (spUseCpus != null && position < spUseCpus.getAdapter().getCount()) {
      spUseCpus.setSelection(position);
    }
  }
 public GovernorFragment(
     GovernorFragmentCallback callback, IGovernorModel governor, boolean disableScript) {
   super(callback, governor);
   this.origThreshUp = governor.getGovernorThresholdUp() + "";
   this.origThreshDown = governor.getGovernorThresholdDown() + "";
   this.disableScript = disableScript;
   this.cpuHandler = CpuHandler.getInstance();
   this.availCpuGovs = cpuHandler.getAvailCpuGov();
 }
  private void updateGovernorFeatures() {
    IGovernorModel governorModel = getGovernorModel();
    GovernorConfig governorConfig = GovernorConfigHelper.getGovernorConfig(governorModel.getGov());

    int up = governorModel.getGovernorThresholdUp();
    int down = governorModel.getGovernorThresholdDown();
    boolean hasThreshholdUp = governorConfig.hasThreshholdUpFeature();
    boolean hasThreshholdDown = governorConfig.hasThreshholdDownFeature();

    if (hasThreshholdUp) {
      llGovernorThresholds.setVisibility(View.VISIBLE);
    } else {
      llGovernorThresholds.setVisibility(View.GONE);
    }

    if (hasThreshholdUp) {
      labelGovThreshUp.setVisibility(View.VISIBLE);
      etGovTreshUp.setVisibility(View.VISIBLE);
      if (up < 2) {
        up = Integer.parseInt(origThreshUp);
      }
      if (up < 2) {
        up = 90;
      }
      etGovTreshUp.setText(up + "");
    } else {
      governorModel.setGovernorThresholdUp(0);
      labelGovThreshUp.setVisibility(View.INVISIBLE);
      etGovTreshUp.setVisibility(View.INVISIBLE);
      etGovTreshUp.setText("-1");
    }

    if (hasThreshholdDown) {
      labelGovThreshDown.setVisibility(View.VISIBLE);
      etGovTreshDown.setVisibility(View.VISIBLE);
      if (down < 1) {
        down = Integer.parseInt(origThreshDown);
      }
      if (down >= up || down < 1) {
        if (up > 30) {
          down = up - 10;
        } else {
          down = up - 1;
        }
      }
      etGovTreshDown.setText(down + "");
    } else {
      governorModel.setGovernorThresholdDown(0);
      labelGovThreshDown.setVisibility(View.INVISIBLE);
      etGovTreshDown.setVisibility(View.INVISIBLE);
      etGovTreshDown.setText("-1");
    }

    if (governorConfig.hasPowersaveBias()) {
      llPowersaveBias.setVisibility(View.VISIBLE);
    } else {
      llPowersaveBias.setVisibility(View.GONE);
    }
  }
 @Override
 public void updateModel() {
   IGovernorModel governorModel = getGovernorModel();
   governorModel.setGovernorThresholdUp(etGovTreshUp.getText().toString());
   governorModel.setGovernorThresholdDown(etGovTreshDown.getText().toString());
   if (SettingsStorage.getInstance().isEnableScriptOnProfileChange()) {
     governorModel.setScript(etScript.getText().toString());
   } else {
     governorModel.setScript("");
   }
   governorModel.setPowersaveBias(sbPowersaveBias.getProgress());
 }