From bcd5262314c631ebd2ccc4ab7d6b155662708146 Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Wed, 10 Jul 2019 21:10:07 +0200 Subject: [PATCH] fix Glide crash in MainActivity (#1379) * fix Glide crash in MainActivity * make emojiInitCallback final --- .../com/keylesspalace/tusky/MainActivity.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java index 28c502cf8..89f24ee83 100644 --- a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java @@ -120,6 +120,13 @@ public final class MainActivity extends BottomSheetActivity implements ActionBut private int notificationTabPosition; private MainPagerAdapter adapter; + private final EmojiCompat.InitCallback emojiInitCallback = new EmojiCompat.InitCallback() { + @Override + public void onInitialized() { + updateProfiles(); + } + }; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -309,6 +316,12 @@ public final class MainActivity extends BottomSheetActivity implements ActionBut } } + @Override + protected void onDestroy() { + super.onDestroy(); + EmojiCompat.get().unregisterInitCallback(emojiInitCallback); + } + private void forwardShare(Intent intent) { Intent composeIntent = new Intent(this, ComposeActivity.class); composeIntent.setAction(intent.getAction()); @@ -438,12 +451,7 @@ public final class MainActivity extends BottomSheetActivity implements ActionBut drawer.addItem(debugItem); } - EmojiCompat.get().registerInitCallback(new EmojiCompat.InitCallback() { - @Override - public void onInitialized() { - updateProfiles(); - } - }); + EmojiCompat.get().registerInitCallback(emojiInitCallback); } private void setupTabs(boolean selectNotificationTab) {