OSDN Git Service

Don't do capture animation if we don't have Camera ScreenNail.
authorChih-Chung Chang <chihchung@google.com>
Wed, 25 Apr 2012 03:50:08 +0000 (11:50 +0800)
committerChih-Chung Chang <chihchung@google.com>
Wed, 25 Apr 2012 04:03:03 +0000 (12:03 +0800)
Also make "Back" jump to first picture instead of the previous one.

Bug: 6388263

Change-Id: Idf78363cf3952bf66c6b0688e79d99c01956cd07

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

index 096e781..d0fde24 100644 (file)
@@ -340,6 +340,11 @@ public class PhotoDataAdapter implements PhotoPage.Model {
     }
 
     @Override
+    public void moveToFirst() {
+        updateCurrentIndex(0);
+    }
+
+    @Override
     public ScreenNail getScreenNail(int offset) {
         return getImage(mCurrentIndex + offset);
     }
index 6617ce6..6e5343b 100644 (file)
@@ -403,7 +403,8 @@ public class PhotoPage extends ActivityState
     protected void onBackPressed() {
         if (mShowDetails) {
             hideDetails();
-        } else if (!switchWithCaptureAnimation(-1)) {
+        } else if (mScreenNail == null
+                || !switchWithCaptureAnimation(-1)) {
             super.onBackPressed();
         }
     }
index 47f6acb..d0e8161 100644 (file)
@@ -164,6 +164,11 @@ public class SinglePhotoDataAdapter extends TileImageViewAdapter
     }
 
     @Override
+    public void moveToFirst() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
     public void getImageSize(int offset, PhotoView.Size size) {
         if (offset == 0) {
             size.width = mItem.getWidth();
index 66941be..5487e3e 100644 (file)
@@ -52,6 +52,7 @@ public class PhotoView extends GLView {
     public interface Model extends TileImageView.Model {
         public void next();
         public void previous();
+        public void moveToFirst();
 
         // Returns the size for the specified picture. If the size information is
         // not avaiable, width = height = 0.
@@ -935,6 +936,10 @@ public class PhotoView extends GLView {
         mModel.previous();
     }
 
+    private void switchToFirstImage() {
+        mModel.moveToFirst();
+    }
+
     ////////////////////////////////////////////////////////////////////////////
     //  Opening Animation
     ////////////////////////////////////////////////////////////////////////////
@@ -958,7 +963,6 @@ public class PhotoView extends GLView {
     }
 
     private boolean switchWithCaptureAnimationLocked(int offset) {
-        if (mFilmMode) return false;
         if (mHolding != 0) return true;
         if (offset == 1) {
             if (mNextBound <= 0) return false;
@@ -966,7 +970,7 @@ public class PhotoView extends GLView {
             mPositionController.startCaptureAnimationSlide(-1);
         } else if (offset == -1) {
             if (mPrevBound >= 0) return false;
-            switchToPrevImage();
+            switchToFirstImage();
             mPositionController.startCaptureAnimationSlide(1);
         } else {
             return false;