summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d
diff options
context:
space:
mode:
authorRay Chen <raychen@google.com>2011-09-02 00:28:36 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-09-02 00:28:36 -0700
commit28eb58218cfd50d07e8e333b4b7fd000037c6749 (patch)
treeff2a3702edbbdd1518949fc5f18e51b72076660e /src/com/android/gallery3d
parent83d4691e8dae4e6fe9090f71283b96ee2b911236 (diff)
parentce811df0fc04278e440aed176c0f2ab4a64f22f5 (diff)
downloadandroid_packages_apps_Snap-28eb58218cfd50d07e8e333b4b7fd000037c6749.tar.gz
android_packages_apps_Snap-28eb58218cfd50d07e8e333b4b7fd000037c6749.tar.bz2
android_packages_apps_Snap-28eb58218cfd50d07e8e333b4b7fd000037c6749.zip
Merge "Fix a few monkey issues: 5157713 and 5157712 Add debugging message for 5192628."
Diffstat (limited to 'src/com/android/gallery3d')
-rw-r--r--src/com/android/gallery3d/ui/MenuExecutor.java95
-rw-r--r--src/com/android/gallery3d/ui/TileImageView.java2
2 files changed, 28 insertions, 69 deletions
diff --git a/src/com/android/gallery3d/ui/MenuExecutor.java b/src/com/android/gallery3d/ui/MenuExecutor.java
index 637c01ec4..54c4e7693 100644
--- a/src/com/android/gallery3d/ui/MenuExecutor.java
+++ b/src/com/android/gallery3d/ui/MenuExecutor.java
@@ -90,11 +90,7 @@ public class MenuExecutor {
public void handleMessage(Message message) {
switch (message.what) {
case MSG_TASK_COMPLETE: {
- if (mDialog != null) {
- mDialog.dismiss();
- mDialog = null;
- mTask = null;
- }
+ stopTaskAndDismissDialog();
if (message.obj != null) {
ProgressListener listener = (ProgressListener) message.obj;
listener.onProgressComplete(message.arg1);
@@ -119,7 +115,7 @@ public class MenuExecutor {
};
}
- public void pause() {
+ private void stopTaskAndDismissDialog() {
if (mTask != null) {
mTask.cancel();
mTask.waitDone();
@@ -129,6 +125,10 @@ public class MenuExecutor {
}
}
+ public void pause() {
+ stopTaskAndDismissDialog();
+ }
+
private void onProgressUpdate(int index, ProgressListener listener) {
mHandler.sendMessage(
mHandler.obtainMessage(MSG_TASK_UPDATE, index, 0, listener));
@@ -138,55 +138,6 @@ public class MenuExecutor {
mHandler.sendMessage(mHandler.obtainMessage(MSG_TASK_COMPLETE, result, 0, listener));
}
- private int getShareType(SelectionManager selectionManager) {
- ArrayList<Path> items = selectionManager.getSelected(false);
- int type = 0;
- DataManager dataManager = mActivity.getDataManager();
- for (Path id : items) {
- type |= dataManager.getMediaType(id);
- }
- return type;
- }
-
- private void onShareItemClicked(final SelectionManager selectionManager,
- final String mimeType, final ComponentName component) {
- Utils.assertTrue(mDialog == null);
- final ArrayList<Path> items = selectionManager.getSelected(true);
- mDialog = showProgressDialog((Activity) mActivity,
- R.string.loading_image, items.size());
-
- mTask = mActivity.getThreadPool().submit(new Job<Void>() {
- @Override
- public Void run(JobContext jc) {
- DataManager manager = mActivity.getDataManager();
- ArrayList<Uri> uris = new ArrayList<Uri>(items.size());
- int index = 0;
- for (Path path : items) {
- if ((manager.getSupportedOperations(path)
- & MediaObject.SUPPORT_SHARE) != 0) {
- uris.add(manager.getContentUri(path));
- }
- onProgressUpdate(++index, null);
- }
- if (jc.isCancelled()) return null;
- Intent intent = new Intent()
- .setComponent(component).setType(mimeType);
- if (uris.isEmpty()) {
- return null;
- } else if (uris.size() == 1) {
- intent.setAction(Intent.ACTION_SEND);
- intent.putExtra(Intent.EXTRA_STREAM, uris.get(0));
- } else {
- intent.setAction(Intent.ACTION_SEND_MULTIPLE);
- intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
- }
- onProgressComplete(EXECUTION_RESULT_SUCCESS, null);
- mHandler.sendMessage(mHandler.obtainMessage(MSG_DO_SHARE, intent));
- return null;
- }
- }, null);
- }
-
private static void setMenuItemVisibility(
Menu menu, int id, boolean visibility) {
MenuItem item = menu.findItem(id);
@@ -283,7 +234,7 @@ public class MenuExecutor {
public void startAction(int action, int title, ProgressListener listener) {
ArrayList<Path> ids = mSelectionManager.getSelected(false);
- Utils.assertTrue(mDialog == null);
+ stopTaskAndDismissDialog();
Activity activity = (Activity) mActivity;
mDialog = showProgressDialog(activity, title, ids.size());
@@ -304,6 +255,9 @@ public class MenuExecutor {
private boolean execute(
DataManager manager, JobContext jc, int cmd, Path path) {
boolean result = true;
+ Log.v(TAG, "Execute cmd: " + cmd + " for " + path);
+ long startTime = System.currentTimeMillis();
+
switch (cmd) {
case R.id.action_confirm_delete:
manager.delete(path);
@@ -359,6 +313,8 @@ public class MenuExecutor {
default:
throw new AssertionError();
}
+ Log.v(TAG, "It takes " + (System.currentTimeMillis() - startTime) +
+ " ms to execute cmd for " + path);
return result;
}
@@ -377,20 +333,23 @@ public class MenuExecutor {
int index = 0;
DataManager manager = mActivity.getDataManager();
int result = EXECUTION_RESULT_SUCCESS;
- for (Path id : mItems) {
- if (jc.isCancelled()) {
- result = EXECUTION_RESULT_CANCEL;
- break;
- }
- try {
- if (!execute(manager, jc, mOperation, id)) result = EXECUTION_RESULT_FAIL;
- } catch (Throwable th) {
- Log.e(TAG, "failed to execute operation " + mOperation
- + " for " + id, th);
+ try {
+ for (Path id : mItems) {
+ if (jc.isCancelled()) {
+ result = EXECUTION_RESULT_CANCEL;
+ break;
+ }
+ if (!execute(manager, jc, mOperation, id)) {
+ result = EXECUTION_RESULT_FAIL;
+ }
+ onProgressUpdate(index++, mListener);
}
- onProgressUpdate(index++, mListener);
+ } catch (Throwable th) {
+ Log.e(TAG, "failed to execute operation " + mOperation
+ + " : " + th);
+ } finally {
+ onProgressComplete(result, mListener);
}
- onProgressComplete(result, mListener);
return null;
}
}
diff --git a/src/com/android/gallery3d/ui/TileImageView.java b/src/com/android/gallery3d/ui/TileImageView.java
index 2cecedd33..b445c843b 100644
--- a/src/com/android/gallery3d/ui/TileImageView.java
+++ b/src/com/android/gallery3d/ui/TileImageView.java
@@ -351,7 +351,7 @@ public class TileImageView extends GLView {
if (mIsTextureFreed) {
layoutTiles(mCenterX, mCenterY, mScale, mRotation);
mIsTextureFreed = false;
- updateBackupTexture(mModel.getBackupImage());
+ updateBackupTexture(mModel != null ? mModel.getBackupImage() : null);
}
}