avoid decoding fullscreen images twice
This commit is contained in:
parent
1b88318f46
commit
6ebfb82e39
1 changed files with 2 additions and 7 deletions
|
@ -236,7 +236,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)
|
||||||
setDoubleTapZoomScale(getDoubleTapZoomScale())
|
setDoubleTapZoomScale(getDoubleTapZoomScale(sWidth, sHeight))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTileLoadError(e: Exception?) {
|
override fun onTileLoadError(e: Exception?) {
|
||||||
|
@ -259,12 +259,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getDoubleTapZoomScale(): Float {
|
private fun getDoubleTapZoomScale(width: Int, height: Int): Float {
|
||||||
val bitmapOptions = BitmapFactory.Options()
|
|
||||||
bitmapOptions.inJustDecodeBounds = true
|
|
||||||
BitmapFactory.decodeFile(medium.path, bitmapOptions)
|
|
||||||
val width = bitmapOptions.outWidth
|
|
||||||
val height = bitmapOptions.outHeight
|
|
||||||
val bitmapAspectRatio = height / (width).toFloat()
|
val bitmapAspectRatio = height / (width).toFloat()
|
||||||
|
|
||||||
return if (context == null) {
|
return if (context == null) {
|
||||||
|
|
Loading…
Reference in a new issue