From 4dbacd79aeda8b2418c5d87b7fdf9e2c64926cd4 Mon Sep 17 00:00:00 2001 From: tonymanou Date: Thu, 12 Jan 2017 00:51:44 +0100 Subject: [PATCH] Matching event [un]registering, call super at the end of onPause/onDestroy Event unregistered in onDestroy() should be registered in onCreate() to avoid being registered multiple times. --- app/src/main/java/com/topjohnwu/magisk/MainActivity.java | 6 +++--- .../main/java/com/topjohnwu/magisk/SettingsActivity.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/MainActivity.java b/app/src/main/java/com/topjohnwu/magisk/MainActivity.java index 050c57cb9..9835eb58a 100644 --- a/app/src/main/java/com/topjohnwu/magisk/MainActivity.java +++ b/app/src/main/java/com/topjohnwu/magisk/MainActivity.java @@ -92,13 +92,13 @@ public class MainActivity extends AppCompatActivity } navigationView.setNavigationItemSelectedListener(this); + CallbackHandler.register(recreate, this); } @Override protected void onResume() { super.onResume(); CallbackHandler.register(StatusFragment.updateCheckDone, this); - CallbackHandler.register(recreate, this); if (StatusFragment.updateCheckDone.isTriggered) { onTrigger(StatusFragment.updateCheckDone); } @@ -107,14 +107,14 @@ public class MainActivity extends AppCompatActivity @Override protected void onPause() { - super.onPause(); CallbackHandler.unRegister(StatusFragment.updateCheckDone, this); + super.onPause(); } @Override protected void onDestroy() { - super.onDestroy(); CallbackHandler.unRegister(recreate, this); + super.onDestroy(); } @Override diff --git a/app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java b/app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java index 6d31c663d..0fdd3ad48 100644 --- a/app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java +++ b/app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java @@ -131,8 +131,8 @@ public class SettingsActivity extends AppCompatActivity { @Override public void onDestroy() { - super.onDestroy(); prefs.unregisterOnSharedPreferenceChangeListener(this); + super.onDestroy(); } @Override