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

View file

@ -218,11 +218,17 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
private fun rotateImage(degrees: Float) { private fun rotateImage(degrees: Float) {
mRotationDegrees = (mRotationDegrees + degrees) % 360 mRotationDegrees = (mRotationDegrees + degrees) % 360
getCurrentFragment().rotateImageViewBy(mRotationDegrees) getCurrentFragment()?.rotateImageViewBy(mRotationDegrees)
supportInvalidateOptionsMenu() 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() { private fun showProperties() {
if (getCurrentMedium() != null) if (getCurrentMedium() != null)