From d6b0514f4c5c596c8a47fea2862380e1dd6bccd5 Mon Sep 17 00:00:00 2001 From: Ztiany Date: Thu, 21 Nov 2019 11:35:55 +0800 Subject: [PATCH] fix PullToZoomView --- .../pulltozoom/PullToZoomScrollView.java | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/lib_base/src/main/java/com/android/base/widget/pulltozoom/PullToZoomScrollView.java b/lib_base/src/main/java/com/android/base/widget/pulltozoom/PullToZoomScrollView.java index a1d1eca..8f74b85 100644 --- a/lib_base/src/main/java/com/android/base/widget/pulltozoom/PullToZoomScrollView.java +++ b/lib_base/src/main/java/com/android/base/widget/pulltozoom/PullToZoomScrollView.java @@ -13,10 +13,9 @@ import android.view.animation.DecelerateInterpolator; import com.android.base.R; -import timber.log.Timber; - /** + * usage: *
  *     {@code
  *     = mOriginContainerViewHeight) {
-                    int height = mContainerView
-                            .getHeight() - offset < mMaxZoomHeight ?
-                            mContainerView.getHeight() - offset : mMaxZoomHeight;
+                    int height = mContainerView.getHeight() - offset < mMaxZoomHeight ? mContainerView.getHeight() - offset : mMaxZoomHeight;
                     setContainerHeight(height);
                 }
             } else {
                 if (mContainerView.getHeight() > mOriginContainerViewHeight) {
-                    int height = mContainerView.getHeight() - deltaY > mOriginContainerViewHeight ?
-                            mContainerView.getHeight() - deltaY : mOriginContainerViewHeight;
+                    int height = mContainerView.getHeight() - deltaY > mOriginContainerViewHeight ? mContainerView.getHeight() - deltaY : mOriginContainerViewHeight;
                     setContainerHeight(height);
                     return true;
                 }
@@ -172,7 +170,7 @@ public class PullToZoomScrollView extends NestedScrollView {
     @SuppressLint("ClickableViewAccessibility")
     @Override
     public boolean onTouchEvent(MotionEvent ev) {
-        if (hasInnerView()) {
+        if (innerViewInitialized()) {
             int action = ev.getAction();
             if (action == MotionEvent.ACTION_DOWN) {
                 cancelAnim();
@@ -231,9 +229,8 @@ public class PullToZoomScrollView extends NestedScrollView {
         mZoomView.setPivotY(mOriginContainerViewHeight / 3F);
         float addOffset = (height - mOriginContainerViewHeight) * mZoomFactory / mOriginContainerViewHeight;
         float scale = height * 1.0F / mOriginContainerViewHeight + addOffset;
-        Timber.d("scale = %f", scale);
 
-        if (!Float.isInfinite(scale) && !Float.isNaN(scale)) {
+        if (!Float.isInfinite(scale) && !Float.isNaN(scale) && scale >= 1F) {
             mZoomView.setScaleX(scale);
             mZoomView.setScaleY(scale);
         } else {