Fix other potential crashes

This commit is contained in:
Benoit Marty 2021-02-16 11:32:16 +01:00
parent bec4af7c87
commit b534d4660c
2 changed files with 4 additions and 2 deletions

View file

@ -29,6 +29,7 @@ import androidx.core.view.ViewCompat
import androidx.core.view.isInvisible import androidx.core.view.isInvisible
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.lifecycle.Lifecycle import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.transition.Transition import androidx.transition.Transition
import im.vector.app.R import im.vector.app.R
import im.vector.app.core.di.ActiveSessionHolder import im.vector.app.core.di.ActiveSessionHolder
@ -131,7 +132,7 @@ class VectorAttachmentViewerActivity : AttachmentViewerActivity(), BaseAttachmen
if (savedInstanceState == null) { if (savedInstanceState == null) {
pager2.setCurrentItem(initialIndex, false) pager2.setCurrentItem(initialIndex, false)
// The page change listener is not notified of the change... // The page change listener is not notified of the change...
pager2.post { lifecycleScope.launchWhenResumed {
onSelectedPositionChanged(initialIndex) onSelectedPositionChanged(initialIndex)
} }
} }

View file

@ -25,6 +25,7 @@ import android.view.ViewGroup
import android.widget.ScrollView import android.widget.ScrollView
import androidx.core.view.forEach import androidx.core.view.forEach
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.lifecycle.lifecycleScope
import com.airbnb.mvrx.activityViewModel import com.airbnb.mvrx.activityViewModel
import com.airbnb.mvrx.args import com.airbnb.mvrx.args
import com.airbnb.mvrx.fragmentViewModel 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 // Scroll to the bottom when adding chips. When removing chips, do not scroll
if (newNumberOfChips >= currentNumberOfChips) { if (newNumberOfChips >= currentNumberOfChips) {
views.chipGroupScrollView.post { viewLifecycleOwner.lifecycleScope.launchWhenResumed {
views.chipGroupScrollView.fullScroll(ScrollView.FOCUS_DOWN) views.chipGroupScrollView.fullScroll(ScrollView.FOCUS_DOWN)
} }
} }