Fix 5280798: Click on filmstrip during swiping causes crash.

After swiping animation finishes we move to the previous
picture. But if during the animation the user clicks the first
thumbnail on the filmstrip, we will have no previous picture
to move to.

Now disallow clicking on the filmstrip during the swiping animation.

Change-Id: Ie910c346cbf35543fedb6812b04c8e78faab0d0f
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java
index 3e8972f..a3b385a 100644
--- a/src/com/android/gallery3d/app/PhotoPage.java
+++ b/src/com/android/gallery3d/app/PhotoPage.java
@@ -510,9 +510,10 @@
         }
     }
 
-    // Called by FileStripView
-    public void onSlotSelected(int slotIndex) {
-        ((PhotoDataAdapter) mModel).jumpTo(slotIndex);
+    // Called by FileStripView.
+    // Returns false if it cannot jump to the specified index at this time.
+    public boolean onSlotSelected(int slotIndex) {
+        return mPhotoView.jumpTo(slotIndex);
     }
 
     @Override
diff --git a/src/com/android/gallery3d/app/SinglePhotoDataAdapter.java b/src/com/android/gallery3d/app/SinglePhotoDataAdapter.java
index 54183e0..0c54ada 100644
--- a/src/com/android/gallery3d/app/SinglePhotoDataAdapter.java
+++ b/src/com/android/gallery3d/app/SinglePhotoDataAdapter.java
@@ -174,6 +174,10 @@
         throw new UnsupportedOperationException();
     }
 
+    public void jumpTo(int index) {
+        throw new UnsupportedOperationException();
+    }
+
     public MediaItem getCurrentMediaItem() {
         return mItem;
     }
diff --git a/src/com/android/gallery3d/ui/FilmStripView.java b/src/com/android/gallery3d/ui/FilmStripView.java
index c53e1ae..a6be2d1 100644
--- a/src/com/android/gallery3d/ui/FilmStripView.java
+++ b/src/com/android/gallery3d/ui/FilmStripView.java
@@ -34,7 +34,8 @@
     private static final int HIDE_ANIMATION_DURATION = 300;  // 0.3 sec
 
     public interface Listener {
-        void onSlotSelected(int slotIndex);
+        // Returns false if it cannot jump to the specified index at this time.
+        boolean onSlotSelected(int slotIndex);
     }
 
     private int mTopMargin, mMidMargin, mBottomMargin;
@@ -171,8 +172,9 @@
     // Called by AlbumView
     @Override
     public void onSingleTapUp(int slotIndex) {
-        mAlbumView.setFocusIndex(slotIndex);
-        mListener.onSlotSelected(slotIndex);
+        if (mListener.onSlotSelected(slotIndex)) {
+            mAlbumView.setFocusIndex(slotIndex);
+        }
     }
 
     // Called by AlbumView
diff --git a/src/com/android/gallery3d/ui/PhotoView.java b/src/com/android/gallery3d/ui/PhotoView.java
index aba572b..feb0ee7 100644
--- a/src/com/android/gallery3d/ui/PhotoView.java
+++ b/src/com/android/gallery3d/ui/PhotoView.java
@@ -985,6 +985,12 @@
         }
     }
 
+    public boolean jumpTo(int index) {
+        if (mTransitionMode != TRANS_NONE) return false;
+        mModel.jumpTo(index);
+        return true;
+    }
+
     public void notifyOnNewImage() {
         mPositionController.setImageSize(0, 0);
     }
@@ -1065,6 +1071,7 @@
     public static interface Model extends TileImageView.Model {
         public void next();
         public void previous();
+        public void jumpTo(int index);
         public int getImageRotation();
 
         // Return null if the specified image is unavailable.