From f4ddc129112246e229d27c3da1fb8560ebc1af22 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 31 May 2017 23:04:56 +0200 Subject: [PATCH] add another check at getting current media of viewpager --- .../simplemobiletools/gallery/activities/ViewPagerActivity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index 24aa738e7..652ac5b8d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -498,7 +498,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } private fun getCurrentMedium(): Medium? { - return if (mMedia.isEmpty()) + return if (mMedia.isEmpty() || mPos >= mMedia.size) null else mMedia[Math.min(mPos, mMedia.size - 1)]