Merge "Persist docked state so it doesn't get lost in re-inflates" into oc-mr1-dev

This commit is contained in:
TreeHugger Robot
2017-08-15 20:48:09 +00:00
committed by Android (Google) Code Review

View File

@@ -33,6 +33,7 @@ public class DockedStackExistsListener {
private static final String TAG = "DockedStackExistsListener";
private static ArrayList<WeakReference<Consumer<Boolean>>> sCallbacks = new ArrayList<>();
private static boolean mLastExists;
static {
try {
@@ -73,6 +74,7 @@ public class DockedStackExistsListener {
private static void onDockedStackExistsChanged(boolean exists) {
mLastExists = exists;
synchronized (sCallbacks) {
sCallbacks.removeIf(wf -> {
Consumer<Boolean> l = wf.get();
@@ -83,6 +85,7 @@ public class DockedStackExistsListener {
}
public static void register(Consumer<Boolean> callback) {
callback.accept(mLastExists);
synchronized (sCallbacks) {
sCallbacks.add(new WeakReference<>(callback));
}