Merge "Avoid calling getIconResult if recycle is called after request is queued" into sc-v2-dev

This commit is contained in:
Alex Chau 2021-10-25 23:30:32 +00:00 committed by Android (Google) Code Review
commit 4941b84717
1 changed files with 10 additions and 2 deletions

View File

@ -70,6 +70,8 @@ public class FloatingIconView extends FrameLayout implements
// Manages loading the icon on a worker thread
private static @Nullable IconLoadResult sIconLoadResult;
private static long sFetchIconId = 0;
private static long sRecycledFetchIconId = sFetchIconId;
public static final float SHAPE_PROGRESS_DURATION = 0.10f;
private static final RectF sTmpRectF = new RectF();
@ -519,8 +521,13 @@ public class FloatingIconView extends FrameLayout implements
IconLoadResult result = new IconLoadResult(info,
btvIcon == null ? false : btvIcon.isThemed());
MODEL_EXECUTOR.getHandler().postAtFrontOfQueue(() ->
getIconResult(l, v, info, position, btvIcon, result));
final long fetchIconId = sFetchIconId++;
MODEL_EXECUTOR.getHandler().postAtFrontOfQueue(() -> {
if (fetchIconId < sRecycledFetchIconId) {
return;
}
getIconResult(l, v, info, position, btvIcon, result);
});
sIconLoadResult = result;
return result;
@ -622,6 +629,7 @@ public class FloatingIconView extends FrameLayout implements
mOnTargetChangeRunnable = null;
mBadge = null;
sTmpObjArray[0] = null;
sRecycledFetchIconId = sFetchIconId;
mIconLoadResult = null;
mClipIconView.recycle();
mBtvDrawable.setBackground(null);