lineage-sdk self-removing prefs: don't remove from death row until reaped

*) Graveyard is shared by all prefs with a given context.

*) When we reap in onAttached(), there may be prefs that aren't yet
   attached to the hierarchy.  Ensure that summonReaper keeps
   track of them until the last onAttached() is called in the context.

*) Fixes self-removing prefs that weren't being removed on a settings
   page that has at least one least other self-removing pref.

Change-Id: Ic48b86bb6f06aa29c44814a5487e2382349fb363
This commit is contained in:
Sam Mortimer
2017-12-11 23:17:27 -08:00
committed by Bruno Martins
parent 7ab8aadc8a
commit 0991abb0c3

View File

@@ -331,7 +331,7 @@ public class ConstraintsHelper {
*/
private static class Graveyard {
private final Set<String> mDeathRow = new ArraySet<>();
private Set<String> mDeathRow = new ArraySet<>();
private static Graveyard sInstance;
@@ -374,13 +374,16 @@ public class ConstraintsHelper {
public void summonReaper(PreferenceManager mgr) {
synchronized (mDeathRow) {
Set<String> notReadyForReap = new ArraySet<>();
for (String dead : mDeathRow) {
Preference deadPref = mgr.findPreference(dead);
if (deadPref != null) {
deadPref.setVisible(false);
} else {
notReadyForReap.add(dead);
}
}
mDeathRow.clear();
mDeathRow = notReadyForReap;
}
}
}