From 814b0cc3b6b52c462ebeb5fbb4c56a090479b7b3 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 20 Feb 2017 23:19:03 +0100 Subject: [PATCH] check if we are trying to rotate a photo fragment --- .../gallery/activities/ViewPagerActivity.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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 53463c55a..34a1abb0b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -218,11 +218,17 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View private fun rotateImage(degrees: Float) { mRotationDegrees = (mRotationDegrees + degrees) % 360 - getCurrentFragment().rotateImageViewBy(mRotationDegrees) + getCurrentFragment()?.rotateImageViewBy(mRotationDegrees) supportInvalidateOptionsMenu() } - private fun getCurrentFragment() = ((view_pager.adapter as MyPagerAdapter).getCurrentFragment(view_pager.currentItem) as PhotoFragment) + private fun getCurrentFragment(): PhotoFragment? { + val fragment = (view_pager.adapter as MyPagerAdapter).getCurrentFragment(view_pager.currentItem) + return if (fragment is PhotoFragment) + fragment + else + null + } private fun showProperties() { if (getCurrentMedium() != null)