From 84468be6175c2419b5b07d678cbd8e4f1b4ba761 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Thu, 23 Sep 2021 10:55:31 +0200 Subject: [PATCH] catch NPE for popup bubble catch NPE when popup bubble for unread mentions is not available anymore Signed-off-by: Marcel Hibbe --- .../ConversationsListController.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java index ff3868695..6783ca40e 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java @@ -626,18 +626,23 @@ public class ConversationsListController extends BaseController implements Searc } private void checkToShowUnreadBubble() { - int lastVisibleItem = layoutManager.findLastCompletelyVisibleItemPosition(); - for (AbstractFlexibleItem flexItem : callItems) { - Conversation conversationItem = ((ConversationItem) flexItem).getModel(); - int position = adapter.getGlobalPositionOf(flexItem); - if (conversationItem.unreadMention && position > lastVisibleItem) { - if (!newMentionPopupBubble.isShown()){ - newMentionPopupBubble.show(); + try{ + int lastVisibleItem = layoutManager.findLastCompletelyVisibleItemPosition(); + for (AbstractFlexibleItem flexItem : callItems) { + Conversation conversationItem = ((ConversationItem) flexItem).getModel(); + int position = adapter.getGlobalPositionOf(flexItem); + if (conversationItem.unreadMention && position > lastVisibleItem) { + if (!newMentionPopupBubble.isShown()){ + newMentionPopupBubble.show(); + } + return; } - return; } + newMentionPopupBubble.hide(); + } catch (NullPointerException e){ + Log.d(TAG, "A NPE was caught when trying to show the unread popup bubble. This might happen when the " + + "user already left the conversations-list screen so the popup bubble is not available anymore.", e); } - newMentionPopupBubble.hide(); } private void showNewConversationsScreen() {