コード例 #1
0
  private void setParserSeparatorWord() {

    viewLauncher.showTextInputDialog(
        getString(R.string.settings_option_7_parser_separate_word_name),
        SharedPreferencesHelper.loadString(
            SharedPreferencesHelper.ITEM_SEPARATOR_WORD, getString(R.string.item_divider), context),
        new Command<String>() {
          @Override
          public void execute(String word) {
            for (int i = 0; i < word.length(); i++) {
              if (word.charAt(i) == ' ') {
                Toast.makeText(
                        context,
                        getString(R.string.settings_option_parser_separator_no_space_allowed),
                        Toast.LENGTH_LONG)
                    .show();
                return;
              }
            }
            saveString(ITEM_SEPARATOR_WORD, word, context);
          }
        },
        new Command<String>() {
          @Override
          public void execute(String parameter) {}
        });
  }
コード例 #2
0
  private void selectSyncInterval() {

    final int defaultValue = resourceProvider.getInteger(R.integer.synchronizationInterval_default);
    final int currentValue = loadInt(SYNCHRONIZATION_INTERVAL, defaultValue, context);

    viewLauncher.showNumberInputDialog(

        // title and message
        resourceProvider.getString(R.string.settings_options_syncInterval_name),
        resourceProvider.getString(R.string.settings_options_syncInterval_inputBox_message),

        // current value
        currentValue,

        // ok button: save updated value
        resourceProvider.getString(android.R.string.ok),
        new Command<String>() {
          @Override
          public void execute(String value) {

            try {

              int intValue = Integer.parseInt(value);

              if (intValue != currentValue && intValue > 0) {
                saveInt(SYNCHRONIZATION_INTERVAL, intValue, context);
                SyncingActivity.onSyncIntervalSettingChanged(intValue);
              }

            } catch (NumberFormatException ex) {
              // should not happen, because showNumberInputDialog() only allows digits as input
              // => just ignore the error
            }
          }
        },

        // reset to default value (neutral button)
        resourceProvider.getString(R.string.str_default),
        new Command<String>() {
          @Override
          public void execute(String parameter) {

            if (defaultValue != currentValue) {
              saveInt(SYNCHRONIZATION_INTERVAL, defaultValue, context);
              SyncingActivity.onSyncIntervalSettingChanged(defaultValue);
            }
          }
        },

        // cancel button: do othign
        resourceProvider.getString(android.R.string.cancel),
        NullCommand.StringInstance);
  }
コード例 #3
0
  private void setApiEndpoint() {

    viewLauncher.showTextInputDialog(
        resourceProvider.getString(R.string.settings_option_4_APIEndPoint_Title),
        loadString(API_ENDPOINT, resourceProvider.getString(R.string.API_HOST), getActivity()),
        resourceProvider.getString(android.R.string.ok),
        new Command<String>() {
          @Override
          public void execute(String value) {
            saveString(API_ENDPOINT, value, getActivity());
          }
        },
        resourceProvider.getString(R.string.reset),
        new Command<String>() {
          @Override
          public void execute(String value) {
            value = resourceProvider.getString(R.string.API_HOST);
            saveString(API_ENDPOINT, value, getActivity());
          }
        },
        resourceProvider.getString(android.R.string.cancel),
        NullCommand.StringInstance);
  }