0

Code fist:

 @Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    switch (ev.getAction()) {
        case MotionEvent.ACTION_DOWN:
            isActionCancel = false;
            isTouchOrRunning = true;
            lastY = ev.getY();
            break;
    }
    return super.onInterceptTouchEvent(ev);
}

@Override
public boolean onTouchEvent(MotionEvent ev) {
    if (oa != null && oa.isRunning()) {
        ev.setAction(MotionEvent.ACTION_UP);
        isActionCancel = true;
    }
    if (isActionCancel && ev.getAction() != MotionEvent.ACTION_DOWN) {
        return false;
    }
    if (ev.getActionIndex() != 0 && getScrollY() < range) {
        ev.setAction(MotionEvent.ACTION_UP);
        isActionCancel = true;
    }

    switch (ev.getAction()) {
        case MotionEvent.ACTION_MOVE:
            isTouchOrRunning = true;
            if (getScrollY() != 0) {
                detalY = 0;
                lastY = ev.getY();
            } else {
                detalY = ev.getY() - lastY;
                if (detalY > 0) {
                    setT((int) -detalY / 5);
                    return true;
                }
            }
            break;
        case MotionEvent.ACTION_UP:
            isTouchOrRunning = false;
            if (getScrollY() < range) {
                if (detalY != 0) {
                    reset();
                } else {
                    toggle();
                }
                return true;
            }
            break;
    }
    return super.onTouchEvent(ev);
}

As i know, View must consume ACTION_DOWN event so that it can receive other eventaction, but in the code above, in onTouchEvent() function ACTION_DOWN are not handled There, how could this view receive ACTION_MOVE and ACTION_UP??

YanceyWang
  • 77
  • 1
  • 6

0 Answers0