mirror of
https://github.com/Tencent/QMUI_Android.git
synced 2026-10-18 13:11:05 +08:00
add public method
This commit is contained in:
+10
-1
@@ -48,6 +48,7 @@ public class QMUIContinuousNestedTopAreaBehavior extends QMUIViewOffsetBehavior<
|
||||
private Callback mCallback;
|
||||
private boolean isInTouch = false;
|
||||
private boolean isInFlingOrScroll = false;
|
||||
private boolean replaceCancelActionWithMoveActionForWebView = true;
|
||||
|
||||
public QMUIContinuousNestedTopAreaBehavior(Context context) {
|
||||
this(context, null);
|
||||
@@ -59,6 +60,10 @@ public class QMUIContinuousNestedTopAreaBehavior extends QMUIViewOffsetBehavior<
|
||||
mViewFlinger = new ViewFlinger(context);
|
||||
}
|
||||
|
||||
public void setReplaceCancelActionWithMoveActionForWebView(boolean replaceCancelActionWithMoveActionForWebView) {
|
||||
this.replaceCancelActionWithMoveActionForWebView = replaceCancelActionWithMoveActionForWebView;
|
||||
}
|
||||
|
||||
public void setCallback(Callback callback) {
|
||||
mCallback = callback;
|
||||
}
|
||||
@@ -117,7 +122,11 @@ public class QMUIContinuousNestedTopAreaBehavior extends QMUIViewOffsetBehavior<
|
||||
// dispatch cancel event not work in webView sometimes.
|
||||
MotionEvent cancelEvent = MotionEvent.obtain(ev);
|
||||
cancelEvent.offsetLocation(-child.getLeft(), -child.getTop());
|
||||
cancelEvent.setAction(MotionEvent.ACTION_MOVE);
|
||||
if(replaceCancelActionWithMoveActionForWebView){
|
||||
cancelEvent.setAction(MotionEvent.ACTION_MOVE);
|
||||
}else{
|
||||
cancelEvent.setAction(MotionEvent.ACTION_CANCEL);
|
||||
}
|
||||
child.dispatchTouchEvent(cancelEvent);
|
||||
cancelEvent.recycle();
|
||||
}
|
||||
|
||||
@@ -39,15 +39,15 @@ import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
import com.qmuiteam.qmui.R;
|
||||
import com.qmuiteam.qmui.util.QMUIDisplayHelper;
|
||||
import com.qmuiteam.qmui.util.QMUILangHelper;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
|
||||
import com.qmuiteam.qmui.R;
|
||||
import com.qmuiteam.qmui.util.QMUIDisplayHelper;
|
||||
import com.qmuiteam.qmui.util.QMUILangHelper;
|
||||
|
||||
public class QMUIDraggableScrollBar extends View {
|
||||
|
||||
private int[] STATE_PRESSED = new int[]{android.R.attr.state_pressed};
|
||||
@@ -71,6 +71,7 @@ public class QMUIDraggableScrollBar extends View {
|
||||
private float mDragInnerTop = 0;
|
||||
private int mAdjustDistanceProtection = QMUIDisplayHelper.dp2px(getContext(), 20);
|
||||
private int mAdjustMaxDistanceOnce = QMUIDisplayHelper.dp2px(getContext(), 4);
|
||||
private boolean mAdjustDistanceWithAnimation = true;
|
||||
private boolean enableFadeInAndOut = true;
|
||||
|
||||
public QMUIDraggableScrollBar(Context context) {
|
||||
@@ -90,6 +91,10 @@ public class QMUIDraggableScrollBar extends View {
|
||||
mCallback = callback;
|
||||
}
|
||||
|
||||
public void setAdjustDistanceWithAnimation(boolean adjustDistanceWithAnimation) {
|
||||
mAdjustDistanceWithAnimation = adjustDistanceWithAnimation;
|
||||
}
|
||||
|
||||
public void setKeepShownTime(int keepShownTime) {
|
||||
mKeepShownTime = keepShownTime;
|
||||
}
|
||||
@@ -237,7 +242,7 @@ public class QMUIDraggableScrollBar extends View {
|
||||
int totalWidth = getWidth();
|
||||
int top = getScrollBarTopMargin() + (int) ((totalHeight - drawableHeight) * mPercent);
|
||||
int left = totalWidth - drawableWidth;
|
||||
if (!mIsInDragging && mDrawableDrawTop > 0) {
|
||||
if (!mIsInDragging && mDrawableDrawTop > 0 && mAdjustDistanceWithAnimation) {
|
||||
int moveDistance = top - mDrawableDrawTop;
|
||||
if (moveDistance > mAdjustMaxDistanceOnce && moveDistance < mAdjustDistanceProtection) {
|
||||
top = mDrawableDrawTop + mAdjustMaxDistanceOnce;
|
||||
|
||||
Reference in New Issue
Block a user