diff options
| author | Bobby Georgescu <georgescu@google.com> | 2013-01-29 00:51:51 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-01-29 00:51:52 +0000 |
| commit | 7805371bbe17bca129bfd1902f23227b27312854 (patch) | |
| tree | 496c221653c2f32beead5a9811aecc5a11bac08d /src | |
| parent | 3a67b242889f81d3a124de7a9763a6ca72bc5194 (diff) | |
| parent | d00f521a3138a8f244c91748b0277290edbf61f6 (diff) | |
| download | android_packages_apps_Gallery2-7805371bbe17bca129bfd1902f23227b27312854.tar.gz android_packages_apps_Gallery2-7805371bbe17bca129bfd1902f23227b27312854.tar.bz2 android_packages_apps_Gallery2-7805371bbe17bca129bfd1902f23227b27312854.zip | |
Merge "Fix ANRs due to waiting for IO on UI thread" into gb-ub-photos-bryce
Diffstat (limited to 'src')
| -rw-r--r-- | src/com/android/gallery3d/app/AbstractGalleryActivity.java | 4 | ||||
| -rw-r--r-- | src/com/android/gallery3d/app/PhotoPage.java | 4 | ||||
| -rw-r--r-- | src/com/android/gallery3d/ui/MenuExecutor.java | 14 |
3 files changed, 14 insertions, 8 deletions
diff --git a/src/com/android/gallery3d/app/AbstractGalleryActivity.java b/src/com/android/gallery3d/app/AbstractGalleryActivity.java index acfc033b7..c9cce811a 100644 --- a/src/com/android/gallery3d/app/AbstractGalleryActivity.java +++ b/src/com/android/gallery3d/app/AbstractGalleryActivity.java @@ -343,9 +343,7 @@ public class AbstractGalleryActivity extends Activity implements GalleryContext if (mBatchServiceIsBound && mBatchService != null) { return mBatchService.getThreadPool(); } else { - // Fall back on the old behavior if for some reason the - // service is not available. - return getThreadPool(); + throw new RuntimeException("Batch service unavailable"); } } } diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index c110a8ccc..b3a6040de 100644 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -1217,9 +1217,7 @@ public abstract class PhotoPage extends ActivityState implements @Override public void onCommitDeleteImage() { if (mDeletePath == null) return; - mSelectionManager.deSelectAll(); - mSelectionManager.toggle(mDeletePath); - mMenuExecutor.onMenuClicked(R.id.action_delete, null, true, false); + mMenuExecutor.startSingleItemAction(R.id.action_delete, mDeletePath); mDeletePath = null; } diff --git a/src/com/android/gallery3d/ui/MenuExecutor.java b/src/com/android/gallery3d/ui/MenuExecutor.java index 28fd71e10..497632f5e 100644 --- a/src/com/android/gallery3d/ui/MenuExecutor.java +++ b/src/com/android/gallery3d/ui/MenuExecutor.java @@ -132,7 +132,6 @@ public class MenuExecutor { private void stopTaskAndDismissDialog() { if (mTask != null) { if (!mWaitOnStop) mTask.cancel(); - mTask.waitDone(); if (mDialog != null && mDialog.isShowing()) mDialog.dismiss(); mDialog = null; mTask = null; @@ -334,15 +333,26 @@ public class MenuExecutor { stopTaskAndDismissDialog(); Activity activity = mActivity; - mDialog = createProgressDialog(activity, title, ids.size()); if (showDialog) { + mDialog = createProgressDialog(activity, title, ids.size()); mDialog.show(); + } else { + mDialog = null; } MediaOperation operation = new MediaOperation(action, ids, listener); mTask = mActivity.getBatchServiceThreadPoolIfAvailable().submit(operation, null); mWaitOnStop = waitOnStop; } + public void startSingleItemAction(int action, Path targetPath) { + ArrayList<Path> ids = new ArrayList<Path>(1); + ids.add(targetPath); + mDialog = null; + MediaOperation operation = new MediaOperation(action, ids, null); + mTask = mActivity.getBatchServiceThreadPoolIfAvailable().submit(operation, null); + mWaitOnStop = false; + } + public static String getMimeType(int type) { switch (type) { case MediaObject.MEDIA_TYPE_IMAGE : |
