本文整理汇总了Java中com.afollestad.materialdialogs.prefs.MaterialListPreference类的典型用法代码示例。如果您正苦于以下问题:Java MaterialListPreference类的具体用法?Java MaterialListPreference怎么用?Java MaterialListPreference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MaterialListPreference类属于com.afollestad.materialdialogs.prefs包,在下文中一共展示了MaterialListPreference类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateSpecialPreferences
import com.afollestad.materialdialogs.prefs.MaterialListPreference; //导入依赖的package包/类
private void updateSpecialPreferences() {
if (shouldEnableNotificationsAlerts && checkNotificationsPermission(context, false)) {
((TwoStatePreference) findPreference("notifications_alerts")).setChecked(true);
}
if (((MaterialListPreference) findPreference("stop_delay")).getValue().equals("0"))
findPreference("stop_delay").setSummary(R.string.settings_stop_delay_desc);
else
findPreference("stop_delay").setSummary("%s");
findPreference("watchface_clock").setSummary(context.getResources().getStringArray(R.array.customize_clock)[prefs.clockStyle]);
findPreference("watchface_date").setSummary(context.getResources().getStringArray(R.array.customize_date)[prefs.dateStyle]);
findPreference("greenify_enabled").setSummary(isPackageInstalled("com.oasisfeng.greenify") ? context.getString(R.string.settings_greenify_integration_desc) : context.getString(R.string.settings_greenify_integration_desc_not_found));
if (!isPackageInstalled("com.oasisfeng.greenify")) {
((SwitchPreference) findPreference("greenify_enabled")).setChecked(false);
}
}
示例2: onCreate
import com.afollestad.materialdialogs.prefs.MaterialListPreference; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
context = getActivity().getApplicationContext();
mAdminName = new ComponentName(context, DAReceiver.class);
prefs = new Prefs(context);
prefs.apply();
findPreference("enabled").setOnPreferenceChangeListener(this);
findPreference("persistent_notification").setOnPreferenceChangeListener(this);
findPreference("raise_to_wake").setOnPreferenceChangeListener(this);
findPreference("greenify_enabled").setOnPreferenceChangeListener(this);
findPreference("proximity_to_lock").setOnPreferenceChangeListener(this);
findPreference("startafterlock").setOnPreferenceChangeListener(this);
findPreference("notifications_alerts").setOnPreferenceChangeListener(this);
findPreference("doze_mode").setOnPreferenceChangeListener(this);
findPreference("google_now_shortcut").setOnPreferenceChangeListener(this);
findPreference("camera_shortcut").setOnPreferenceChangeListener(this);
findPreference("stop_delay").setOnPreferenceChangeListener(this);
findPreference("battery_saver").setOnPreferenceChangeListener(this);
findPreference("watchface_clock").setOnPreferenceClickListener(this);
findPreference("watchface_date").setOnPreferenceClickListener(this);
findPreference("textcolor").setOnPreferenceClickListener(this);
findPreference("uninstall").setOnPreferenceClickListener(this);
findPreference("font").setOnPreferenceClickListener(this);
((SeekBarPreference) findPreference("font_size")).setMin(20);
PreferenceManager.getDefaultSharedPreferences(context).registerOnSharedPreferenceChangeListener(this);
String[] gesturePreferencesList = {DOUBLE_TAP, SWIPE_UP, SWIPE_DOWN, VOLUME_KEYS, BACK_BUTTON};
for (String preference : gesturePreferencesList) {
findPreference(preference).setOnPreferenceChangeListener((preference1, o) -> {
switch (Integer.parseInt((String) o)) {
case DISABLED:
return true;
case ACTION_UNLOCK:
return true;
case ACTION_SPEAK:
if (isSupporter()) {
if (!isPackageInstalled("com.google.android.tts"))
Utils.openURL(getActivity(), "https://play.google.com/store/apps/details?id=com.google.android.tts");
return true;
} else {
DonateActivity.quicklyPromptToSupport(getActivity(), rootView);
return false;
}
case ACTION_FLASHLIGHT:
if (isSupporter()) {
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.CAMERA}, CAMERA_PERMISSION_REQUEST_CODE);
return false;
}
return true;
} else {
DonateActivity.quicklyPromptToSupport(getActivity(), rootView);
return false;
}
}
return true;
});
}
checkNotificationsPermission(context, false);
starterService = new Intent(getActivity().getApplicationContext(), StarterService.class);
Utils.logDebug(String.valueOf(((MaterialListPreference) findPreference("rules")).getValue()), " Selected");
}
示例3: onCreate
import com.afollestad.materialdialogs.prefs.MaterialListPreference; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstance) {
super.onCreate(savedInstance);
addPreferencesFromResource(R.xml.pref_main);
mSets = Settings.getInstance(getActivity().getApplicationContext());
getActivity().setTitle(R.string.title_settings);
pref_version = findPreference("application_version");
pref_weibo = findPreference("sina_weibo");
pref_os_license = findPreference("open_source_license");
pref_api_provider = findPreference("api_provider");
pref_github = findPreference("github_repo");
pref_token_choose = (MaterialListPreference) findPreference("api_token_choose");
pref_token_custom = findPreference("api_token_custom");
pref_swipe_back = (SwitchPreference) findPreference("swipe_back");
pref_notification_interval = (MaterialListPreference) findPreference("notification_interval");
pref_do_not_disturb = (SwitchPreference) findPreference("do_not_disturb");
pref_disable_animation = (SwitchPreference) findPreference("disable_animation");
pref_navigation_tint = (SwitchPreference) findPreference("navigation_tint");
String version = "Unknown";
try {
version = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName;
version += " (" + getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionCode + ")";
} catch (Exception e) {
// Keep the default value
}
pref_version.setSummary(version);
pref_swipe_back.setChecked(mSets.getBoolean(Settings.KEY_SWIPE_BACK, true));
pref_token_custom.setDefaultValue(mSets.getInt(Settings.KEY_TOKEN_CHOOSE, 0));
pref_token_custom.setEnabled(mSets.getInt(Settings.KEY_TOKEN_CHOOSE, 0) == 2);
pref_do_not_disturb.setChecked(mSets.getBoolean(Settings.KEY_NOTIFICATION_DO_NOT_DISTURB, true));
pref_disable_animation.setChecked(mSets.getBoolean(Settings.KEY_DISABLE_ANIMATION, false));
if (Build.VERSION.SDK_INT < 21) {
pref_navigation_tint.setEnabled(false);
pref_navigation_tint.setChecked(false);
} else {
pref_navigation_tint.setChecked(mSets.getBoolean(Settings.KEY_NAVIGATION_TINT, true));
}
String[] values = getResources().getStringArray(R.array.item_token_list_values);
int index, target = mSets.getInt(Settings.KEY_TOKEN_CHOOSE, 0);
for (index = 0; index < values.length; index++) {
if (values[index].equals(String.valueOf(target))) break;
}
pref_token_choose.setSummary(
getResources().getStringArray(R.array.item_token_list)
[index]
);
String[] values1 = getResources().getStringArray(R.array.notification_interval_item);
int index1, target1 = mSets.getInt(Settings.KEY_NOTIFICATION_INTERVAL, 0);
for (index1 = 0; index1 < values.length; index1++) {
if (values1[index1].equals(String.valueOf(target1))) break;
}
pref_notification_interval.setSummary(
getResources().getStringArray(R.array.notification_interval)
[index1]
);
pref_weibo.setOnPreferenceClickListener(this);
pref_os_license.setOnPreferenceClickListener(this);
pref_api_provider.setOnPreferenceClickListener(this);
pref_github.setOnPreferenceClickListener(this);
pref_token_custom.setOnPreferenceClickListener(this);
pref_token_choose.setOnPreferenceChangeListener(this);
pref_swipe_back.setOnPreferenceChangeListener(this);
pref_notification_interval.setOnPreferenceChangeListener(this);
pref_do_not_disturb.setOnPreferenceChangeListener(this);
pref_disable_animation.setOnPreferenceChangeListener(this);
pref_navigation_tint.setOnPreferenceChangeListener(this);
}