List of usage examples for android.preference PreferenceGroup getPreferenceCount
public int getPreferenceCount()
From source file:Main.java
private static ArrayList<Preference> getPreferenceList(Preference p, ArrayList<Preference> list) { if (p instanceof PreferenceCategory || p instanceof PreferenceScreen) { PreferenceGroup pGroup = (PreferenceGroup) p; int pCount = pGroup.getPreferenceCount(); for (int i = 0; i < pCount; i++) { getPreferenceList(pGroup.getPreference(i), list); // recursive call }// w w w . ja va2 s . com } else { list.add(p); } return list; }
From source file:Main.java
private static void replaceAllCheckBoxPreferencesBySwitchPreferences(final PreferenceGroup group) { final ArrayList<Preference> preferences = new ArrayList<>(); final int count = group.getPreferenceCount(); for (int index = 0; index < count; index++) { preferences.add(group.getPreference(index)); }/*from w w w .j a va2 s .c o m*/ group.removeAll(); for (int index = 0; index < count; index++) { final Preference preference = preferences.get(index); if (preference instanceof CheckBoxPreference) { addSwitchPreferenceBasedOnCheckBoxPreference((CheckBoxPreference) preference, group); } else { group.addPreference(preference); if (preference instanceof PreferenceGroup) { replaceAllCheckBoxPreferencesBySwitchPreferences((PreferenceGroup) preference); } } } }
From source file:org.namelessrom.devicecontrol.ui.views.CustomPreferenceFragment.java
public void removeIfEmpty(final PreferenceScreen root, final PreferenceGroup preferenceGroup) { if (root != null && preferenceGroup.getPreferenceCount() == 0) { root.removePreference(preferenceGroup); }/*from www .j a v a 2s .co m*/ }
From source file:org.mozilla.gecko.GeckoPreferences.java
private void initGroups(PreferenceGroup preferences) { final int count = preferences.getPreferenceCount(); for (int i = 0; i < count; i++) { Preference pref = preferences.getPreference(i); if (pref instanceof PreferenceGroup) initGroups((PreferenceGroup) pref); else {/*from w w w. ja v a 2 s . c om*/ pref.setOnPreferenceChangeListener(this); mPreferencesList.add(pref.getKey()); } } }
From source file:com.android.inputmethod.latin.settings.CustomInputStyleSettingsFragment.java
private InputMethodSubtype[] getSubtypes() { final PreferenceGroup group = getPreferenceScreen(); final ArrayList<InputMethodSubtype> subtypes = new ArrayList<>(); final int count = group.getPreferenceCount(); for (int i = 0; i < count; i++) { final Preference pref = group.getPreference(i); if (pref instanceof CustomInputStylePreference) { final CustomInputStylePreference subtypePref = (CustomInputStylePreference) pref; // We should not save newly adding subtype to preference because it is incomplete. if (subtypePref.isIncomplete()) continue; subtypes.add(subtypePref.getSubtype()); }//from w ww .j a v a 2 s. co m } return subtypes.toArray(new InputMethodSubtype[subtypes.size()]); }
From source file:com.mobiletin.inputmethod.indic.settings.CustomInputStyleSettingsFragment.java
private InputMethodSubtype[] getSubtypes() { final PreferenceGroup group = getPreferenceScreen(); final ArrayList<InputMethodSubtype> subtypes = new ArrayList<>(); final int count = group.getPreferenceCount(); for (int i = 0; i < count; i++) { final Preference pref = group.getPreference(i); if (pref instanceof SubtypePreference) { final SubtypePreference subtypePref = (SubtypePreference) pref; // We should not save newly adding subtype to preference because it is incomplete. if (subtypePref.isIncomplete()) continue; subtypes.add(subtypePref.getSubtype()); }// ww w .ja v a2 s . c om } return subtypes.toArray(new InputMethodSubtype[subtypes.size()]); }
From source file:com.ichi2.anki.PreferenceContext.java
/** * Loop over every preference in the list and set the summary text */// w w w .j ava 2 s . c o m private void initAllPreferences(PreferenceScreen screen) { for (int i = 0; i < screen.getPreferenceCount(); ++i) { Preference preference = screen.getPreference(i); if (preference instanceof PreferenceGroup) { PreferenceGroup preferenceGroup = (PreferenceGroup) preference; for (int j = 0; j < preferenceGroup.getPreferenceCount(); ++j) { Preference nestedPreference = preferenceGroup.getPreference(j); if (nestedPreference instanceof PreferenceGroup) { PreferenceGroup nestedPreferenceGroup = (PreferenceGroup) nestedPreference; for (int k = 0; k < nestedPreferenceGroup.getPreferenceCount(); ++k) { initPreference(nestedPreferenceGroup.getPreference(k)); } } else { initPreference(preferenceGroup.getPreference(j)); } } } else { initPreference(preference); } } }
From source file:de.mrapp.android.preference.activity.PreferenceFragment.java
/** * Applies Material style on all preferences, which are contained by a specific preference * group, and on the group itself.//from w ww. j a v a 2s . c o m * * @param preferenceGroup * The preference group, at whose preferences the Material style should be applied on, * as an instance of the class {@link PreferenceGroup}. The preference group may not be * null * @param decorator * The decorator, which should be used to apply the Material style, as an instance of * the class {@link PreferenceDecorator}. The decorator may not be null */ private void applyMaterialStyle(@NonNull final PreferenceGroup preferenceGroup, @NonNull final PreferenceDecorator decorator) { for (int i = 0; i < preferenceGroup.getPreferenceCount(); i++) { Preference preference = preferenceGroup.getPreference(i); if (preference instanceof PreferenceGroup) { decorator.applyDecorator(preference); applyMaterialStyle((PreferenceGroup) preference, decorator); } else { decorator.applyDecorator(preference); } } }
From source file:de.mrapp.android.preference.activity.PreferenceFragment.java
/** * Restores the default preferences, which are contained by a specific preference group. * * @param preferenceGroup//from w ww .j a v a 2 s . co m * The preference group, whose preferences should be restored, as an instance of the * class {@link PreferenceGroup}. The preference group may not be null * @param sharedPreferences * The shared preferences, which should be used to restore the preferences, as an * instance of the type {@link SharedPreferences}. The shared preferences may not be * null */ private void restoreDefaults(@NonNull final PreferenceGroup preferenceGroup, @NonNull final SharedPreferences sharedPreferences) { for (int i = 0; i < preferenceGroup.getPreferenceCount(); i++) { Preference preference = preferenceGroup.getPreference(i); if (preference instanceof PreferenceGroup) { restoreDefaults((PreferenceGroup) preference, sharedPreferences); } else if (preference.getKey() != null && !preference.getKey().isEmpty()) { Object oldValue = sharedPreferences.getAll().get(preference.getKey()); if (notifyOnRestoreDefaultValueRequested(preference, oldValue)) { sharedPreferences.edit().remove(preference.getKey()).apply(); preferenceGroup.removePreference(preference); preferenceGroup.addPreference(preference); Object newValue = sharedPreferences.getAll().get(preference.getKey()); notifyOnRestoredDefaultValue(preference, oldValue, newValue); } else { preferenceGroup.removePreference(preference); preferenceGroup.addPreference(preference); } } } }