From 49df8130cf2e0ba739cbe0d949c0ce846f59c3dc Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 26 Jun 2017 23:30:32 +0200 Subject: [PATCH] changing the current fragment retriever at viewpager activity --- .../gallery/activities/ViewPagerActivity.kt | 12 ++++-------- 1 file changed, 4 insertions(+), 8 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 b779db178..b6d0078f1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -306,17 +306,13 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View private fun rotateImage(degrees: Float) { mRotationDegrees = (mRotationDegrees + degrees) % 360 - getCurrentFragment()?.rotateImageViewBy(mRotationDegrees) + getCurrentFragment()?.let { + (it as? PhotoFragment)?.rotateImageViewBy(mRotationDegrees) + } supportInvalidateOptionsMenu() } - 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 getCurrentFragment() = (view_pager.adapter as MyPagerAdapter).getCurrentFragment(view_pager.currentItem) private fun showProperties() { if (getCurrentMedium() != null)