From b534d4660c2ab9b77d1c62531673c0df6cd0a174 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 16 Feb 2021 11:32:16 +0100 Subject: [PATCH] Fix other potential crashes --- .../app/features/media/VectorAttachmentViewerActivity.kt | 3 ++- .../im/vector/app/features/userdirectory/UserListFragment.kt | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/media/VectorAttachmentViewerActivity.kt b/vector/src/main/java/im/vector/app/features/media/VectorAttachmentViewerActivity.kt index c632a008ce..158dbfdaae 100644 --- a/vector/src/main/java/im/vector/app/features/media/VectorAttachmentViewerActivity.kt +++ b/vector/src/main/java/im/vector/app/features/media/VectorAttachmentViewerActivity.kt @@ -29,6 +29,7 @@ import androidx.core.view.ViewCompat import androidx.core.view.isInvisible import androidx.core.view.isVisible import androidx.lifecycle.Lifecycle +import androidx.lifecycle.lifecycleScope import androidx.transition.Transition import im.vector.app.R import im.vector.app.core.di.ActiveSessionHolder @@ -131,7 +132,7 @@ class VectorAttachmentViewerActivity : AttachmentViewerActivity(), BaseAttachmen if (savedInstanceState == null) { pager2.setCurrentItem(initialIndex, false) // The page change listener is not notified of the change... - pager2.post { + lifecycleScope.launchWhenResumed { onSelectedPositionChanged(initialIndex) } } diff --git a/vector/src/main/java/im/vector/app/features/userdirectory/UserListFragment.kt b/vector/src/main/java/im/vector/app/features/userdirectory/UserListFragment.kt index 96f459cbbf..4a87d13021 100644 --- a/vector/src/main/java/im/vector/app/features/userdirectory/UserListFragment.kt +++ b/vector/src/main/java/im/vector/app/features/userdirectory/UserListFragment.kt @@ -25,6 +25,7 @@ import android.view.ViewGroup import android.widget.ScrollView import androidx.core.view.forEach import androidx.core.view.isVisible +import androidx.lifecycle.lifecycleScope import com.airbnb.mvrx.activityViewModel import com.airbnb.mvrx.args import com.airbnb.mvrx.fragmentViewModel @@ -171,7 +172,7 @@ class UserListFragment @Inject constructor( // Scroll to the bottom when adding chips. When removing chips, do not scroll if (newNumberOfChips >= currentNumberOfChips) { - views.chipGroupScrollView.post { + viewLifecycleOwner.lifecycleScope.launchWhenResumed { views.chipGroupScrollView.fullScroll(ScrollView.FOCUS_DOWN) } }