本文整理汇总了Java中android.support.v7.preference.PreferenceScreen.removePreference方法的典型用法代码示例。如果您正苦于以下问题:Java PreferenceScreen.removePreference方法的具体用法?Java PreferenceScreen.removePreference怎么用?Java PreferenceScreen.removePreference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.preference.PreferenceScreen
的用法示例。
在下文中一共展示了PreferenceScreen.removePreference方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreatePreferencesFix
import android.support.v7.preference.PreferenceScreen; //导入方法依赖的package包/类
@Override
public void onCreatePreferencesFix(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.app_preferences);
PreferenceScreen mainPreferenceScreen = (PreferenceScreen) findPreference("mainPreferenceScreen");
pushPreferenceCat = findPreference("pushCat");
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
Preference downloadNotificationCat = findPreference("downloadNotificationCat");
mainPreferenceScreen.removePreference(downloadNotificationCat);
}
crashlyticsAlwaysSendPreference = (SwitchPreferenceCompat) findPreference(getString(R.string.pref_key_crashlytics_always_send));
crashlyticsAlwaysSendPreference.setChecked(TazSettings.getInstance(getContext())
.getCrashlyticsAlwaysSend());
crashlyticsAlwaysSendPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
TazSettings.getInstance(preference.getContext())
.setCrashlyticsAlwaysSend((Boolean) newValue);
return true;
}
});
setPushPrefState(!TextUtils.isEmpty(TazSettings.getInstance(getContext())
.getFirebaseToken()));
}
示例2: hideOrShowDangerousSettings
import android.support.v7.preference.PreferenceScreen; //导入方法依赖的package包/类
private void hideOrShowDangerousSettings() {
Preference[] onScreenPrefs = getOnScreenPrefs();
if (!GlobalPrivilegesManager.isAdvancedSettingsAccessEnabled() && !BuildConfig.DEBUG) {
// Dangerous privileges should not be showing
PreferenceScreen prefScreen = getPreferenceScreen();
for (Preference p : onScreenPrefs) {
if (p != null && !WHITELISTED_DEVELOPER_PREF_KEYS.contains(p.getKey())) {
prefScreen.removePreference(p);
}
}
} else {
// Dangerous privileges should be showing
if (onScreenPrefs.length == WHITELISTED_DEVELOPER_PREF_KEYS.size()) {
// If we're currently showing only white-listed prefs, reset
reset();
}
}
}
示例3: onCreatePreferences
import android.support.v7.preference.PreferenceScreen; //导入方法依赖的package包/类
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.preference_settings, rootKey);
mPreferenceScreen = (PreferenceScreen) findPreference("preference_screen");
initGeneral();
initUi();
mDevPreferenceGroup = (PreferenceGroup) findPreference("preference_group_dev");
if (!mPrefs.devOptionsOpened().getValue()) {
mPreferenceScreen.removePreference(mDevPreferenceGroup);
} else {
initDevOps();
}
initAbout();
}
示例4: setVisibilityOfMigrationButton
import android.support.v7.preference.PreferenceScreen; //导入方法依赖的package包/类
private void setVisibilityOfMigrationButton() {
Preference migratePreference = findPreference(getString(R.string.pref_database_migrate_14_to_20));
if (migratePreference == null) return;
// check if there is a database at the old location.
final DatabaseMigrator14To20 migrator = new DatabaseMigrator14To20(getActivity());
boolean legacyDataExists = migrator.legacyDataExists();
// display description.
migratePreference.setSummary(getString(R.string.database_migrate_14_to_20_explanation));
// + " (" + migrator.getLegacyDbPath() + ")");
Preference.OnPreferenceClickListener migrateClicked = new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
boolean success = migrator.migrateLegacyDatabase();
if (success) {
Toast.makeText(getActivity(), R.string.database_migrate_14_to_20_success, Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getActivity(), R.string.database_migrate_14_to_20_failure, Toast.LENGTH_LONG).show();
}
// The return value indicates whether to persist the preference,
// which is not used in this case.
return false;
}
};
// hide preference if there is no legacy data.
if (!legacyDataExists) {
PreferenceScreen screen = getPreferenceScreen();
screen.removePreference(migratePreference);
} else {
// enable listener for migration.
migratePreference.setOnPreferenceClickListener(migrateClicked);
}
}
示例5: setVisibilityOfUpdateOptionsPref
import android.support.v7.preference.PreferenceScreen; //导入方法依赖的package包/类
private void setVisibilityOfUpdateOptionsPref() {
Preference updateOptionsPref = getPreferenceManager().findPreference(UPDATE_TARGET);
if (!DeveloperPreferences.shouldShowUpdateOptionsSetting() && updateOptionsPref != null) {
// If the pref is showing and it shouldn't be
PreferenceScreen prefScreen = getPreferenceScreen();
prefScreen.removePreference(updateOptionsPref);
} else if (DeveloperPreferences.shouldShowUpdateOptionsSetting() &&
updateOptionsPref == null) {
// If the pref isn't showing and it should be
reset();
}
}
示例6: removeCategoryFromSettings
import android.support.v7.preference.PreferenceScreen; //导入方法依赖的package包/类
/**
* removes category from the settings
*
* @param preference preference to remove
*/
private void removeCategoryFromSettings(CharSequence preference) {
PreferenceScreen screen = getPreferenceScreen();
Preference preferenceCategory = findPreference(preference);
screen.removePreference(preferenceCategory);
}
示例7: initPreferenceForConsent
import android.support.v7.preference.PreferenceScreen; //导入方法依赖的package包/类
private void initPreferenceForConsent() {
boolean isSignedInAndConsented = DataProvider.getInstance().isSignedIn(getActivity()) &&
DataProvider.getInstance().isConsented(getActivity());
PreferenceScreen screen = getPreferenceScreen();
if (!isSignedInAndConsented) {
screen.removePreference(profileCategory);
privacyCategory.removePreference(sharingScope);
generalCategory.removePreference(leaveStudy);
// This method will be called if we leave the study. This means we need to add
// "join study" back into the general-category as it was removed on the initial call of
// this method
if (generalCategory.findPreference(KEY_JOIN_STUDY) == null) {
generalCategory.addPreference(joinStudy);
}
} else {
generalCategory.removePreference(joinStudy);
Observable.defer(() -> Observable.just(DataProvider.getInstance()
.getUser(getActivity())))
.compose(ObservableUtils.applyDefault())
.subscribe(profile -> {
if (profile == null) {
getPreferenceScreen().removePreference(profileCategory);
return;
}
Preference namePref = profileCategory.findPreference(KEY_PROFILE_NAME);
if (profile.getName() != null) {
namePref.setSummary(profile.getName());
} else {
profileCategory.removePreference(namePref);
}
Preference birthdatePref = profileCategory.findPreference(
KEY_PROFILE_BIRTHDATE);
if (profile.getBirthDate() != null) {
try {
// The incoming date is formated in "yyyy-MM-dd", clean it up to "MMM dd, yyyy"
Date birthdate = FormatHelper.SIMPLE_FORMAT_DATE.parse(profile.getBirthDate());
DateFormat format = FormatHelper.getFormat(DateFormat.LONG,
FormatHelper.NONE);
birthdatePref.setSummary(format.format(birthdate));
} catch (ParseException e) {
LogExt.e(SettingsFragment.class, e);
birthdatePref.setSummary(profile.getBirthDate());
}
} else {
profileCategory.removePreference(birthdatePref);
}
});
// Load Consent Data and set sharing scope
Observable.defer(() -> Observable.just(ResourceManager.getInstance()
.getConsentSections()
.create(getActivity()))).flatMap((consentData) -> {
this.data = (ConsentSectionModel) consentData;
// Load and set sharing scope
return Observable.just(DataProvider.getInstance()
.getUserSharingScope(getContext()));
}).compose(ObservableUtils.applyDefault()).subscribe(scope -> {
sharingScope.setSummary(formatSharingOption(scope));
});
}
isInitializedForConsent = true;
}