Refresh overlay when thumbnail was set for first time am: 60d5315e19

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/16279507

Change-Id: Ie7f068b1839ec461ec52c7a2e201342b41131569
This commit is contained in:
Alex Chau
2021-11-18 12:20:33 +00:00
committed by Automerger Merge Worker
2 changed files with 12 additions and 10 deletions

View File

@@ -208,13 +208,6 @@ public class TaskOverlayFactory implements ResourceBasedOverride {
}
}
/**
* Called when the current task's thumbnail has changed.
*/
public void refreshActionVisibility(ThumbnailData thumbnail) {
getActionsView().updateDisabledFlags(DISABLED_NO_THUMBNAIL, thumbnail == null);
}
/**
* End rendering live tile in Overview.
*

View File

@@ -148,10 +148,11 @@ public class TaskThumbnailView extends View {
public void setThumbnail(@Nullable Task task, @Nullable ThumbnailData thumbnailData,
boolean refreshNow) {
mTask = task;
boolean thumbnailWasNull = mThumbnailData == null;
mThumbnailData =
(thumbnailData != null && thumbnailData.thumbnail != null) ? thumbnailData : null;
if (refreshNow) {
refresh();
refresh(thumbnailWasNull && mThumbnailData != null);
}
}
@@ -162,14 +163,22 @@ public class TaskThumbnailView extends View {
/** Updates the shader, paint, matrix to redraw. */
public void refresh() {
refresh(false);
}
/**
* Updates the shader, paint, matrix to redraw.
* @param shouldRefreshOverlay whether to re-initialize overlay
*/
private void refresh(boolean shouldRefreshOverlay) {
if (mThumbnailData != null && mThumbnailData.thumbnail != null) {
Bitmap bm = mThumbnailData.thumbnail;
bm.prepareToDraw();
mBitmapShader = new BitmapShader(bm, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
mPaint.setShader(mBitmapShader);
updateThumbnailMatrix();
if (mOverlayEnabled) {
getTaskOverlay().refreshActionVisibility(mThumbnailData);
if (shouldRefreshOverlay) {
refreshOverlay();
}
} else {
mBitmapShader = null;