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 e3122eef4..7f82ae47f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt @@ -237,6 +237,9 @@ class PhotoFragment : ViewPagerFragment() { val height = bitmapOptions.outHeight val bitmapAspectRatio = height / (width).toFloat() + if (context == null) + return 2f + return if (context.portrait && bitmapAspectRatio <= 1f) { ViewPagerActivity.screenHeight / height.toFloat() } else if (!context.portrait && bitmapAspectRatio >= 1f) {