summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSantiago Etchebehere <santie@google.com>2022-03-25 14:54:47 -0700
committerSantiago Etchebehere <santie@google.com>2022-03-25 14:54:47 -0700
commit731a7c82755564442319468af9e972e2e1822494 (patch)
tree0bd338034de016286c6cd1f126e6ebdbc587c004 /src
parent652520b219c5b78a580a2d091a16e2a2f9ec36a0 (diff)
downloadThemePicker-731a7c82755564442319468af9e972e2e1822494.tar.gz
Always recreate the SurfaceView when updating the grid preview
This fixes a problem where the preview was rendereed in the wrong position Fixes: 221856837 Test: manual Change-Id: Ib8605a04e4a4ae5e0d5a83b3afe94d0954169198
Diffstat (limited to 'src')
-rw-r--r--src/com/android/customization/picker/grid/GridOptionPreviewer.java19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/com/android/customization/picker/grid/GridOptionPreviewer.java b/src/com/android/customization/picker/grid/GridOptionPreviewer.java
index 8de08cfd..5cf327ed 100644
--- a/src/com/android/customization/picker/grid/GridOptionPreviewer.java
+++ b/src/com/android/customization/picker/grid/GridOptionPreviewer.java
@@ -64,16 +64,17 @@ class GridOptionPreviewer {
if (mSurfaceCallback != null) {
mSurfaceCallback.cleanUp();
mSurfaceCallback.resetLastSurface();
+ if (mGridOptionSurface != null) {
+ mGridOptionSurface.getHolder().removeCallback(mSurfaceCallback);
+ }
}
- if (mGridOptionSurface == null) {
- mGridOptionSurface = new SurfaceView(mPreviewContainer.getContext());
- mGridOptionSurface.setLayoutParams(new ViewGroup.LayoutParams(
- ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
- mGridOptionSurface.setZOrderMediaOverlay(true);
- mSurfaceCallback = new GridOptionSurfaceHolderCallback(mGridOptionSurface,
- mGridOptionSurface.getContext());
- mGridOptionSurface.getHolder().addCallback(mSurfaceCallback);
- }
+ mGridOptionSurface = new SurfaceView(mPreviewContainer.getContext());
+ mGridOptionSurface.setLayoutParams(new ViewGroup.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
+ mGridOptionSurface.setZOrderMediaOverlay(true);
+ mSurfaceCallback = new GridOptionSurfaceHolderCallback(mGridOptionSurface,
+ mGridOptionSurface.getContext());
+ mGridOptionSurface.getHolder().addCallback(mSurfaceCallback);
mPreviewContainer.addView(mGridOptionSurface);
}