Refresh overlay when thumbnail was set for first time

Bug: 202414125
Test: TaplTestsNexus.testOverviewActions && TaplTestsQuickstep.testOverviewActions
Change-Id: I2cc38df4c891fb21a8295d4f9c75e396c71449f2
This commit is contained in:
Alex Chau
2021-11-17 19:03:04 +00:00
parent 90a9982b36
commit 60d5315e19
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;