From 8abbd29ca320fe88d0043a51bc4a4f5914480b00 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Thu, 21 May 2015 15:54:58 -0700 Subject: [PATCH] Enabling setWallpaper button only if the image was loaded successfully Bug: 20187333 Change-Id: I1b738a06499d20facbc4bccb1e6247086a45b686 --- .../src/com/android/launcher3/WallpaperCropActivity.java | 1 + .../src/com/android/launcher3/WallpaperPickerActivity.java | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java b/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java index ee0d8b0c6..f2bb50944 100644 --- a/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java +++ b/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java @@ -263,6 +263,7 @@ public class WallpaperCropActivity extends BaseActivity implements Handler.Callb if (req.postExecute != null) { req.postExecute.run(); } + mProgressView.setVisibility(View.GONE); } public final void setCropViewTileSource(BitmapSource bitmapSource, boolean touchEnabled, diff --git a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java index 72cb194d6..3f90203ed 100644 --- a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java +++ b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java @@ -196,13 +196,15 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { @Override public void onClick(final WallpaperPickerActivity a) { a.setWallpaperButtonEnabled(false); - BitmapRegionTileSource.UriBitmapSource bitmapSource = + final BitmapRegionTileSource.UriBitmapSource bitmapSource = new BitmapRegionTileSource.UriBitmapSource(a.getContext(), Uri.fromFile(mFile)); a.setCropViewTileSource(bitmapSource, false, true, null, new Runnable() { @Override public void run() { - a.setWallpaperButtonEnabled(true); + if (bitmapSource.getLoadingState() == BitmapSource.State.LOADED) { + a.setWallpaperButtonEnabled(true); + } } }); } @@ -232,7 +234,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { @Override public void onClick(final WallpaperPickerActivity a) { a.setWallpaperButtonEnabled(false); - BitmapRegionTileSource.ResourceBitmapSource bitmapSource = + final BitmapRegionTileSource.ResourceBitmapSource bitmapSource = new BitmapRegionTileSource.ResourceBitmapSource(mResources, mResId); a.setCropViewTileSource(bitmapSource, false, false, new CropViewScaleProvider() { @@ -249,7 +251,9 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { @Override public void run() { - a.setWallpaperButtonEnabled(true); + if (bitmapSource.getLoadingState() == BitmapSource.State.LOADED) { + a.setWallpaperButtonEnabled(true); + } } }); } -- 2.11.0