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

Commit 2086464d authored by Michael Mikhail's avatar Michael Mikhail
Browse files

[Flexiglass] avoid calling update on removed UMOs in the new list.

Flag: com.android.systemui.scene_container
Bug: 395940287
Test: UI checked.
Test: atest MediaDiffUtilTest
Change-Id: I11f7667ecb02defa2b46e9d5447b789cdf68ed17
parent 0c5e9bb0
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.media.controls.ui.util

import androidx.recyclerview.widget.ListUpdateCallback
import com.android.systemui.media.controls.ui.viewmodel.MediaCommonViewModel
import kotlin.math.min

/** A [ListUpdateCallback] to apply media events needed to reach the new state. */
class MediaViewModelListUpdateCallback(
@@ -46,7 +47,7 @@ class MediaViewModelListUpdateCallback(
    }

    override fun onChanged(position: Int, count: Int, payload: Any?) {
        for (i in position until position + count) {
        for (i in position until min(position + count, new.size)) {
            onUpdated(new[i], position)
        }
    }