Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 58476b4c authored by Johannes Gallmann's avatar Johannes Gallmann
Browse files

Load QuickAffordance data before fragment transitions

Bug: 278929581
Test: Manual, i.e. analysing screen recordings
Change-Id: I0dc15d40fbde21ae8ab71fd273cb9830d2aa8342
parent 6d1bafdb
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import com.android.wallpaper.picker.common.icon.ui.viewbinder.IconViewBinder
import com.android.wallpaper.picker.common.icon.ui.viewmodel.Icon
import com.android.wallpaper.picker.option.ui.adapter.OptionItemAdapter
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.collectIndexed
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flatMapLatest
@@ -99,17 +100,22 @@ object KeyguardQuickAffordancePickerBinder {
                                selectedFlags.indexOfFirst { it }
                            }
                        }
                        .collect { selectedPosition ->
                        .collectIndexed { index, selectedPosition ->
                            // Scroll the view to show the first selected affordance.
                            if (selectedPosition != -1) {
                                // We use "post" because we need to give the adapter item a pass to
                                // update the view.
                                affordancesView.post {
                                    if (index == 0) {
                                        // don't animate on initial collection
                                        affordancesView.scrollToPosition(selectedPosition)
                                    } else {
                                        affordancesView.smoothScrollToPosition(selectedPosition)
                                    }
                                }
                            }
                        }
                }

                launch {
                    viewModel.dialog.distinctUntilChanged().collect { dialogRequest ->
+1 −1
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ object KeyguardQuickAffordanceSectionViewBinder {

        lifecycleOwner.lifecycleScope.launch {
            viewModel.summary
                .flowWithLifecycle(lifecycleOwner.lifecycle, Lifecycle.State.RESUMED)
                .flowWithLifecycle(lifecycleOwner.lifecycle, Lifecycle.State.STARTED)
                .collectLatest { summary ->
                    TextViewBinder.bind(
                        view = descriptionView,
+2 −2
Original line number Diff line number Diff line
@@ -33,9 +33,7 @@ import com.android.customization.picker.quickaffordance.ui.viewmodel.KeyguardQui
import com.android.wallpaper.R
import com.android.wallpaper.module.InjectorProvider
import com.android.wallpaper.picker.AppbarFragment
import kotlinx.coroutines.ExperimentalCoroutinesApi

@OptIn(ExperimentalCoroutinesApi::class)
class KeyguardQuickAffordancePickerFragment : AppbarFragment() {
    companion object {
        const val DESTINATION_ID = "quick_affordances"
@@ -80,6 +78,8 @@ class KeyguardQuickAffordancePickerFragment : AppbarFragment() {
            viewModel = viewModel,
            lifecycleOwner = this,
        )
        postponeEnterTransition()
        view.post { startPostponedEnterTransition() }
        (returnTransition as? Transition)?.doOnStart {
            // Hide preview during exit transition animation
            view?.findViewById<View>(R.id.preview)?.isVisible = false