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

Commit ea88d968 authored by Lucas Dupin's avatar Lucas Dupin Committed by Automerger Merge Worker
Browse files

Merge "[ANR] Read device icon on the main thread" into sc-dev am: 1ecac1ab

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14461326

Change-Id: Ia1719df8f9af20ea58c598bf94db22059ca419e9
parents 581472ea 1ecac1ab
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -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));
            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) {