check if we are trying to rotate a photo fragment

This commit is contained in:
tibbi 2017-02-20 23:19:03 +01:00
parent c0fcb48d9c
commit 814b0cc3b6
1 changed files with 8 additions and 2 deletions

View File

@ -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)