コード例 #1
0
ファイル: SettingsTab.java プロジェクト: yiqideren/quitesleep
  /** Put the ddbb saved data in the activity widgets */
  private void initActivity() {

    try {
      ClientDDBB clientDDBB = new ClientDDBB();

      // Togglebutton (QuuiteSleep service) check
      Settings settings = clientDDBB.getSelects().selectSettings();
      if (settings != null) {
        serviceToggleButton.setChecked(settings.isQuiteSleepServiceState());
      } else serviceToggleButton.setChecked(false);

      // Mute or hangup radio buttons check
      if (ConfigAppValues.getMuteOrHangup() == null) {
        MuteOrHangUp muteOrHangup = clientDDBB.getSelects().selectMuteOrHangUp();
        if (muteOrHangup != null) {
          if (muteOrHangup.isMute()) muteRButton.setChecked(true);
          else if (muteOrHangup.isHangUp()) hangUpRButton.setChecked(true);
        }
        // If MuteOrHangUp object is not created. Should not occur
        else {
          muteOrHangup = new MuteOrHangUp();
          clientDDBB.getInserts().insertMuteOrHangUp(muteOrHangup);
          clientDDBB.commit();
        }

      } else {
        if (ConfigAppValues.getMuteOrHangup()) hangUpRButton.setChecked(true);
        else muteRButton.setChecked(true);
      }
      clientDDBB.close();

    } catch (Exception e) {
      if (QSLog.DEBUG_E)
        QSLog.e(CLASS_NAME, ExceptionUtils.exceptionTraceToString(e.toString(), e.getStackTrace()));
    }
  }
コード例 #2
0
ファイル: SettingsTab.java プロジェクト: yiqideren/quitesleep
  /**
   * This function save the user option regarding both mute or hang up in the ddbb.
   *
   * @param optionValue
   */
  private void saveMuteOrHangUpOption(boolean optionValue) {

    try {

      ClientDDBB clientDDBB = new ClientDDBB();
      MuteOrHangUp muteOrHangup = clientDDBB.getSelects().selectMuteOrHangUp();
      if (muteOrHangup != null) {

        // If is true, then the hangup option is established
        if (optionValue) {
          muteOrHangup.setHangUp(true);
          ConfigAppValues.setMuteOrHangup(true);
        }
        // If is false, then the mute mode is set to true
        else {
          muteOrHangup.setMute(true);
          ConfigAppValues.setMuteOrHangup(false);
        }

        clientDDBB.getUpdates().insertMuteOrHangUp(muteOrHangup);
        clientDDBB.commit();
      }

      // If MuteOrHangUp object is not created.
      else {
        muteOrHangup = new MuteOrHangUp();
        clientDDBB.getInserts().insertMuteOrHangUp(muteOrHangup);
        clientDDBB.commit();
      }
      clientDDBB.close();

    } catch (Exception e) {
      if (QSLog.DEBUG_E)
        QSLog.e(CLASS_NAME, ExceptionUtils.exceptionTraceToString(e.toString(), e.getStackTrace()));
    }
  }