use of com.android.settings.widget.FilterTouchesSwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DeviceAdminListPreferenceController method refreshUI.
private void refreshUI() {
if (mPreferenceGroup == null) {
return;
}
if (mFooterPreferenceMixin != null) {
final FooterPreference footer = mFooterPreferenceMixin.createFooterPreference();
footer.setTitle(R.string.no_device_admins);
footer.setVisible(mAdmins.isEmpty());
}
final Map<String, FilterTouchesSwitchPreference> preferenceCache = new ArrayMap<>();
final Context prefContext = mPreferenceGroup.getContext();
final int childrenCount = mPreferenceGroup.getPreferenceCount();
for (int i = 0; i < childrenCount; i++) {
final Preference pref = mPreferenceGroup.getPreference(i);
if (!(pref instanceof FilterTouchesSwitchPreference)) {
continue;
}
final FilterTouchesSwitchPreference appSwitch = (FilterTouchesSwitchPreference) pref;
preferenceCache.put(appSwitch.getKey(), appSwitch);
}
for (DeviceAdminListItem item : mAdmins) {
final String key = item.getKey();
FilterTouchesSwitchPreference pref = preferenceCache.remove(key);
if (pref == null) {
pref = new FilterTouchesSwitchPreference(prefContext);
mPreferenceGroup.addPreference(pref);
}
bindPreference(item, pref);
}
for (FilterTouchesSwitchPreference unusedCacheItem : preferenceCache.values()) {
mPreferenceGroup.removePreference(unusedCacheItem);
}
}
Aggregations