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 89f1314d5..7bb2844ed 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -147,10 +147,12 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View private fun updatePagerItems() { val pagerAdapter = MyPagerAdapter(this, supportFragmentManager, mMedia) - view_pager?.apply { - adapter = pagerAdapter - currentItem = mPos - addOnPageChangeListener(this@ViewPagerActivity) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && !isDestroyed) { + view_pager?.apply { + adapter = pagerAdapter + currentItem = mPos + addOnPageChangeListener(this@ViewPagerActivity) + } } }