Unlock orientation only when action bar is needed.

Bug: 6482079
Change-Id: I75d96ca7957f80e9c52f35edf74127f82f194f63
diff --git a/src/com/android/gallery3d/ui/PositionController.java b/src/com/android/gallery3d/ui/PositionController.java
index bb2b83e..d085c4d 100644
--- a/src/com/android/gallery3d/ui/PositionController.java
+++ b/src/com/android/gallery3d/ui/PositionController.java
@@ -209,8 +209,13 @@
         }
 
         updateScaleAndGapLimit();
-        startOpeningAnimationIfNeeded();
-        snapAndRedraw();
+
+        // If we have the opening animation, do it. Otherwise go directly to the
+        // right position.
+        if (!startOpeningAnimationIfNeeded()) {
+            snapAndRedraw();
+            skipAnimation();
+        }
     }
 
     public void setConstrainedFrame(Rect f) {
@@ -280,10 +285,10 @@
         return true;
     }
 
-    private void startOpeningAnimationIfNeeded() {
-        if (mOpenAnimationRect == null) return;
+    private boolean startOpeningAnimationIfNeeded() {
+        if (mOpenAnimationRect == null) return false;
         Box b = mBoxes.get(0);
-        if (b.mUseViewSize) return;
+        if (b.mUseViewSize) return false;
 
         // Start animation from the saved rectangle if we have one.
         Rect r = mOpenAnimationRect;
@@ -303,6 +308,8 @@
             g.mCurrentGap = mViewW;
             g.doAnimation(g.mDefaultSize, ANIM_KIND_OPENING);
         }
+
+        return true;
     }
 
     public void setFilmMode(boolean enabled) {