mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 13:08:00 +01:00
fixed some fullscreen view rotation related glitches
This commit is contained in:
parent
09726c0cd4
commit
58fe410e85
2 changed files with 17 additions and 9 deletions
|
@ -142,6 +142,12 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
currentMedium.isFavorite = mFavoritePaths.contains(currentMedium.path)
|
currentMedium.isFavorite = mFavoritePaths.contains(currentMedium.path)
|
||||||
val visibleBottomActions = if (config.bottomActions) config.visibleBottomActions else 0
|
val visibleBottomActions = if (config.bottomActions) config.visibleBottomActions else 0
|
||||||
|
|
||||||
|
getCurrentFragment()?.let {
|
||||||
|
(it as? PhotoFragment)?.apply {
|
||||||
|
mRotationDegrees = mCurrentRotationDegrees
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
menu.apply {
|
menu.apply {
|
||||||
findItem(R.id.menu_show_on_map).isVisible = visibleBottomActions and BOTTOM_ACTION_SHOW_ON_MAP == 0
|
findItem(R.id.menu_show_on_map).isVisible = visibleBottomActions and BOTTOM_ACTION_SHOW_ON_MAP == 0
|
||||||
findItem(R.id.menu_slideshow).isVisible = visibleBottomActions and BOTTOM_ACTION_SLIDESHOW == 0
|
findItem(R.id.menu_slideshow).isVisible = visibleBottomActions and BOTTOM_ACTION_SLIDESHOW == 0
|
||||||
|
|
|
@ -62,6 +62,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
"google nexus 5x"
|
"google nexus 5x"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var mCurrentRotationDegrees = 0
|
||||||
private var mIsFragmentVisible = false
|
private var mIsFragmentVisible = false
|
||||||
private var mIsFullscreen = false
|
private var mIsFullscreen = false
|
||||||
private var mWasInit = false
|
private var mWasInit = false
|
||||||
|
@ -69,7 +70,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
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 mImageOrientation = -1
|
private var mImageOrientation = -1
|
||||||
private var mOriginalSubsamplingScale = 0f
|
private var mOriginalSubsamplingScale = 0f
|
||||||
private var mIoadZoomableViewHandler = Handler()
|
private var mLoadZoomableViewHandler = Handler()
|
||||||
private var mScreenWidth = 0
|
private var mScreenWidth = 0
|
||||||
private var mScreenHeight = 0
|
private var mScreenHeight = 0
|
||||||
private var mCurrentGestureViewZoom = 1f
|
private var mCurrentGestureViewZoom = 1f
|
||||||
|
@ -222,7 +223,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
if (activity?.isDestroyed == false) {
|
if (activity?.isDestroyed == false) {
|
||||||
mView.subsampling_view.recycle()
|
mView.subsampling_view.recycle()
|
||||||
}
|
}
|
||||||
mIoadZoomableViewHandler.removeCallbacksAndMessages(null)
|
mLoadZoomableViewHandler.removeCallbacksAndMessages(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||||
|
@ -344,7 +345,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
.into(mView.gestures_view)
|
.into(mView.gestures_view)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadBitmap(degrees: Int = 0) {
|
private fun loadBitmap(degrees: Int = mCurrentRotationDegrees) {
|
||||||
val options = RequestOptions()
|
val options = RequestOptions()
|
||||||
.signature(mMedium.path.getFileSignature())
|
.signature(mMedium.path.getFileSignature())
|
||||||
.format(DecodeFormat.PREFER_ARGB_8888)
|
.format(DecodeFormat.PREFER_ARGB_8888)
|
||||||
|
@ -368,7 +369,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResourceReady(resource: Drawable?, model: Any?, target: Target<Drawable>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
|
override fun onResourceReady(resource: Drawable?, model: Any?, target: Target<Drawable>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
|
||||||
if (mIsFragmentVisible) {
|
if (mIsFragmentVisible && degrees == 0) {
|
||||||
scheduleZoomableView()
|
scheduleZoomableView()
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
@ -415,9 +416,9 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun scheduleZoomableView() {
|
private fun scheduleZoomableView() {
|
||||||
mIoadZoomableViewHandler.removeCallbacksAndMessages(null)
|
mLoadZoomableViewHandler.removeCallbacksAndMessages(null)
|
||||||
mIoadZoomableViewHandler.postDelayed({
|
mLoadZoomableViewHandler.postDelayed({
|
||||||
if (mIsFragmentVisible && context?.config?.allowZoomingImages == true && mMedium.isImage() && !mIsSubsamplingVisible) {
|
if (mIsFragmentVisible && context?.config?.allowZoomingImages == true && mMedium.isImage() && !mIsSubsamplingVisible && mCurrentRotationDegrees == 0) {
|
||||||
addZoomableView()
|
addZoomableView()
|
||||||
}
|
}
|
||||||
}, ZOOMABLE_VIEW_LOAD_DELAY)
|
}, ZOOMABLE_VIEW_LOAD_DELAY)
|
||||||
|
@ -542,7 +543,8 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun rotateImageViewBy(degrees: Int) {
|
fun rotateImageViewBy(degrees: Int) {
|
||||||
mIoadZoomableViewHandler.removeCallbacksAndMessages(null)
|
mCurrentRotationDegrees = degrees
|
||||||
|
mLoadZoomableViewHandler.removeCallbacksAndMessages(null)
|
||||||
mView.subsampling_view.beGone()
|
mView.subsampling_view.beGone()
|
||||||
mIsSubsamplingVisible = false
|
mIsSubsamplingVisible = false
|
||||||
loadBitmap(degrees)
|
loadBitmap(degrees)
|
||||||
|
@ -574,7 +576,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
mIsSubsamplingVisible = false
|
mIsSubsamplingVisible = false
|
||||||
mView.subsampling_view.recycle()
|
mView.subsampling_view.recycle()
|
||||||
mView.subsampling_view.beGone()
|
mView.subsampling_view.beGone()
|
||||||
mIoadZoomableViewHandler.removeCallbacksAndMessages(null)
|
mLoadZoomableViewHandler.removeCallbacksAndMessages(null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue