Fix orientation locking issues when going back to Camera

Bug: 7287039
Change-Id: Ib993266706b24269fd759f1ded1b6a85c2c5c7ba
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java
index cd8b802..cfc9aa0 100644
--- a/src/com/android/gallery3d/app/PhotoPage.java
+++ b/src/com/android/gallery3d/app/PhotoPage.java
@@ -295,19 +295,19 @@
                     }
                     case MSG_ON_CAMERA_CENTER: {
                         mSkipUpdateCurrentPhoto = false;
-                        boolean updateNeeded = false;
+                        boolean stayedOnCamera = false;
                         if (!mPhotoView.getFilmMode()) {
-                            lockOrientation();
-                            updateNeeded = true;
+                            stayedOnCamera = true;
                         } else if (SystemClock.uptimeMillis() < mCameraSwitchCutoff &&
                                 mMediaSet.getMediaItemCount() > 1) {
                             mPhotoView.switchToImage(1);
                         } else {
                             mPhotoView.setFilmMode(false);
-                            updateNeeded = true;
+                            stayedOnCamera = true;
                         }
 
-                        if (updateNeeded) {
+                        if (stayedOnCamera) {
+                            lockOrientation();
                             updateBars();
                             updateCurrentPhoto(mModel.getMediaItem(0));
                         }
@@ -444,7 +444,7 @@
                             mCameraSwitchCutoff = SystemClock.uptimeMillis() +
                                     CAMERA_SWITCH_CUTOFF_THRESHOLD_MS;
                             mPhotoView.stopScrolling();
-                        } else if (oldIndex == 1 && mCurrentIndex == 0) {
+                        } else if (oldIndex >= 1 && mCurrentIndex == 0) {
                             mPhotoView.setWantPictureCenterCallbacks(true);
                             mSkipUpdateCurrentPhoto = true;
                         }