Workarounds to avoid removing all prefs

Removing all prefs causes ugly animations, so avoid it at all cost
and cache all the prefs (while still added) as long as possible.

Bug: 26271353
Change-Id: I33b84d751938b460f4b66c0158057407dd45d974
This commit is contained in:
Jason Monk
2016-02-25 13:55:48 -05:00
parent 6c09bd2538
commit 2071eda150
5 changed files with 72 additions and 29 deletions

View File

@@ -649,19 +649,22 @@ public class WifiSettings extends RestrictedSettingsFragment
boolean hasAvailableAccessPoints = false;
int index = 0;
cacheRemoveAllPrefs(getPreferenceScreen());
for (AccessPoint accessPoint : accessPoints) {
// Ignore access points that are out of range.
if (accessPoint.getLevel() != -1) {
String key = accessPoint.getBssid();
hasAvailableAccessPoints = true;
if (accessPoint.getTag() != null) {
final Preference pref = (Preference) accessPoint.getTag();
LongPressAccessPointPreference pref = (LongPressAccessPointPreference)
getCachedPreference(key);
if (pref != null) {
pref.setOrder(index++);
getPreferenceScreen().addPreference(pref);
continue;
}
LongPressAccessPointPreference
preference = new LongPressAccessPointPreference(accessPoint,
getPrefContext(), mUserBadgeCache, false, this);
preference.setKey(key);
preference.setOrder(index++);
if (mOpenSsid != null && mOpenSsid.equals(accessPoint.getSsidStr())
@@ -674,6 +677,7 @@ public class WifiSettings extends RestrictedSettingsFragment
accessPoint.setListener(this);
}
}
removeCachedPrefs(getPreferenceScreen());
if (!hasAvailableAccessPoints) {
setProgressBarVisible(true);
Preference pref = new Preference(getContext()) {