am ba126c09: Disable Set Wallpaper button while loading image

* commit 'ba126c09a5c00cb0a96da6ece0b4ab4d7ed2d8cb':
  Disable Set Wallpaper button while loading image
This commit is contained in:
Selim Cinek
2014-03-21 22:41:07 +00:00
committed by Android Git Automerger
2 changed files with 6 additions and 0 deletions

View File

@ -20,6 +20,7 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="?android:actionButtonStyle" style="?android:actionButtonStyle"
android:id="@+id/set_wallpaper_button"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" > android:layout_height="match_parent" >
<TextView style="?android:actionBarTabTextStyle" <TextView style="?android:actionBarTabTextStyle"

View File

@ -73,6 +73,7 @@ public class WallpaperCropActivity extends Activity {
protected CropView mCropView; protected CropView mCropView;
protected Uri mUri; protected Uri mUri;
private View mSetWallpaperButton;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -109,10 +110,12 @@ public class WallpaperCropActivity extends Activity {
cropImageAndSetWallpaper(imageUri, null, finishActivityWhenDone); cropImageAndSetWallpaper(imageUri, null, finishActivityWhenDone);
} }
}); });
mSetWallpaperButton = findViewById(R.id.set_wallpaper_button);
// Load image in background // Load image in background
final BitmapRegionTileSource.UriBitmapSource bitmapSource = final BitmapRegionTileSource.UriBitmapSource bitmapSource =
new BitmapRegionTileSource.UriBitmapSource(this, imageUri, 1024); new BitmapRegionTileSource.UriBitmapSource(this, imageUri, 1024);
mSetWallpaperButton.setVisibility(View.INVISIBLE);
Runnable onLoad = new Runnable() { Runnable onLoad = new Runnable() {
public void run() { public void run() {
if (bitmapSource.getLoadingState() != BitmapSource.State.LOADED) { if (bitmapSource.getLoadingState() != BitmapSource.State.LOADED) {
@ -120,6 +123,8 @@ public class WallpaperCropActivity extends Activity {
getString(R.string.wallpaper_load_fail), getString(R.string.wallpaper_load_fail),
Toast.LENGTH_LONG).show(); Toast.LENGTH_LONG).show();
finish(); finish();
} else {
mSetWallpaperButton.setVisibility(View.VISIBLE);
} }
} }
}; };