getTouchSlop ( )源码实例Demo

android.view.ViewConfiguration#getTouchSlop ( )源码实例Demo

下面列出了android.view.ViewConfiguration#getTouchSlop ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: letv   文件: TaskGuide.java
public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
    int y = (int) motionEvent.getY();
    com.tencent.open.a.f.b("XXXX", "onInterceptTouchEvent-- action = " + motionEvent.getAction() + "currentY = " + y);
    this.b.d(3000);
    switch (motionEvent.getAction()) {
        case 0:
            this.a = y;
            return false;
        case 1:
            if (this.a - y > ViewConfiguration.getTouchSlop() * 2) {
                this.b.l();
                return true;
            }
            break;
    }
    return super.onInterceptTouchEvent(motionEvent);
}
 
源代码2 项目: letv   文件: TaskGuide.java
public boolean onTouchEvent(MotionEvent motionEvent) {
    super.onTouchEvent(motionEvent);
    int y = (int) motionEvent.getY();
    com.tencent.open.a.f.b("XXXX", " onTouchEvent-----startY = " + this.a + "currentY = " + y);
    switch (motionEvent.getAction()) {
        case 0:
            this.a = y;
            break;
        case 1:
            if (this.a - y > ViewConfiguration.getTouchSlop() * 2) {
                this.b.l();
                break;
            }
            break;
    }
    return false;
}
 
源代码3 项目: AirFree-Client   文件: GestureDetector.java
private void init(Context context, boolean ignoreMultitouch) {
    if (mListener == null) {
        throw new NullPointerException("OnGestureListener must not be null");
    }
    mIsLongpressEnabled = true;
    mIgnoreMultitouch = ignoreMultitouch;

    // Fallback to support pre-donuts releases
    int touchSlop, largeTouchSlop, doubleTapSlop;
    if (context == null) {
        //noinspection deprecation
        touchSlop = ViewConfiguration.getTouchSlop();
        largeTouchSlop = touchSlop + 2;
        doubleTapSlop = DOUBLE_TAP_SLOP;
    } else {
        final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
        final float density = metrics.density;
        final ViewConfiguration configuration = ViewConfiguration.get(context);
        touchSlop = configuration.getScaledTouchSlop();
        largeTouchSlop = (int) (density * LARGE_TOUCH_SLOP + 0.5f);
        doubleTapSlop = configuration.getScaledDoubleTapSlop();
    }
    mTouchSlopSquare = touchSlop * touchSlop;
    mLargeTouchSlopSquare = largeTouchSlop * largeTouchSlop;
    mDoubleTapSlopSquare = doubleTapSlop * doubleTapSlop;
}
 
源代码4 项目: Telegram-FOSS   文件: GestureDetector2.java
private void init(Context context) {
    if (mListener == null) {
        throw new NullPointerException("OnGestureListener must not be null");
    }
    mIsLongpressEnabled = true;

    int touchSlop, doubleTapSlop, doubleTapTouchSlop;
    if (context == null) {
        touchSlop = ViewConfiguration.getTouchSlop();
        doubleTapTouchSlop = touchSlop;
        doubleTapSlop = 100;
        mMinimumFlingVelocity = ViewConfiguration.getMinimumFlingVelocity();
        mMaximumFlingVelocity = ViewConfiguration.getMaximumFlingVelocity();
    } else {
        final ViewConfiguration configuration = ViewConfiguration.get(context);
        touchSlop = configuration.getScaledTouchSlop();
        doubleTapTouchSlop = configuration.getScaledTouchSlop();
        doubleTapSlop = configuration.getScaledDoubleTapSlop();
        mMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity();
        mMaximumFlingVelocity = configuration.getScaledMaximumFlingVelocity();
    }
    mTouchSlopSquare = touchSlop * touchSlop;
    mDoubleTapTouchSlopSquare = doubleTapTouchSlop * doubleTapTouchSlop;
    mDoubleTapSlopSquare = doubleTapSlop * doubleTapSlop;
}
 
源代码5 项目: Telegram   文件: GestureDetector2.java
private void init(Context context) {
    if (mListener == null) {
        throw new NullPointerException("OnGestureListener must not be null");
    }
    mIsLongpressEnabled = true;

    int touchSlop, doubleTapSlop, doubleTapTouchSlop;
    if (context == null) {
        touchSlop = ViewConfiguration.getTouchSlop();
        doubleTapTouchSlop = touchSlop;
        doubleTapSlop = 100;
        mMinimumFlingVelocity = ViewConfiguration.getMinimumFlingVelocity();
        mMaximumFlingVelocity = ViewConfiguration.getMaximumFlingVelocity();
    } else {
        final ViewConfiguration configuration = ViewConfiguration.get(context);
        touchSlop = configuration.getScaledTouchSlop();
        doubleTapTouchSlop = configuration.getScaledTouchSlop();
        doubleTapSlop = configuration.getScaledDoubleTapSlop();
        mMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity();
        mMaximumFlingVelocity = configuration.getScaledMaximumFlingVelocity();
    }
    mTouchSlopSquare = touchSlop * touchSlop;
    mDoubleTapTouchSlopSquare = doubleTapTouchSlop * doubleTapTouchSlop;
    mDoubleTapSlopSquare = doubleTapSlop * doubleTapSlop;
}
 
