mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 14:37:59 +01:00
add a helper variable for checking subsampling view visibility
This commit is contained in:
parent
1bae7ef7a6
commit
1110c80b66
1 changed files with 8 additions and 3 deletions
|
@ -56,6 +56,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
private var isFullscreen = false
|
private var isFullscreen = false
|
||||||
private var wasInit = false
|
private var wasInit = false
|
||||||
private var isPanorama = false
|
private var isPanorama = false
|
||||||
|
private var isSubsamplingVisible = false // checking view.visibility is unreliable, use an extra variable for it
|
||||||
private var imageOrientation = -1
|
private var imageOrientation = -1
|
||||||
private var gifDrawable: GifDrawable? = null
|
private var gifDrawable: GifDrawable? = null
|
||||||
private var loadZoomableViewHandler = Handler()
|
private var loadZoomableViewHandler = Handler()
|
||||||
|
@ -209,6 +210,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
if (isVisible) {
|
if (isVisible) {
|
||||||
scheduleZoomableView()
|
scheduleZoomableView()
|
||||||
} else {
|
} else {
|
||||||
|
isSubsamplingVisible = false
|
||||||
view.subsampling_view.recycle()
|
view.subsampling_view.recycle()
|
||||||
view.subsampling_view.beGone()
|
view.subsampling_view.beGone()
|
||||||
loadZoomableViewHandler.removeCallbacksAndMessages(null)
|
loadZoomableViewHandler.removeCallbacksAndMessages(null)
|
||||||
|
@ -346,7 +348,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
private fun scheduleZoomableView() {
|
private fun scheduleZoomableView() {
|
||||||
loadZoomableViewHandler.removeCallbacksAndMessages(null)
|
loadZoomableViewHandler.removeCallbacksAndMessages(null)
|
||||||
loadZoomableViewHandler.postDelayed({
|
loadZoomableViewHandler.postDelayed({
|
||||||
if (isFragmentVisible && context?.config?.allowZoomingImages == true && medium.isImage() && view.subsampling_view.isGone()) {
|
if (isFragmentVisible && context?.config?.allowZoomingImages == true && medium.isImage() && !isSubsamplingVisible) {
|
||||||
addZoomableView()
|
addZoomableView()
|
||||||
}
|
}
|
||||||
}, ZOOMABLE_VIEW_LOAD_DELAY)
|
}, ZOOMABLE_VIEW_LOAD_DELAY)
|
||||||
|
@ -354,17 +356,19 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
|
|
||||||
private fun addZoomableView() {
|
private fun addZoomableView() {
|
||||||
val rotation = degreesForRotation(imageOrientation)
|
val rotation = degreesForRotation(imageOrientation)
|
||||||
|
val path = getPathToLoad(medium)
|
||||||
|
isSubsamplingVisible = true
|
||||||
|
|
||||||
view.subsampling_view.apply {
|
view.subsampling_view.apply {
|
||||||
setMinimumTileDpi(getMinTileDpi())
|
setMinimumTileDpi(getMinTileDpi())
|
||||||
background = ColorDrawable(Color.TRANSPARENT)
|
background = ColorDrawable(Color.TRANSPARENT)
|
||||||
setBitmapDecoderFactory { PicassoDecoder(medium.path, Picasso.get(), rotation) }
|
setBitmapDecoderFactory { PicassoDecoder(path, Picasso.get(), rotation) }
|
||||||
setRegionDecoderFactory { PicassoRegionDecoder() }
|
setRegionDecoderFactory { PicassoRegionDecoder() }
|
||||||
maxScale = 10f
|
maxScale = 10f
|
||||||
beVisible()
|
beVisible()
|
||||||
isQuickScaleEnabled = context.config.oneFingerZoom
|
isQuickScaleEnabled = context.config.oneFingerZoom
|
||||||
setResetScaleOnSizeChange(context.config.screenRotation != ROTATE_BY_ASPECT_RATIO)
|
setResetScaleOnSizeChange(context.config.screenRotation != ROTATE_BY_ASPECT_RATIO)
|
||||||
setImage(ImageSource.uri(getPathToLoad(medium)))
|
setImage(ImageSource.uri(path))
|
||||||
orientation = rotation
|
orientation = rotation
|
||||||
setEagerLoadingEnabled(false)
|
setEagerLoadingEnabled(false)
|
||||||
setOnImageEventListener(object : SubsamplingScaleImageView.OnImageEventListener {
|
setOnImageEventListener(object : SubsamplingScaleImageView.OnImageEventListener {
|
||||||
|
@ -466,6 +470,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
fun rotateImageViewBy(degrees: Int) {
|
fun rotateImageViewBy(degrees: Int) {
|
||||||
loadZoomableViewHandler.removeCallbacksAndMessages(null)
|
loadZoomableViewHandler.removeCallbacksAndMessages(null)
|
||||||
view.subsampling_view.beGone()
|
view.subsampling_view.beGone()
|
||||||
|
isSubsamplingVisible = false
|
||||||
loadBitmap(degrees)
|
loadBitmap(degrees)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue