本文整理匯總了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;
}