diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt index 84f9f944b..681bca548 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt @@ -142,12 +142,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View currentMedium.isFavorite = mFavoritePaths.contains(currentMedium.path) val visibleBottomActions = if (config.bottomActions) config.visibleBottomActions else 0 - getCurrentFragment()?.let { - (it as? PhotoFragment)?.apply { - mRotationDegrees = mCurrentRotationDegrees - } - } - + getCurrentPhotoFragment()?.mCurrentRotationDegrees = mRotationDegrees menu.apply { findItem(R.id.menu_show_on_map).isVisible = visibleBottomActions and BOTTOM_ACTION_SHOW_ON_MAP == 0 findItem(R.id.menu_slideshow).isVisible = visibleBottomActions and BOTTOM_ACTION_SLIDESHOW == 0 @@ -569,9 +564,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View private fun rotateBy(degrees: Int) { mRotationDegrees = (mRotationDegrees + degrees) % 360 - getCurrentFragment()?.let { - (it as? PhotoFragment)?.rotateImageViewBy(mRotationDegrees) - } + getCurrentPhotoFragment()?.rotateImageViewBy(mRotationDegrees) supportInvalidateOptionsMenu() } @@ -602,6 +595,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View saveRotatedImageToFile(currPath, it, mRotationDegrees, true) { toast(R.string.file_saved) mRotationDegrees = 0 + getCurrentPhotoFragment()?.mCurrentRotationDegrees = 0 invalidateOptionsMenu() } }.start() @@ -609,6 +603,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } } + private fun getCurrentPhotoFragment() = getCurrentFragment() as? PhotoFragment + private fun isShowHiddenFlagNeeded(): Boolean { val file = File(mPath) if (file.isHidden) { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt index 644ac09cd..d181d8bf8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt @@ -32,6 +32,7 @@ import com.davemorrissey.labs.subscaleview.DecoderFactory import com.davemorrissey.labs.subscaleview.ImageDecoder import com.davemorrissey.labs.subscaleview.ImageRegionDecoder import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView +import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.OTG_PATH import com.simplemobiletools.gallery.pro.R @@ -223,7 +224,14 @@ class PhotoFragment : ViewPagerFragment() { if (activity?.isDestroyed == false) { mView.subsampling_view.recycle() } + mLoadZoomableViewHandler.removeCallbacksAndMessages(null) + if (mCurrentRotationDegrees != 0) { + Thread { + val path = mMedium.path + (activity as? BaseSimpleActivity)?.saveRotatedImageToFile(path, path, mCurrentRotationDegrees, false) {} + }.start() + } } override fun onConfigurationChanged(newConfig: Configuration) {