mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-30 08:18:00 +01:00
improve some double-tap zoom handling
This commit is contained in:
parent
bdc61380a5
commit
a3c680fc73
1 changed files with 10 additions and 8 deletions
|
@ -37,6 +37,7 @@ import java.io.File
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
|
|
||||||
class PhotoFragment : ViewPagerFragment() {
|
class PhotoFragment : ViewPagerFragment() {
|
||||||
|
private var DEFAULT_DOUBLE_TAP_ZOOM = 5f
|
||||||
private var isFragmentVisible = false
|
private var isFragmentVisible = false
|
||||||
private var isFullscreen = false
|
private var isFullscreen = false
|
||||||
private var wasInit = false
|
private var wasInit = false
|
||||||
|
@ -234,8 +235,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
|
|
||||||
override fun onReady() {
|
override fun onReady() {
|
||||||
background = ColorDrawable(if (context.config.darkBackground) Color.BLACK else context.config.backgroundColor)
|
background = ColorDrawable(if (context.config.darkBackground) Color.BLACK else context.config.backgroundColor)
|
||||||
val zoomScale = if (ViewPagerActivity.wasDecodedByGlide) 1f else getDoubleTapZoomScale()
|
setDoubleTapZoomScale(getDoubleTapZoomScale())
|
||||||
setDoubleTapZoomScale(zoomScale)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTileLoadError(e: Exception?) {
|
override fun onTileLoadError(e: Exception?) {
|
||||||
|
@ -266,11 +266,13 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
val height = bitmapOptions.outHeight
|
val height = bitmapOptions.outHeight
|
||||||
val bitmapAspectRatio = height / (width).toFloat()
|
val bitmapAspectRatio = height / (width).toFloat()
|
||||||
|
|
||||||
if (context == null) {
|
return if (context == null) {
|
||||||
return 2f
|
DEFAULT_DOUBLE_TAP_ZOOM
|
||||||
}
|
} else if (ViewPagerActivity.screenHeight / ViewPagerActivity.screenWidth.toFloat() == bitmapAspectRatio) {
|
||||||
|
DEFAULT_DOUBLE_TAP_ZOOM
|
||||||
return if (context!!.portrait && bitmapAspectRatio <= 1f) {
|
} else if (ViewPagerActivity.wasDecodedByGlide) {
|
||||||
|
1f
|
||||||
|
} else if (context!!.portrait && bitmapAspectRatio <= 1f) {
|
||||||
ViewPagerActivity.screenHeight / height.toFloat()
|
ViewPagerActivity.screenHeight / height.toFloat()
|
||||||
} else if (context!!.portrait && bitmapAspectRatio > 1f) {
|
} else if (context!!.portrait && bitmapAspectRatio > 1f) {
|
||||||
ViewPagerActivity.screenHeight / width.toFloat()
|
ViewPagerActivity.screenHeight / width.toFloat()
|
||||||
|
@ -279,7 +281,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
} else if (!context!!.portrait && bitmapAspectRatio < 1f) {
|
} else if (!context!!.portrait && bitmapAspectRatio < 1f) {
|
||||||
ViewPagerActivity.screenWidth / height.toFloat()
|
ViewPagerActivity.screenWidth / height.toFloat()
|
||||||
} else {
|
} else {
|
||||||
2f
|
DEFAULT_DOUBLE_TAP_ZOOM
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue