From 3c2e2552ec7d8a74e9e1cc113765983deddd89ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Mart=C3=ADn?= Date: Tue, 4 Oct 2022 12:57:18 +0200 Subject: [PATCH] Simplify child fragment replacement logic --- .../vector/app/features/home/room/detail/TimelineFragment.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt index 4def538c46..c9e8382a6b 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt @@ -71,6 +71,7 @@ import im.vector.app.core.extensions.ensureEndsLeftToRight import im.vector.app.core.extensions.filterDirectionOverrides import im.vector.app.core.extensions.hideKeyboard import im.vector.app.core.extensions.registerStartForActivityResult +import im.vector.app.core.extensions.replaceChildFragment import im.vector.app.core.extensions.setTextOrHide import im.vector.app.core.extensions.toMvRxBundle import im.vector.app.core.extensions.trackItemsVisibilityChange @@ -298,13 +299,13 @@ class TimelineFragment : } } - childFragmentManager.findFragmentById(R.id.composerContainer) as? MessageComposerFragment ?: run { + if (childFragmentManager.findFragmentById(R.id.composerContainer) == null) { childFragmentManager.commitTransaction { replace(R.id.composerContainer, MessageComposerFragment()) } } - childFragmentManager.findFragmentById(R.id.voiceMessageRecorderContainer) as? VoiceRecorderFragment ?: run { + if (childFragmentManager.findFragmentById(R.id.voiceMessageRecorderContainer) == null) { childFragmentManager.commitTransaction { replace(R.id.voiceMessageRecorderContainer, VoiceRecorderFragment()) }