From bb38fd9d2da84b840c415eaf2da8b5280f7f99bf Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Mon, 27 Feb 2023 13:19:15 +0100 Subject: [PATCH 1/2] avoid NPE for unread bubble in chat 2023-02-27 12:29:00.275 995-995 AndroidRuntime......... java.lang.NullPointerException at com.nextcloud.talk.controllers.ChatController.modifyMessageCount(ChatController.kt:2536) at com.nextcloud.talk.controllers.ChatController.addMessagesToAdapter(ChatController.kt:2515) at com.nextcloud.talk.controllers.ChatController.processMessagesFromTheFuture(ChatController.kt:2489) at com.nextcloud.talk.controllers.ChatController.processMessages(ChatController.kt:2437) at com.nextcloud.talk.controllers.ChatController.processMessagesResponse(ChatController.kt:2398) at com.nextcloud.talk.controllers.ChatController.access$processMessagesResponse(ChatController.kt:221) at com.nextcloud.talk.controllers.ChatController$pullChatMessages$2.onNext(ChatController.kt:2309) at com.nextcloud.talk.controllers.ChatController$pullChatMessages$2.onNext(ChatController.kt:2294) at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.drainNormal(ObservableObserveOn.java:201) at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.run(ObservableObserveOn.java:255) at io.reactivex.android.schedulers.HandlerScheduler$ScheduledRunnable.run(HandlerScheduler.java:124) at android.os.Handler.handleCallback(Handler.java:942) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at android.app.ActivityThread.main(ActivityThread.java:8741) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067) Signed-off-by: Marcel Hibbe --- .../nextcloud/talk/controllers/ChatController.kt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt index 01badf1ab..1de090bde 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt +++ b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt @@ -2533,12 +2533,14 @@ class ChatController(args: Bundle) : private fun modifyMessageCount(shouldAddNewMessagesNotice: Boolean, shouldScroll: Boolean) { if (!shouldAddNewMessagesNotice && !shouldScroll) { - if (!binding?.popupBubbleView?.isShown!!) { - newMessagesCount = 1 - binding?.scrollDownButton?.visibility = View.GONE - binding?.popupBubbleView?.show() - } else if (binding?.popupBubbleView?.isShown!!) { - newMessagesCount++ + binding?.popupBubbleView?.isShown?.let { + if (it) { + newMessagesCount++ + } else { + newMessagesCount = 1 + binding?.scrollDownButton?.visibility = View.GONE + binding?.popupBubbleView?.show() + } } } else { newMessagesCount = 0 From 1c660cc02f18fe1c3214974eb83bafbd54b65749 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Mon, 27 Feb 2023 13:28:58 +0100 Subject: [PATCH 2/2] Hide scroll to bottom button when automatically scrolled to new message Signed-off-by: Marcel Hibbe --- .../main/java/com/nextcloud/talk/controllers/ChatController.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt index 1de090bde..994caf8b2 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt +++ b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt @@ -2543,6 +2543,7 @@ class ChatController(args: Bundle) : } } } else { + binding?.scrollDownButton?.visibility = View.GONE newMessagesCount = 0 } }