当前位置: 首页>>代码示例>>Java>>正文


Java MotionEventCompat.ACTION_POINTER_DOWN属性代码示例

本文整理汇总了Java中android.support.v4.view.MotionEventCompat.ACTION_POINTER_DOWN属性的典型用法代码示例。如果您正苦于以下问题:Java MotionEventCompat.ACTION_POINTER_DOWN属性的具体用法?Java MotionEventCompat.ACTION_POINTER_DOWN怎么用?Java MotionEventCompat.ACTION_POINTER_DOWN使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.support.v4.view.MotionEventCompat的用法示例。


在下文中一共展示了MotionEventCompat.ACTION_POINTER_DOWN属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent ev) {
    final int action = MotionEventCompat.getActionMasked(ev);
    if (isBackToStart && action == MotionEvent.ACTION_DOWN) isBackToStart = false;
    switch (mType) {
        case BOTTOM:
            if (!isEnabled() || isBackToStart || canChildScrollDown() || isRefreshing) {
                return false;
            }
            break;
        case TOP:
        default:
            if (!isEnabled() || isBackToStart || canChildScrollUp() || isRefreshing) {
                return false;
            }
            break;
    }
    switch (action) {
        case MotionEvent.ACTION_DOWN:
            mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
            isReady = false;
            break;
        case MotionEvent.ACTION_MOVE:
            if (TouchActionMove(ev)) return false;
            break;
        case MotionEventCompat.ACTION_POINTER_DOWN:
            final int index = MotionEventCompat.getActionIndex(ev);
            mActivePointerId = MotionEventCompat.getPointerId(ev, index);
            break;
        case MotionEventCompat.ACTION_POINTER_UP:
            onSecondaryPointerUp(ev);
            break;
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL: {
            return TouchActionCancel(ev);
        }
    }
    return true;
}
 
开发者ID:shenhuanet,项目名称:AndroidOpen,代码行数:39,代码来源:SwipeToRefreshLayout.java

示例2: onInterceptTouchEvent

@Override
public boolean onInterceptTouchEvent(MotionEvent e) {
    final int action = MotionEventCompat.getActionMasked(e);
    final int actionIndex = MotionEventCompat.getActionIndex(e);

    switch (action) {
        case MotionEvent.ACTION_DOWN:
            mScrollPointerId = MotionEventCompat.getPointerId(e, 0);
            mInitialTouchX = (int) (e.getX() + 0.5f);
            mInitialTouchY = (int) (e.getY() + 0.5f);
            return super.onInterceptTouchEvent(e);

        case MotionEventCompat.ACTION_POINTER_DOWN:
            mScrollPointerId = MotionEventCompat.getPointerId(e, actionIndex);
            mInitialTouchX = (int) (MotionEventCompat.getX(e, actionIndex) + 0.5f);
            mInitialTouchY = (int) (MotionEventCompat.getY(e, actionIndex) + 0.5f);
            return super.onInterceptTouchEvent(e);

        case MotionEvent.ACTION_MOVE: {
            final int index = MotionEventCompat.findPointerIndex(e, mScrollPointerId);
            if (index < 0) {
                return false;
            }

            final int x = (int) (MotionEventCompat.getX(e, index) + 0.5f);
            final int y = (int) (MotionEventCompat.getY(e, index) + 0.5f);
            if (getScrollState() != SCROLL_STATE_DRAGGING) {
                final int dx = x - mInitialTouchX;
                final int dy = y - mInitialTouchY;
                final boolean canScrollHorizontally = getLayoutManager().canScrollHorizontally();
                final boolean canScrollVertically = getLayoutManager().canScrollVertically();
                boolean startScroll = false;
                if (canScrollHorizontally && Math.abs(dx) > mTouchSlop && (Math.abs(dx) >= Math.abs(dy) || canScrollVertically)) {
                    startScroll = true;
                }
                if (canScrollVertically && Math.abs(dy) > mTouchSlop && (Math.abs(dy) >= Math.abs(dx) || canScrollHorizontally)) {
                    startScroll = true;
                }
                return startScroll && super.onInterceptTouchEvent(e);
            }
            return super.onInterceptTouchEvent(e);
        }

        default:
            return super.onInterceptTouchEvent(e);
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:47,代码来源:BaseRecycleView.java


注:本文中的android.support.v4.view.MotionEventCompat.ACTION_POINTER_DOWN属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。