Java Code Examples for androidx.preference.EditTextPreference#setSummaryProvider()

The following examples show how to use androidx.preference.EditTextPreference#setSummaryProvider() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SettingsPreferenceActivity.java    From DeviceConnect-Android with MIT License 6 votes vote down vote up
private void createEncoderBitRatePreference() {
    EditTextPreference pref = findPreference("encoder_bit_rate");
    if (pref != null) {
        pref.setSummaryProvider((Preference preference) ->
                pref.getText() + " Mbps"
        );
        // 0以上の実数値以外の入力を禁止する
        pref.setOnBindEditTextListener((@NonNull EditText editText) ->
                editText.setInputType(InputType.TYPE_CLASS_NUMBER
                        | InputType.TYPE_NUMBER_FLAG_DECIMAL));
        String value = pref.getText();
        if (value == null) {
            pref.setText(Settings.DEFAULT_ENCODER_BITRATE_BASE);
        }
    }
}
 
Example 2
Source File: HostRecorderSRTSettingFragment.java    From DeviceConnect-Android with MIT License 5 votes vote down vote up
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
    addPreferencesFromResource(R.xml.settings_host_preview_srt);

    EditTextPreference inputBwPref = findPreference(getString(R.string.pref_key_settings_srt_inputbw));
    if (inputBwPref != null) {
        inputBwPref.setSummaryProvider(summaryOptionAuto);
    }
    EditTextPreference oHeadBwPref = findPreference(getString(R.string.pref_key_settings_srt_oheadbw));
    if (oHeadBwPref != null) {
        oHeadBwPref.setSummaryProvider(summaryOptionAuto);
    }
}
 
Example 3
Source File: SettingsPreferenceActivity.java    From DeviceConnect-Android with MIT License 5 votes vote down vote up
private void createEncoderFrameRatePreference() {
    EditTextPreference pref = findPreference("encoder_frame_rate");
    if (pref != null) {
        pref.setSummaryProvider((Preference preference) ->
                pref.getText() + " fps"
        );
        // 0以上の整数値以外の入力を禁止する
        pref.setOnBindEditTextListener((@NonNull EditText editText) ->
                editText.setInputType(InputType.TYPE_CLASS_NUMBER));
        String value = pref.getText();
        if (value == null) {
            pref.setText(Integer.toString(Settings.DEFAULT_ENCODER_FPS));
        }
    }
}