summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2012-10-17 16:13:13 +0400
committerAndrew Dolgov <[email protected]>2012-10-17 16:13:13 +0400
commit2e35ef83788246df5526dd0ddc762dc8f799239d (patch)
treeaa64eb8205125da6bf998ce7de2268fa7757ff60 /src
parent4c3ccd6e0c794336f28a6767ddf06d0e89ae7558 (diff)
fit to height on double tap when fit to width already
Diffstat (limited to 'src')
-rw-r--r--src/it/sephiroth/android/library/imagezoom/ImageViewTouch.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/it/sephiroth/android/library/imagezoom/ImageViewTouch.java b/src/it/sephiroth/android/library/imagezoom/ImageViewTouch.java
index 94bff44..1dd873c 100644
--- a/src/it/sephiroth/android/library/imagezoom/ImageViewTouch.java
+++ b/src/it/sephiroth/android/library/imagezoom/ImageViewTouch.java
@@ -7,6 +7,7 @@ import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
+import android.view.Display;
import android.view.GestureDetector;
import android.view.GestureDetector.OnGestureListener;
import android.view.MotionEvent;
@@ -41,7 +42,7 @@ public class ImageViewTouch extends ImageViewTouchBase {
public ImageViewTouch( Context context, AttributeSet attrs ) {
super( context, attrs );
}
-
+
@Override
protected void init() {
super.init();
@@ -126,12 +127,18 @@ public class ImageViewTouch extends ImageViewTouchBase {
protected float onDoubleTapPost( float scale, float maxZoom ) {
if ( mDoubleTapDirection == 1 ) {
if (mCurrentScaleFactor - 1.0f < 0.01) { //( scale + ( mScaleFactor * 2 ) ) <= maxZoom
-
- float w = getBitmapRect().right - getBitmapRect().left;
+
float scaleFactor = mScaleFactor;
+
+ RectF bitmapRect = getBitmapRect();
+
+ float w = bitmapRect.right - bitmapRect.left;
+ float h = bitmapRect.bottom - bitmapRect.top;
if (w < getWidth()) {
- scaleFactor = (float)getWidth() / (float)w - scale;
+ scaleFactor = (float)getWidth() / w - scale;
+ } else if (h < getHeight()) {
+ scaleFactor = (float)getHeight() / h - scale;
}
return scale + scaleFactor;