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

Commit 0244bdd8 authored by Michael Mikhail's avatar Michael Mikhail
Browse files

Use more generic methods in carousel controller

Flag: ACONFIG media_control_refactor DISABLED
Bug: 328207006
Test: Build
Change-Id: Ic4ef38f8156c22136b1e9efae564e851db4960ea
parent e636d3f1
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -758,7 +758,7 @@ constructor(
                    isSsReactivated,
                    debugLogger
                )
                updatePlayerToState(newPlayer, noAnimation = true)
                updatePlayerToState(newPlayer.mediaViewController, noAnimation = true)
                // Media data added from a recommendation card should starts playing.
                if (
                    (shouldScrollToKey && data.isPlaying == true) ||
@@ -856,7 +856,7 @@ constructor(
                systemClock,
                debugLogger,
            )
            updatePlayerToState(newRecs, noAnimation = true)
            updatePlayerToState(newRecs.mediaViewController, noAnimation = true)
            reorderAllPlayers(curVisibleMediaKey)
            updatePageIndicator()
            mediaFrame.requiresRemeasuring = true
@@ -886,7 +886,7 @@ constructor(
        val removed =
            MediaPlayerData.removeMediaPlayer(key, dismissMediaData || dismissRecommendation)
        return removed?.apply {
            mediaCarouselScrollHandler.onPrePlayerRemoved(removed)
            mediaCarouselScrollHandler.onPrePlayerRemoved(removed.mediaViewHolder?.player)
            mediaContent.removeView(removed.mediaViewHolder?.player)
            mediaContent.removeView(removed.recommendationViewHolder?.recommendations)
            removed.onDestroy()
@@ -980,7 +980,7 @@ constructor(
            currentEndLocation = endLocation
            currentTransitionProgress = progress
            for (mediaPlayer in MediaPlayerData.players()) {
                updatePlayerToState(mediaPlayer, immediately)
                updatePlayerToState(mediaPlayer.mediaViewController, immediately)
            }
            maybeResetSettingsCog()
            updatePageIndicatorAlpha()
@@ -1080,8 +1080,8 @@ constructor(
        }
    }

    private fun updatePlayerToState(mediaPlayer: MediaControlPanel, noAnimation: Boolean) {
        mediaPlayer.mediaViewController.setCurrentState(
    private fun updatePlayerToState(viewController: MediaViewController, noAnimation: Boolean) {
        viewController.setCurrentState(
            startLocation = currentStartLocation,
            endLocation = currentEndLocation,
            transitionProgress = currentTransitionProgress,
+3 −3
Original line number Diff line number Diff line
@@ -31,11 +31,11 @@ import com.android.internal.annotations.VisibleForTesting
import com.android.settingslib.Utils
import com.android.systemui.Gefingerpoken
import com.android.systemui.classifier.Classifier.NOTIFICATION_DISMISS
import com.android.systemui.media.controls.ui.controller.MediaControlPanel
import com.android.systemui.media.controls.util.MediaUiEventLogger
import com.android.systemui.plugins.FalsingManager
import com.android.systemui.qs.PageIndicator
import com.android.systemui.res.R
import com.android.systemui.util.animation.TransitionLayout
import com.android.systemui.util.concurrency.DelayableExecutor
import com.android.wm.shell.shared.animation.PhysicsAnimator

@@ -535,8 +535,8 @@ class MediaCarouselScrollHandler(
     * Notify that a player will be removed right away. This gives us the opporunity to look where
     * it was and update our scroll position.
     */
    fun onPrePlayerRemoved(removed: MediaControlPanel) {
        val removedIndex = mediaContent.indexOfChild(removed.mediaViewHolder?.player)
    fun onPrePlayerRemoved(player: TransitionLayout?) {
        val removedIndex = mediaContent.indexOfChild(player)
        // If the removed index is less than the visibleMediaIndex, then we need to decrement it.
        // RTL has no effect on this, because indices are always relative (start-to-end).
        // Update the index 'manually' since we won't always get a call to onMediaScrollingChanged