diff --git a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseAdapter.java b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseAdapter.java index c6373f5e0c5f5..bcef43c93be45 100644 --- a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseAdapter.java +++ b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseAdapter.java @@ -24,6 +24,7 @@ import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; import android.graphics.Typeface; import android.graphics.drawable.Drawable; +import android.graphics.drawable.Icon; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; @@ -41,6 +42,7 @@ import androidx.recyclerview.widget.RecyclerView; import com.android.settingslib.bluetooth.BluetoothUtils; import com.android.settingslib.media.MediaDevice; +import com.android.settingslib.utils.ThreadUtils; import com.android.systemui.R; import com.android.systemui.animation.Interpolators; @@ -116,6 +118,7 @@ public abstract class MediaOutputBaseAdapter extends final View mDivider; final View mBottomDivider; final CheckBox mCheckBox; + private String mDeviceId; MediaDeviceBaseViewHolder(View view) { super(view); @@ -134,8 +137,17 @@ public abstract class MediaOutputBaseAdapter extends } void onBind(MediaDevice device, boolean topMargin, boolean bottomMargin) { - mTitleIcon.setImageIcon(mController.getDeviceIconCompat(device).toIcon(mContext)); - setMargin(topMargin, bottomMargin); + mDeviceId = device.getId(); + ThreadUtils.postOnBackgroundThread(() -> { + Icon icon = mController.getDeviceIconCompat(device).toIcon(mContext); + ThreadUtils.postOnMainThread(() -> { + if (!TextUtils.equals(mDeviceId, device.getId())) { + return; + } + mTitleIcon.setImageIcon(icon); + setMargin(topMargin, bottomMargin); + }); + }); } void onBind(int customizedItem, boolean topMargin, boolean bottomMargin) {