From d16f2552bd2b31b99e26ae92cceda85ff6b44ad0 Mon Sep 17 00:00:00 2001 From: Alec Hill Date: Wed, 29 May 2019 14:32:38 +0100 Subject: [PATCH] Compare activity that is destroyed to the owner of the debug drawer, so that only the owner being destroyed removes drawer lifecycle handling. Otherwise drawer modules become unresponsive when any activity is destroyed. --- .../debugdrawer/DebugDrawerLifecycleCallbacks.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/debugdrawer/src/main/java/io/palaima/debugdrawer/DebugDrawerLifecycleCallbacks.java b/debugdrawer/src/main/java/io/palaima/debugdrawer/DebugDrawerLifecycleCallbacks.java index 45ac32d..98d74ff 100644 --- a/debugdrawer/src/main/java/io/palaima/debugdrawer/DebugDrawerLifecycleCallbacks.java +++ b/debugdrawer/src/main/java/io/palaima/debugdrawer/DebugDrawerLifecycleCallbacks.java @@ -53,8 +53,10 @@ public void onActivitySaveInstanceState(Activity activity, Bundle outState) { @Override public void onActivityDestroyed(Activity activity) { - this.activity.getApplication().unregisterActivityLifecycleCallbacks(this); - this.activity = null; - debugDrawer = null; + if (this.activity == activity) { + this.activity.getApplication().unregisterActivityLifecycleCallbacks(this); + this.activity = null; + debugDrawer = null; + } } }