Java Code Examples for android.view.ViewConfiguration#getTouchSlop()

The following examples show how to use android.view.ViewConfiguration#getTouchSlop() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TaskGuide.java    From letv with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 2
Source File: TaskGuide.java    From letv with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 3
Source File: GestureDetector.java    From AirFree-Client with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example 4
Source File: GestureDetector2.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 5
Source File: GestureDetector2.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 6
Source File: ImageViewTouch.java    From fanfouapp-opensource with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 7
Source File: StylusEventHelper.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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();
    }
}
 
Example 8
Source File: ScrollDetector.java    From shortyz with GNU General Public License v3.0 5 votes vote down vote up
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();
    }
}
 
Example 9
Source File: ScrollDetector.java    From school_shop with MIT License 5 votes vote down vote up
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();
    }
}
 
Example 10
Source File: ScrollDetector.java    From floating-action-button with Apache License 2.0 5 votes vote down vote up
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();
    }
}
 
Example 11
Source File: FingerDragHelper.java    From imsdk-android with MIT License 4 votes vote down vote up
private void initViews() {
    mTouchslop = ViewConfiguration.getTouchSlop();
}
 
Example 12
Source File: PullToRefreshBase.java    From letv with Apache License 2.0 4 votes vote down vote up
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;
    }
}