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
diff --git a/src/com/android/customization/picker/grid/GridOptionPreviewer.java b/src/com/android/customization/picker/grid/GridOptionPreviewer.java
index 8de08cf..5cf327e 100644
--- a/src/com/android/customization/picker/grid/GridOptionPreviewer.java
+++ b/src/com/android/customization/picker/grid/GridOptionPreviewer.java
@@ -64,16 +64,17 @@
         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);
     }