OSDN Git Service

Correct behavior when swiping to placeholder item in PhotoPage
authorBobby Georgescu <georgescu@google.com>
Wed, 3 Oct 2012 01:34:08 +0000 (18:34 -0700)
committerAndroid (Google) Code Review <android-gerrit@google.com>
Wed, 3 Oct 2012 07:16:06 +0000 (00:16 -0700)
Bug: 7261641
Change-Id: I54deed0f20a4673cb5470ffc128c73cddc071772

src/com/android/gallery3d/app/PhotoPage.java
src/com/android/gallery3d/ui/PhotoView.java

index 6d05df1..3c64fa3 100644 (file)
@@ -92,6 +92,7 @@ public class PhotoPage extends ActivityState implements
     private static final int MSG_WANT_BARS = 7;
     private static final int MSG_REFRESH_BOTTOM_CONTROLS = 8;
     private static final int MSG_ON_CAMERA_CENTER = 9;
+    private static final int MSG_ON_PICTURE_CENTER = 10;
 
     private static final int HIDE_BARS_TIMEOUT = 3500;
     private static final int UNFREEZE_GLROOT_TIMEOUT = 250;
@@ -311,6 +312,13 @@ public class PhotoPage extends ActivityState implements
                         }
                         break;
                     }
+                    case MSG_ON_PICTURE_CENTER: {
+                        if (mCurrentPhoto != null
+                                && (mCurrentPhoto.getSupportedOperations() & MediaObject.SUPPORT_ACTION) != 0) {
+                            mPhotoView.setFilmMode(true);
+                        }
+                        break;
+                    }
                     default: throw new AssertionError(message.what);
                 }
             }
@@ -417,9 +425,7 @@ public class PhotoPage extends ActivityState implements
                     mCurrentIndex = index;
 
                     if (mAppBridge != null) {
-                        mPhotoView.setWantCameraCenterCallbacks(true);
                         if (mCurrentIndex > 0) {
-                            mHandler.removeMessages(MSG_ON_CAMERA_CENTER);
                             mSkipUpdateCurrentPhoto = false;
                         }
 
@@ -431,6 +437,7 @@ public class PhotoPage extends ActivityState implements
                                     CAMERA_SWITCH_CUTOFF_THRESHOLD_MS;
                             mPhotoView.stopScrolling();
                         } else if (oldIndex == 1 && mCurrentIndex == 0) {
+                            mPhotoView.setWantPictureCenterCallbacks(true);
                             mSkipUpdateCurrentPhoto = true;
                         }
                     }
@@ -483,9 +490,11 @@ public class PhotoPage extends ActivityState implements
         }
     }
 
-    public void onCameraCenter() {
-        mPhotoView.setWantCameraCenterCallbacks(false);
-        mHandler.sendEmptyMessage(MSG_ON_CAMERA_CENTER);
+    public void onPictureCenter(boolean isCamera) {
+        mPhotoView.setWantPictureCenterCallbacks(false);
+        mHandler.removeMessages(MSG_ON_CAMERA_CENTER);
+        mHandler.removeMessages(MSG_ON_PICTURE_CENTER);
+        mHandler.sendEmptyMessage(isCamera ? MSG_ON_CAMERA_CENTER : MSG_ON_PICTURE_CENTER);
     }
 
     public boolean canDisplayBottomControls() {
@@ -598,7 +607,7 @@ public class PhotoPage extends ActivityState implements
         // more clear
         if ((photo.getSupportedOperations() & MediaObject.SUPPORT_ACTION) != 0
                 && !mPhotoView.getFilmMode()) {
-            mPhotoView.setFilmMode(true);
+            mPhotoView.setWantPictureCenterCallbacks(true);
         }
 
         updateMenuOperations();
index 303d302..8c9c6d7 100644 (file)
@@ -125,7 +125,7 @@ public class PhotoView extends GLView {
         public void onUndoDeleteImage();
         public void onCommitDeleteImage();
         public void onFilmModeChanged(boolean enabled);
-        public void onCameraCenter();
+        public void onPictureCenter(boolean isCamera);
     }
 
     // The rules about orientation locking:
@@ -199,7 +199,7 @@ public class PhotoView extends GLView {
 
     private boolean mCancelExtraScalingPending;
     private boolean mFilmMode = false;
-    private boolean mWantCameraCenterCallbacks = false;
+    private boolean mWantPictureCenterCallbacks = false;
     private int mDisplayRotation = 0;
     private int mCompensation = 0;
     private boolean mFullScreenCamera;
@@ -383,8 +383,8 @@ public class PhotoView extends GLView {
         }
     }
 
-    public void setWantCameraCenterCallbacks(boolean wanted) {
-        mWantCameraCenterCallbacks = wanted;
+    public void setWantPictureCenterCallbacks(boolean wanted) {
+        mWantPictureCenterCallbacks = wanted;
     }
 
     ////////////////////////////////////////////////////////////////////////////
@@ -629,10 +629,8 @@ public class PhotoView extends GLView {
             // Holdings except touch-down prevent the transitions.
             if ((mHolding & ~HOLD_TOUCH_DOWN) != 0) return;
 
-            boolean isCameraCenter = mIsCamera && mPositionController.isCenter() && !canUndoLastPicture();
-
-            if (isCameraCenter && mWantCameraCenterCallbacks) {
-                mListener.onCameraCenter();
+            if (mWantPictureCenterCallbacks && mPositionController.isCenter()) {
+                mListener.onPictureCenter(mIsCamera && !canUndoLastPicture());
             }
         }