Browse Source

Zoom bug on next/previous image fix

master
Hardcore Sushi 12 months ago
parent
commit
7fad08ae66
  1. 10
      app/src/main/java/sushi/hardcore/droidfs/file_viewers/ImageViewer.kt
  2. 10
      app/src/main/java/sushi/hardcore/droidfs/widgets/ZoomableImageView.java

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

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

Loading…
Cancel
Save