Merge "Post rendering low res image when using SurfaceView for wallpaper preview" into ub-launcher3-master
diff --git a/src/com/android/wallpaper/picker/ImagePreviewFragment.java b/src/com/android/wallpaper/picker/ImagePreviewFragment.java
index 56f2df7..c3d2fc4 100755
--- a/src/com/android/wallpaper/picker/ImagePreviewFragment.java
+++ b/src/com/android/wallpaper/picker/ImagePreviewFragment.java
@@ -32,6 +32,7 @@
 import android.graphics.PointF;
 import android.graphics.Rect;
 import android.os.Bundle;
+import android.os.Handler;
 import android.view.Display;
 import android.view.LayoutInflater;
 import android.view.Surface;
@@ -74,6 +75,8 @@
 
     private static final float DEFAULT_WALLPAPER_MAX_ZOOM = 8f;
 
+    private final Handler mHandler = new Handler();
+
     private SubsamplingScaleImageView mFullResImageView;
     private Asset mWallpaperAsset;
     private Point mDefaultCropSurfaceSize;
@@ -183,9 +186,16 @@
         // Load a low-res placeholder image if there's a thumbnail available from the asset that can
         // be shown to the user more quickly than the full-sized image.
         if (mWallpaperAsset.hasLowResDataSource()) {
-            mWallpaperAsset.loadLowResDrawable(activity, mLowResImageView, Color.BLACK,
-                    new WallpaperPreviewBitmapTransformation(activity.getApplicationContext(),
-                            isRtl()));
+            if (!USE_NEW_UI) {
+                mWallpaperAsset.loadLowResDrawable(activity, mLowResImageView, Color.BLACK,
+                        new WallpaperPreviewBitmapTransformation(
+                                activity.getApplicationContext(), isRtl()));
+            } else {
+                mHandler.post(() ->
+                        mWallpaperAsset.loadLowResDrawable(activity, mLowResImageView, Color.BLACK,
+                                new WallpaperPreviewBitmapTransformation(
+                                        activity.getApplicationContext(), isRtl())));
+            }
         }
 
         mWallpaperAsset.decodeRawDimensions(getActivity(), dimensions -> {