From 5ac185a167faa43c7360a1df1dc74a0fb5215c7a Mon Sep 17 00:00:00 2001 From: Arne Date: Tue, 15 Oct 2024 20:35:37 +0200 Subject: [PATCH] Fix crash caused by WeakRef --- .../conversations/entities/Conversation.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java index d3458e312..5ff65fcaf 100644 --- a/src/main/java/eu/siacs/conversations/entities/Conversation.java +++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java @@ -1790,11 +1790,11 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl } public class ConversationPagerAdapter extends PagerAdapter { - protected WeakReference mPager = new WeakReference(null); - protected WeakReference mTabs = new WeakReference(null); + protected WeakReference mPager = new WeakReference<>(null); + protected WeakReference mTabs = new WeakReference<>(null); ArrayList sessions = null; - protected WeakReference page1 = new WeakReference(null); - protected WeakReference page2 = new WeakReference(null); + protected WeakReference page1 = new WeakReference<>(null); + protected WeakReference page2 = new WeakReference<>(null); protected boolean mOnboarding = false; public void setupViewPager(ViewPager pager, TabLayout tabs, boolean onboarding, Conversation oldConversation) { @@ -1814,15 +1814,15 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl } if (sessions != null) show(); - if (pager.getChildAt(0) != null) page1 = new WeakReference(pager.getChildAt(0)); - if (pager.getChildAt(1) != null) page2 = new WeakReference(pager.getChildAt(1)); + if (pager.getChildAt(0) != null) page1 = new WeakReference<>(pager.getChildAt(0)); + if (pager.getChildAt(1) != null) page2 = new WeakReference<>(pager.getChildAt(1)); if (page2.get() != null && page2.get().findViewById(R.id.commands_view) == null) { page1.clear(); page2.clear(); } if (oldConversation != null) { - if (page1.get() == null) page1 = new WeakReference(oldConversation.pagerAdapter.page1); - if (page2.get() == null) page2 = new WeakReference(oldConversation.pagerAdapter.page2); + if (page1.get() == null) page1 = oldConversation.pagerAdapter.page1; + if (page2.get() == null) page2 = oldConversation.pagerAdapter.page2; } if (page1.get() == null || page2.get() == null) { throw new IllegalStateException("page1 or page2 were not present as child or in model?");