Zoom bug on next/previous image fix

This commit is contained in:
Hardcore Sushi 2020-10-14 19:03:30 +02:00
parent 5a885fed72
commit 7fad08ae66
2 changed files with 15 additions and 5 deletions

View File

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

View File

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