@SuppressWarnings("unchecked") protected final P getPreference() { final PreferenceGroup root = mRootPrefGroup.get(); if(root == null) throw new IllegalStateException("mRootPrefGroup is not available anymore"); return (P) root.findPreference(mPrefKey); }
final Preference p = root.findPreference(key); final PreferenceController ph = prefHelpers.get(key);
/** * Note: copied wholesale from Android source * @param key * @return */ @Implementation public Preference findPreference(CharSequence key) { if (TextUtils.equals(getKey(), key)) { return realPreferenceGroup; } final int preferenceCount = getPreferenceCount(); for (int i = 0; i < preferenceCount; i++) { final Preference preference = getPreference(i); final String curKey = preference.getKey(); if (curKey != null && curKey.equals(key)) { return preference; } if (preference instanceof PreferenceGroup) { final Preference returnedPreference = ((PreferenceGroup)preference) .findPreference(key); if (returnedPreference != null) { return returnedPreference; } } } return null; }
if(p != null) if(p.hasKey() && root.findPreference(p.getKey()) == null) root.addPreference(p); continue; if(root.findPreference(key) != null)
final Preference p = root.findPreference(key); if(p == null) throw new IllegalStateException("No preference with key=" + key + " in hierarchy");