summaryrefslogtreecommitdiffstats
path: root/WallpaperPicker/src/com/android
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-04-15 23:38:17 +0000
committerSunny Goyal <sunnygoyal@google.com>2015-04-15 23:38:17 +0000
commitb4b01efa438953b0a9fcb5b83a6a619e24c93ea3 (patch)
tree81931eb84f0f78c594142eb60f764ce6694c6df0 /WallpaperPicker/src/com/android
parent65776c43590e506f2ce1906b1421caad95448010 (diff)
downloadandroid_packages_apps_Trebuchet-b4b01efa438953b0a9fcb5b83a6a619e24c93ea3.tar.gz
android_packages_apps_Trebuchet-b4b01efa438953b0a9fcb5b83a6a619e24c93ea3.tar.bz2
android_packages_apps_Trebuchet-b4b01efa438953b0a9fcb5b83a6a619e24c93ea3.zip
Revert "Disable setWallpaper button until the wallpaper is loaded"
Will submit again after the drop This reverts commit 65776c43590e506f2ce1906b1421caad95448010. Change-Id: I5f85d0c70f3f5faf85d9ba16e82d4714b694a193
Diffstat (limited to 'WallpaperPicker/src/com/android')
-rw-r--r--WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java71
1 files changed, 30 insertions, 41 deletions
diff --git a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java
index 93320919e..c49286a75 100644
--- a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java
+++ b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java
@@ -137,32 +137,39 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
public static class UriWallpaperInfo extends WallpaperTileInfo {
private Uri mUri;
+ private boolean mFirstClick = true;
+ @Thunk BitmapRegionTileSource.UriBitmapSource mBitmapSource;
public UriWallpaperInfo(Uri uri) {
mUri = uri;
}
@Override
public void onClick(final WallpaperPickerActivity a) {
- a.setWallpaperButtonEnabled(false);
- final BitmapRegionTileSource.UriBitmapSource bitmapSource =
- new BitmapRegionTileSource.UriBitmapSource(
- a.getContext(), mUri, BitmapRegionTileSource.MAX_PREVIEW_SIZE);
- a.setCropViewTileSource(bitmapSource, true, false, null, new Runnable() {
-
- @Override
- public void run() {
- if (bitmapSource.getLoadingState() == BitmapSource.State.LOADED) {
- a.selectTile(mView);
- a.setWallpaperButtonEnabled(true);
- } else {
- ViewGroup parent = (ViewGroup) mView.getParent();
- if (parent != null) {
- parent.removeView(mView);
- Toast.makeText(a.getContext(), R.string.image_load_fail,
- Toast.LENGTH_SHORT).show();
+ final Runnable onLoad;
+ if (!mFirstClick) {
+ onLoad = null;
+ } else {
+ mFirstClick = false;
+ a.mSetWallpaperButton.setEnabled(false);
+ onLoad = new Runnable() {
+ public void run() {
+ if (mBitmapSource != null &&
+ mBitmapSource.getLoadingState() == BitmapSource.State.LOADED) {
+ a.selectTile(mView);
+ a.mSetWallpaperButton.setEnabled(true);
+ } else {
+ ViewGroup parent = (ViewGroup) mView.getParent();
+ if (parent != null) {
+ parent.removeView(mView);
+ Toast.makeText(a.getContext(), R.string.image_load_fail,
+ Toast.LENGTH_SHORT).show();
+ }
}
}
- }
- });
+ };
+ }
+ mBitmapSource = new BitmapRegionTileSource.UriBitmapSource(
+ a.getContext(), mUri, BitmapRegionTileSource.MAX_PREVIEW_SIZE);
+ a.setCropViewTileSource(mBitmapSource, true, false, null, onLoad);
}
@Override
public void onSave(final WallpaperPickerActivity a) {
@@ -196,18 +203,11 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
mThumb = thumb;
}
@Override
- public void onClick(final WallpaperPickerActivity a) {
- a.setWallpaperButtonEnabled(false);
+ public void onClick(WallpaperPickerActivity a) {
BitmapRegionTileSource.UriBitmapSource bitmapSource =
new BitmapRegionTileSource.UriBitmapSource(a.getContext(),
Uri.fromFile(mFile), 1024);
- a.setCropViewTileSource(bitmapSource, false, true, null, new Runnable() {
-
- @Override
- public void run() {
- a.setWallpaperButtonEnabled(true);
- }
- });
+ a.setCropViewTileSource(bitmapSource, false, true, null, null);
}
@Override
public void onSave(WallpaperPickerActivity a) {
@@ -234,7 +234,6 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
}
@Override
public void onClick(final WallpaperPickerActivity a) {
- a.setWallpaperButtonEnabled(false);
BitmapRegionTileSource.ResourceBitmapSource bitmapSource =
new BitmapRegionTileSource.ResourceBitmapSource(
mResources, mResId, BitmapRegionTileSource.MAX_PREVIEW_SIZE);
@@ -249,13 +248,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
wallpaperSize.x, wallpaperSize.y, false);
return wallpaperSize.x / crop.width();
}
- }, new Runnable() {
-
- @Override
- public void run() {
- a.setWallpaperButtonEnabled(true);
- }
- });
+ }, null);
}
@Override
public void onSave(WallpaperPickerActivity a) {
@@ -427,7 +420,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
}
return;
}
- setWallpaperButtonEnabled(true);
+ mSetWallpaperButton.setEnabled(true);
WallpaperTileInfo info = (WallpaperTileInfo) v.getTag();
if (info.isSelectable() && v.getVisibility() == View.VISIBLE) {
selectTile(v);
@@ -646,10 +639,6 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
};
}
- public void setWallpaperButtonEnabled(boolean enabled) {
- mSetWallpaperButton.setEnabled(enabled);
- }
-
@Thunk void selectTile(View v) {
if (mSelectedTile != null) {
mSelectedTile.setSelected(false);