From 6ebfb82e39c4c03938594031006e7c85cfbee81e Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 23 Nov 2017 09:58:12 +0100 Subject: [PATCH] avoid decoding fullscreen images twice --- .../simplemobiletools/gallery/fragments/PhotoFragment.kt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt index 63cd99e2a..bffd0b422 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt @@ -236,7 +236,7 @@ class PhotoFragment : ViewPagerFragment() { override fun onReady() { background = ColorDrawable(if (context.config.darkBackground) Color.BLACK else context.config.backgroundColor) - setDoubleTapZoomScale(getDoubleTapZoomScale()) + setDoubleTapZoomScale(getDoubleTapZoomScale(sWidth, sHeight)) } override fun onTileLoadError(e: Exception?) { @@ -259,12 +259,7 @@ class PhotoFragment : ViewPagerFragment() { } } - private fun getDoubleTapZoomScale(): Float { - val bitmapOptions = BitmapFactory.Options() - bitmapOptions.inJustDecodeBounds = true - BitmapFactory.decodeFile(medium.path, bitmapOptions) - val width = bitmapOptions.outWidth - val height = bitmapOptions.outHeight + private fun getDoubleTapZoomScale(width: Int, height: Int): Float { val bitmapAspectRatio = height / (width).toFloat() return if (context == null) {