From 7fad08ae6609ead259eca137f6566e073e3804a0 Mon Sep 17 00:00:00 2001 From: Hardcore Sushi Date: Wed, 14 Oct 2020 19:03:30 +0200 Subject: [PATCH] Zoom bug on next/previous image fix --- .../sushi/hardcore/droidfs/file_viewers/ImageViewer.kt | 10 ++++++++-- .../hardcore/droidfs/widgets/ZoomableImageView.java | 10 +++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/sushi/hardcore/droidfs/file_viewers/ImageViewer.kt b/app/src/main/java/sushi/hardcore/droidfs/file_viewers/ImageViewer.kt index 5da3bc4..4dcac12 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/file_viewers/ImageViewer.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/file_viewers/ImageViewer.kt @@ -211,10 +211,16 @@ class ImageViewer: FileViewerActivity() { } fun onClickPrevious(view: View){ - askSaveRotation { swipeImage(1F) } + askSaveRotation { + image_viewer.resetZoomFactor() + swipeImage(1F) + } } fun onClickNext(view: View){ - askSaveRotation { swipeImage(-1F) } + askSaveRotation { + image_viewer.resetZoomFactor() + swipeImage(-1F) + } } private fun askSaveRotation(callback: () -> Unit){ diff --git a/app/src/main/java/sushi/hardcore/droidfs/widgets/ZoomableImageView.java b/app/src/main/java/sushi/hardcore/droidfs/widgets/ZoomableImageView.java index 51a70f0..c428a60 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/widgets/ZoomableImageView.java +++ b/app/src/main/java/sushi/hardcore/droidfs/widgets/ZoomableImageView.java @@ -23,8 +23,8 @@ public class ZoomableImageView extends androidx.appcompat.widget.AppCompatImageV // Remember some things for zooming PointF last = new PointF(); PointF start = new PointF(); - float minScale = 1f; - float maxScale = 3f; + static final float minScale = 1f; + static final float maxScale = 3f; float[] m; int viewWidth, viewHeight; @@ -123,9 +123,13 @@ public class ZoomableImageView extends androidx.appcompat.widget.AppCompatImageV return saveScale > minScale; } + public void resetZoomFactor(){ + saveScale = minScale; + } + public void restoreZoomNormal(){ float origScale = saveScale; - saveScale = minScale; + resetZoomFactor(); float mScaleFactor = minScale / origScale; matrix.postScale(mScaleFactor, mScaleFactor, viewWidth/2, viewHeight/2); fixTrans();