From 30caa435ae98f4a17ba4d310099ce8fb8bd18ceb Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Mon, 17 Feb 2025 14:59:15 +0100 Subject: [PATCH] Avoid duplicated messages when activity is in background. onDestroy is not called when navigating to the next activity or bringing the app to background. That's why the adapter was not set to null and all messages were added another time the next time the activity comes to foreground. With this fix, the adapter is set to null in onStop. All in all, the adapter handling may not be the best, but will be replaced by Compose anyway.. Signed-off-by: Marcel Hibbe --- app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt index 532f2e44f..2e9012241 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt @@ -562,6 +562,7 @@ class ChatActivity : override fun onStop() { super.onStop() active = false + adapter = null this.lifecycle.removeObserver(AudioUtils) this.lifecycle.removeObserver(chatViewModel) } @@ -2677,7 +2678,6 @@ class ChatActivity : currentlyPlayedVoiceMessage?.let { stopMediaPlayer(it) } // FIXME, mediaplayer can sometimes be null here - adapter = null disposables.dispose() }