From 641610842b91c9a066c4afe33f821f05876c0e86 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 5 Oct 2018 10:51:12 +0200 Subject: [PATCH] fix #981, avoid some glitches related to GIF playing --- .../gallery/fragments/PhotoFragment.kt | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt index d221162e7..1da94e93e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt @@ -163,11 +163,15 @@ class PhotoFragment : ViewPagerFragment() { initExtendedDetails() } - if (wasInit && (config.allowZoomingImages != storedAllowDeepZoomableImages || config.showHighestQuality != storedShowHighestQuality || - config.oneFingerZoom != storedAllowOneFingerZoom)) { - isSubsamplingVisible = false - view.subsampling_view.beGone() - loadImage() + if (wasInit) { + if (config.allowZoomingImages != storedAllowDeepZoomableImages || config.showHighestQuality != storedShowHighestQuality || + config.oneFingerZoom != storedAllowOneFingerZoom) { + isSubsamplingVisible = false + view.subsampling_view.beGone() + loadImage() + } else if (medium.isGIF()) { + loadGif() + } } val allowPhotoGestures = config.allowPhotoGestures @@ -518,7 +522,18 @@ class PhotoFragment : ViewPagerFragment() { override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) - loadImage() + + // avoid GIFs being skewed, played in wrong aspect ratio + if (medium.isGIF()) { + view.onGlobalLayout { + Handler().postDelayed({ + loadGif() + }, 50) + } + } else { + loadImage() + } + initExtendedDetails() }