OSDN Git Service

Fix b/3462852 [UI] When linking from Camera preview - App icon with 'Up' arrow should...
authorRay Chen <raychen@google.com>
Tue, 3 Apr 2012 02:42:55 +0000 (10:42 +0800)
committerRay Chen <raychen@google.com>
Tue, 3 Apr 2012 09:39:44 +0000 (17:39 +0800)
Change startActivity to switchState because not every MediaObject implements "getContentUri" which may
cause runtime exception.

Change-Id: I88be6e9e8f15ad17f4c7347b6dfc200c7682ce01

src/com/android/gallery3d/app/AlbumPage.java
src/com/android/gallery3d/app/PhotoPage.java

index 43936e7..e0b7384 100644 (file)
@@ -462,12 +462,9 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
                 if (mActivity.getStateManager().getStateCount() > 1) {
                     onBackPressed();
                 } else if (mParentMediaSetString != null) {
-                    Activity a = (Activity) mActivity;
-                    int flags = Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK;
-                    Intent intent = new Intent()
-                            .setClass(a, Gallery.class)
-                            .setFlags(flags);
-                    a.startActivity(intent);
+                    Bundle data = new Bundle(getData());
+                    data.putString(AlbumSetPage.KEY_MEDIA_PATH, mParentMediaSetString);
+                    mActivity.getStateManager().switchState(this, AlbumSetPage.class, data);
                 }
                 return true;
             }
index e16ac8a..32aba93 100644 (file)
@@ -425,15 +425,13 @@ public class PhotoPage extends ActivityState
                     if (mActivity.getStateManager().getStateCount() > 1) {
                         onBackPressed();
                     } else {
-                        Activity a = (Activity) mActivity;
-                        Uri uri = mActivity.getDataManager().getContentUri(
-                                Path.fromString(mSetPathString));
-                        Intent intent = new Intent(Intent.ACTION_VIEW)
-                                .setClass(a, Gallery.class)
-                                .setDataAndType(uri, ContentResolver.CURSOR_DIR_BASE_TYPE)
-                                .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
-                                        Intent.FLAG_ACTIVITY_NEW_TASK);
-                        a.startActivity(intent);
+                        // We're in view mode so set up the stacks on our own.
+                        Bundle data = new Bundle(getData());
+                        data.putString(AlbumPage.KEY_MEDIA_PATH, mSetPathString);
+                        data.putString(AlbumPage.KEY_PARENT_MEDIA_PATH,
+                                mActivity.getDataManager().getTopSetPath(
+                                        DataManager.INCLUDE_ALL));
+                        mActivity.getStateManager().switchState(this, AlbumPage.class, data);
                     }
                 }
                 return true;