OSDN Git Service

Enabling setWallpaper button only if the image was loaded successfully
authorSunny Goyal <sunnygoyal@google.com>
Thu, 21 May 2015 22:54:58 +0000 (15:54 -0700)
committerSunny Goyal <sunnygoyal@google.com>
Thu, 21 May 2015 23:14:08 +0000 (16:14 -0700)
Bug: 20187333
Change-Id: I1b738a06499d20facbc4bccb1e6247086a45b686

WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java
WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java

index ee0d8b0..f2bb509 100644 (file)
@@ -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,
index 72cb194..3f90203 100644 (file)
@@ -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);
+                    }
                 }
             });
         }