From 037223e28666f2d9294a5b587af35094df1121e3 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Mon, 19 Jul 2021 19:23:16 +0800 Subject: [PATCH] Unregister EventBus listener in onDestroy in TrendingActivity and RPANActivity. --- .../infinityforreddit/activities/RPANActivity.java | 7 +++++++ .../infinityforreddit/activities/TrendingActivity.java | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RPANActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RPANActivity.java index 76ec456b..5d2d47f4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RPANActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RPANActivity.java @@ -30,6 +30,7 @@ import com.evernote.android.state.State; import com.google.android.material.snackbar.Snackbar; import com.livefront.bridge.Bridge; +import org.greenrobot.eventbus.EventBus; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -350,6 +351,12 @@ public class RPANActivity extends AppCompatActivity { return false; } + @Override + protected void onDestroy() { + super.onDestroy(); + EventBus.getDefault().unregister(this); + } + private void shareLink(String link) { try { Intent intent = new Intent(Intent.ACTION_SEND); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java index fa9ac0f0..db550a4f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java @@ -293,6 +293,12 @@ public class TrendingActivity extends BaseActivity { outState.putParcelableArrayList(TRENDING_SEARCHES_STATE, trendingSearches); } + @Override + protected void onDestroy() { + super.onDestroy(); + EventBus.getDefault().unregister(this); + } + @Override protected SharedPreferences getDefaultSharedPreferences() { return mSharedPreferences;