Browse Source

another fit to width fix (now for imageviewtouch)

Andrew Dolgov 1 year ago
parent
commit
d53e05335a

+ 15 - 12
org.fox.ttcomics/src/main/java/it/sephiroth/android/library/imagezoom/ImageViewTouchBase.java

@@ -1,9 +1,5 @@
 package it.sephiroth.android.library.imagezoom;
 
-import it.sephiroth.android.library.imagezoom.easing.Cubic;
-import it.sephiroth.android.library.imagezoom.easing.Easing;
-import it.sephiroth.android.library.imagezoom.graphics.FastBitmapDrawable;
-import it.sephiroth.android.library.imagezoom.utils.IDisposable;
 import android.content.Context;
 import android.graphics.Bitmap;
 import android.graphics.Matrix;
@@ -14,6 +10,11 @@ import android.util.AttributeSet;
 import android.util.Log;
 import android.widget.ImageView;
 
+import it.sephiroth.android.library.imagezoom.easing.Cubic;
+import it.sephiroth.android.library.imagezoom.easing.Easing;
+import it.sephiroth.android.library.imagezoom.graphics.FastBitmapDrawable;
+import it.sephiroth.android.library.imagezoom.utils.IDisposable;
+
 /**
  * Base View to manage image zoom/scrool/pinch operations
  * 
@@ -25,7 +26,7 @@ public class ImageViewTouchBase extends ImageView implements IDisposable {
 	public interface OnBitmapChangedListener {
 
 		void onBitmapChanged( Drawable drawable );
-	};
+	}
 
 	public static final String LOG_TAG = "image";
 
@@ -95,13 +96,15 @@ public class ImageViewTouchBase extends ImageView implements IDisposable {
 			r.run();
 		}
 		if ( getDrawable() != null ) {
-			if ( mFitToScreen )
-				getProperBaseMatrix2( getDrawable(), mBaseMatrix );
-			else
-				getProperBaseMatrix( getDrawable(), mBaseMatrix );
-			setImageMatrix( getImageViewMatrix() );
-			
-			if (mFitToWidth) zoomToWidth();
+			if (mFitToWidth) {
+				zoomToWidth();
+			} else {
+				if (mFitToScreen)
+					getProperBaseMatrix2(getDrawable(), mBaseMatrix);
+				else
+					getProperBaseMatrix(getDrawable(), mBaseMatrix);
+				setImageMatrix(getImageViewMatrix());
+			}
 		}
 	}
 

+ 6 - 2
org.fox.ttcomics/src/main/java/org/fox/ttcomics2/ComicFragment.java

@@ -47,8 +47,12 @@ public class ComicFragment extends StateSavedFragment {
 		View view = inflater.inflate(R.layout.fragment_comic, container, false);
 		
 		final ImageViewTouch image = view.findViewById(R.id.comic_image);
-        image.setFitToScreen(true);
-		image.setFitToWidth(m_prefs.getBoolean("fit_to_width", false));
+
+		if (m_prefs.getBoolean("fit_to_width", false)) {
+			image.setFitToWidth(true);
+		} else {
+			image.setFitToScreen(true);
+		}
 
 		try {
 			Glide.with(ComicFragment.this)