源代码6 项目: fanfouapp-opensource   文件: ImageViewTouch.java
@Override
protected void init() {
    super.init();
    this.mTouchSlop = ViewConfiguration.getTouchSlop();
    this.mGestureListener = new GestureListener();
    this.mScaleListener = new ScaleListener();

    // compatibility for api 7
    this.mScaleDetector = new ScaleGestureDetector(getContext(),
            this.mScaleListener);
    // mGestureDetector = new GestureDetector( getContext(),
    // mGestureListener, null, true );// api>=8
    this.mGestureDetector = new GestureDetector(getContext(),
            this.mGestureListener, null);
    this.mCurrentScaleFactor = 1f;
    this.mDoubleTapDirection = 1;
}
 
源代码7 项目: LaunchEnr   文件: StylusEventHelper.java
/**
 * Constructs a helper for listening to stylus button presses and releases. Ensure that {
 * {@link #onMotionEvent(MotionEvent)} and {@link #onGenericMotionEvent(MotionEvent)} are called on
 * the helper to correctly identify stylus events.
 *
 * @param listener The listener to call for stylus events.
 * @param view Optional view associated with the touch events.
 */
public StylusEventHelper(StylusButtonListener listener, View view) {
    mListener = listener;
    mView = view;
    if (mView != null) {
        mSlop = ViewConfiguration.get(mView.getContext()).getScaledTouchSlop();
    } else {
        mSlop = ViewConfiguration.getTouchSlop();
    }
}
 
源代码8 项目: shortyz   文件: ScrollDetector.java
protected int getSlop(Context context) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) {
        //noinspection deprecation
        return ViewConfiguration.getTouchSlop() * 2;
    } else {
        return ViewConfiguration.get(context).getScaledPagingTouchSlop();
    }
}
 
源代码9 项目: school_shop   文件: ScrollDetector.java
protected int getSlop(Context context) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) {
        //noinspection deprecation
        return ViewConfiguration.getTouchSlop() * 2;
    } else {
        return ViewConfiguration.get(context).getScaledPagingTouchSlop();
    }
}
 
源代码10 项目: floating-action-button   文件: ScrollDetector.java
protected int getSlop(Context context) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) {
        //noinspection deprecation
        return ViewConfiguration.getTouchSlop() * 2;
    } else {
        return ViewConfiguration.get(context).getScaledPagingTouchSlop();
    }
}
 
源代码11 项目: imsdk-android   文件: FingerDragHelper.java
private void initViews() {
    mTouchslop = ViewConfiguration.getTouchSlop();
}
 
源代码12 项目: letv   文件: PullToRefreshBase.java
private void init(Context context, AttributeSet attrs) {
    setOrientation(1);
    this.mTouchSlop = ViewConfiguration.getTouchSlop();
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PullToRefresh);
    if (a.hasValue(22)) {
        this.mMode = a.getInteger(22, 1);
    }
    this.mRefreshableView = createRefreshableView(context, attrs);
    addRefreshableView(context, this.mRefreshableView);
    String pullLabel = context.getString(2131100695);
    String refreshingLabel = context.getString(2131100699);
    String releaseLabel = context.getString(2131100700);
    if (this.mMode == 1 || this.mMode == 3) {
        this.mHeaderLayout = new PullToRefreshHeaderView(context, 1, releaseLabel, pullLabel, refreshingLabel, this.objs);
        addView(this.mHeaderLayout, 0, new LayoutParams(-1, -2));
        measureView(this.mHeaderLayout);
        this.mHeaderHeight = this.mHeaderLayout.getMeasuredHeight();
    }
    if (this.mMode == 2 || this.mMode == 3) {
        this.mFooterLayout = new PullToRefreshHeaderView(context, 2, releaseLabel, pullLabel, refreshingLabel, this.objs);
        addView(this.mFooterLayout, new LayoutParams(-1, -2));
        measureView(this.mFooterLayout);
        this.mHeaderHeight = this.mFooterLayout.getMeasuredHeight();
    }
    if (a.hasValue(21)) {
        int color = a.getColor(21, -16777216);
        if (this.mHeaderLayout != null) {
            this.mHeaderLayout.setTextColor(color);
        }
        if (this.mFooterLayout != null) {
            this.mFooterLayout.setTextColor(color);
        }
    }
    if (a.hasValue(20)) {
        setBackgroundResource(a.getResourceId(20, 0));
    }
    if (a.hasValue(19)) {
        this.mRefreshableView.setBackgroundResource(a.getResourceId(19, 0));
    }
    a.recycle();
    switch (this.mMode) {
        case 2:
            setPadding(0, 0, 0, -this.mHeaderHeight);
            break;
        case 3:
            setPadding(0, -this.mHeaderHeight, 0, -this.mHeaderHeight);
            break;
        default:
            setPadding(0, -this.mHeaderHeight, 0, 0);
            break;
    }
    if (this.mMode != 3) {
        this.mCurrentMode = this.mMode;
    }
}