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

@@ -176,11 +176,19 @@ public abstract class DeviceListPreferenceFragment extends
return;
}
BluetoothDevicePreference preference = new BluetoothDevicePreference(
getPrefContext(), cachedDevice);
String key = cachedDevice.getDevice().getAddress();
BluetoothDevicePreference preference = (BluetoothDevicePreference) getCachedPreference(key);
if (preference == null) {
preference = new BluetoothDevicePreference(getPrefContext(), cachedDevice);
mDeviceListGroup.addPreference(preference);
} else {
// Tell the preference it is being re-used in case there is new info in the
// cached device.
preference.rebind();
}
initDevicePreference(preference);
mDeviceListGroup.addPreference(preference);
mDevicePreferenceMap.put(cachedDevice, preference);
}