Java Code Examples for androidx.customview.widget.ViewDragHelper#STATE_DRAGGING

The following examples show how to use androidx.customview.widget.ViewDragHelper#STATE_DRAGGING . 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: MainDragLayout.java    From NewFastFrame with Apache License 2.0 6 votes vote down vote up
@Override
        public boolean onInterceptTouchEvent(MotionEvent ev) {
//                如果符合条件直接截获事件由自己在onTouchEvent方法中处理
//                如果在释放自动滑动的过程中点击,会导致停止动画
                boolean result = mViewDragHelper.shouldInterceptTouchEvent(ev) && mGestureDetector.onTouchEvent(ev);
//                这里是为了防止在滑动的过程中,突然点击,导致被点击的页面停止滑动的的情况发生
                if (!result && mViewDragHelper.getViewDragState() == ViewDragHelper.STATE_DRAGGING && ev.getAction() == MotionEvent.ACTION_UP) {
                        if (getChildAt(2).getLeft() < range / 2) {
                                closeMenu();
                        } else {
                                openMenu();
                        }
                }


                return result;
        }
 
Example 2
Source File: PullDismissLayout.java    From StoryView with MIT License 5 votes vote down vote up
public boolean onInterceptTouchEvent(MotionEvent event) {
    int action = MotionEventCompat.getActionMasked(event);

    boolean pullingDown = false;

    switch (action) {
        case MotionEvent.ACTION_DOWN:
            verticalTouchSlop = event.getY();
        case MotionEvent.ACTION_MOVE:
            final float dy = event.getY() - verticalTouchSlop;
            if (dy > dragHelper.getTouchSlop()) {
                pullingDown = true;
                mTouchCallbacks.touchPull();
            }else{
                mTouchCallbacks.touchDown(event.getX(), event.getY());
            }
            break;
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
            verticalTouchSlop = 0.0f;
            mTouchCallbacks.touchUp();
            break;
    }

    if (!dragHelper.shouldInterceptTouchEvent(event) && pullingDown) {
        if (dragHelper.getViewDragState() == ViewDragHelper.STATE_IDLE &&
                dragHelper.checkTouchSlop(ViewDragHelper.DIRECTION_VERTICAL)) {

            View child = getChildAt(0);
            if (child != null && !listener.onShouldInterceptTouchEvent()) {
                dragHelper.captureChildView(child, event.getPointerId(0));
                return dragHelper.getViewDragState() == ViewDragHelper.STATE_DRAGGING;
            }
        }
    }
    return false;
}
 
Example 3
Source File: DragLayout.java    From NewFastFrame with Apache License 2.0 5 votes vote down vote up
@Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
//                如果符合条件直接截获事件由自己在onTouchEvent方法中处理
//                如果在释放自动滑动的过程中点击,会导致停止动画
        if (isIntercept()) {
            return false;
        }
        boolean result = mViewDragHelper.shouldInterceptTouchEvent(ev) && mGestureDetector.onTouchEvent(ev);
//                这里是为了防止在滑动的过程中,突然点击,导致被点击的页面停止滑动的的情况发生

        if (!result && mViewDragHelper.getViewDragState() == ViewDragHelper.STATE_DRAGGING && ev.getAction() == MotionEvent.ACTION_UP) {
            if (mode == LEFT_MODE) {
                if (content.getLeft() < range / 2) {
                    closeMenu();
                } else {
                    openMenu();
                }
            } else {
                if (content.getRight() < range / 2) {
                    openMenu();
                } else {
                    closeMenu();
                }
            }
        }
        return result;
    }
 
Example 4
Source File: SwipeLayout.java    From SwipeLayout with MIT License 4 votes vote down vote up
/**
 * Is moving main view
 */
public boolean isMoving() {
    return (currentDraggingState == ViewDragHelper.STATE_DRAGGING ||
            currentDraggingState == ViewDragHelper.STATE_SETTLING);
}
 
Example 5
Source File: SwipeLayout.java    From SwipeLayout with MIT License 4 votes vote down vote up
private boolean isIdleAfterMoving(int state) {
    return (currentDraggingState == ViewDragHelper.STATE_DRAGGING
            || currentDraggingState == ViewDragHelper.STATE_SETTLING)
            && state == ViewDragHelper.STATE_IDLE;
}
 
Example 6
Source File: BottomSheetBehavior.java    From bottomsheetrecycler with Apache License 2.0 4 votes vote down vote up
@Override
public void onViewDragStateChanged(int state) {
    if (state == ViewDragHelper.STATE_DRAGGING) {
        setStateInternal(STATE_DRAGGING);
    }
}
 
Example 7
Source File: BottomSheetBehaviorGoogleMapsLike.java    From CustomBottomSheetBehavior with Apache License 2.0 4 votes vote down vote up
@Override
public void onViewDragStateChanged( int state ) {
    if ( state == ViewDragHelper.STATE_DRAGGING ) {
        setStateInternal( STATE_DRAGGING );
    }
}
 
Example 8
Source File: BottomSheetBehavior.java    From material-components-android with Apache License 2.0 4 votes vote down vote up
@Override
public void onViewDragStateChanged(int state) {
  if (state == ViewDragHelper.STATE_DRAGGING && draggable) {
    setStateInternal(STATE_DRAGGING);
  }
}
 
Example 9
Source File: BottomSheetBehavior.java    From Mysplash with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void onViewDragStateChanged(int state) {
    if (state == ViewDragHelper.STATE_DRAGGING && draggable) {
        setStateInternal(STATE_DRAGGING);
    }
}