private int mCurrentIndex = 0;
private Handler mHandler;
private boolean mShowBars = true;
+ // The value of canShowBars() last time the bar updates state.
+ private boolean mCanShowBars = false;
private volatile boolean mActionBarAllowed = true;
private GalleryActionBar mActionBar;
private MyMenuVisibilityListener mMenuVisibilityListener;
}
case MSG_LOCK_ORIENTATION: {
mOrientationManager.lockOrientation();
+ updateBars();
break;
}
case MSG_UNLOCK_ORIENTATION: {
mOrientationManager.unlockOrientation();
+ updateBars();
break;
}
case MSG_ON_FULL_SCREEN_CHANGED: {
mActionBar.hide();
WindowManager.LayoutParams params =
((Activity) mActivity).getWindow().getAttributes();
- params.systemUiVisibility = View. SYSTEM_UI_FLAG_LOW_PROFILE;
+ params.systemUiVisibility = View.SYSTEM_UI_FLAG_LOW_PROFILE;
((Activity) mActivity).getWindow().setAttributes(params);
mHandler.removeMessages(MSG_HIDE_BARS);
}
}
}
+ private boolean canShowBars() {
+ // No bars if we are showing camera preview.
+ if (mAppBridge != null && mCurrentIndex == 0) return false;
+ // No bars if it's not allowed.
+ if (!mActionBarAllowed) return false;
+ // No bars if the orientation is locked.
+ if (mOrientationManager.isOrientationLocked()) return false;
+
+ return true;
+ }
+
private void toggleBars() {
+ mCanShowBars = canShowBars();
if (mShowBars) {
hideBars();
- } else if (canShowBars()) {
- showBars();
+ } else {
+ if (mCanShowBars) showBars();
}
}
private void updateBars() {
- if (canShowBars()) {
+ boolean v = canShowBars();
+ if (mCanShowBars == v) return;
+ mCanShowBars = v;
+
+ if (mCanShowBars) {
showBars();
} else {
hideBars();
}
}
- private boolean canShowBars() {
- boolean atCamera = mAppBridge != null && mCurrentIndex == 0;
- return mActionBarAllowed && !atCamera;
- }
-
@Override
public void onOrientationCompensationChanged(int degrees) {
mActivity.getGLRoot().setOrientationCompensation(degrees);
mScreenNail = null;
}
mOrientationManager.removeListener(this);
+
+ // Remove all pending messages.
+ mHandler.removeCallbacksAndMessages(null);
super.onDestroy();
}
boolean isCenter = mPositionController.isCenter();
if (mLoadingState == LOADING_COMPLETE) {
- if (mIsCamera) {
- boolean full = !mFilmMode && isCenter
- && mPositionController.isAtMinimalScale();
- if (full != mFullScreen) {
- mFullScreen = full;
- mListener.onFullScreenChanged(full);
- }
- }
setTileViewPosition(r);
PhotoView.super.render(canvas);
}
renderMessage(canvas, r.centerX(), r.centerY());
+ if (mIsCamera) {
+ boolean full = !mFilmMode && isCenter
+ && mPositionController.isAtMinimalScale();
+ if (full != mFullScreen) {
+ mFullScreen = full;
+ mListener.onFullScreenChanged(full);
+ }
+ }
+
// We want to have the following transitions:
// (1) Move camera preview out of its place: switch to film mode
// (2) Move camera preview into its place: switch to page mode
// setFilmMode(true);
} else if (!mWasCameraCenter && isCameraCenter && mFilmMode) {
setFilmMode(false);
- } else if (isCameraCenter && !mFilmMode) {
- // move into camera, lock
- mListener.lockOrientation(); // Transition A
+ }
+
+ if (isCenter && !mFilmMode) {
+ if (mIsCamera) {
+ // move into camera, lock
+ mListener.lockOrientation(); // Transition A
+ } else {
+ // move out of camera, unlock
+ mListener.unlockOrientation(); // Transition B
+ }
}
mWasCameraCenter = isCameraCenter;
if (offset == 1) {
// move out of camera, unlock
if (!mFilmMode) {
- mListener.unlockOrientation(); // Transition B
// Now the capture animation is done, enable the action bar.
mListener.onActionBarAllowed(true);
}