reset fullscreen image only on device rotation

This commit is contained in:
tibbi 2022-06-26 20:15:48 +02:00
parent 718836459b
commit c8b66cd439
2 changed files with 9 additions and 2 deletions

View file

@ -90,7 +90,7 @@ dependencies {
implementation 'info.androidhive:imagefilters:1.0.7' implementation 'info.androidhive:imagefilters:1.0.7'
implementation 'com.caverock:androidsvg-aar:1.4' implementation 'com.caverock:androidsvg-aar:1.4'
implementation 'com.github.tibbi:gestureviews:a8e8fa8d27' implementation 'com.github.tibbi:gestureviews:a8e8fa8d27'
implementation 'com.github.tibbi:subsampling-scale-image-view:05b02e26b7' implementation 'com.github.tibbi:subsampling-scale-image-view:b51482b3fa'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'com.github.penfeizhou.android.animation:awebp:2.17.0' implementation 'com.github.penfeizhou.android.animation:awebp:2.17.0'
implementation 'com.github.penfeizhou.android.animation:apng:2.17.0' implementation 'com.github.penfeizhou.android.animation:apng:2.17.0'

View file

@ -83,6 +83,7 @@ class PhotoFragment : ViewPagerFragment() {
private var mWasInit = false private var mWasInit = false
private var mIsPanorama = false private var mIsPanorama = false
private var mIsSubsamplingVisible = false // checking view.visibility is unreliable, use an extra variable for it private var mIsSubsamplingVisible = false // checking view.visibility is unreliable, use an extra variable for it
private var mShouldResetImage = false
private var mCurrentPortraitPhotoPath = "" private var mCurrentPortraitPhotoPath = ""
private var mOriginalPath = "" private var mOriginalPath = ""
private var mImageOrientation = -1 private var mImageOrientation = -1
@ -228,11 +229,12 @@ class PhotoFragment : ViewPagerFragment() {
loadImage() loadImage()
} else if (mMedium.isGIF()) { } else if (mMedium.isGIF()) {
loadGif() loadGif()
} else if (mIsSubsamplingVisible) { } else if (mIsSubsamplingVisible && mShouldResetImage) {
mView.subsampling_view.onGlobalLayout { mView.subsampling_view.onGlobalLayout {
mView.subsampling_view.resetView() mView.subsampling_view.resetView()
} }
} }
mShouldResetImage = false
} }
val allowPhotoGestures = config.allowPhotoGestures val allowPhotoGestures = config.allowPhotoGestures
@ -294,6 +296,7 @@ class PhotoFragment : ViewPagerFragment() {
measureScreen() measureScreen()
initExtendedDetails() initExtendedDetails()
updateInstantSwitchWidths() updateInstantSwitchWidths()
mShouldResetImage = true
} }
override fun setMenuVisibility(menuVisible: Boolean) { override fun setMenuVisibility(menuVisible: Boolean) {
@ -708,6 +711,10 @@ class PhotoFragment : ViewPagerFragment() {
loadBitmap(false) loadBitmap(false)
activity?.invalidateOptionsMenu() activity?.invalidateOptionsMenu()
} }
override fun onUpEvent() {
mShouldResetImage = false
}
} }
} }
} }