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


Java MotionEventCompat.getActionIndex方法代码示例

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


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

示例1: onInterceptTouchEvent

import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    if (!isEnabled()) {
        return false;
    }
    switch (MotionEventCompat.getActionMasked(ev) & MotionEventCompat.ACTION_MASK) {
        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
            viewDragHelper.cancel();
            return false;
        case MotionEvent.ACTION_DOWN:
            int index = MotionEventCompat.getActionIndex(ev);
            activePointerId = MotionEventCompat.getPointerId(ev, index);
            if (activePointerId == INVALID_VIEW_POINTER) {
                return false;
            }
            break;
        default:
            break;
    }
    boolean interceptTap = viewDragHelper.isViewUnder(dragView, (int) ev.getX(), (int) ev.getY());
    return viewDragHelper.shouldInterceptTouchEvent(ev) || interceptTap;
}
 
开发者ID:mugku,项目名称:slidingplayersampleapp,代码行数:24,代码来源:SlidingViewK.java

示例2: onSecondaryPointerUp

import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
private void onSecondaryPointerUp(MotionEvent ev) {
    final int pointerIndex = MotionEventCompat.getActionIndex(ev);
    final int pointerId = MotionEventCompat.getPointerId(ev, pointerIndex);
    if (pointerId == mActivePointerId) {
        // This was our active pointer going up. Choose a new
        // active pointer and adjust accordingly.
        final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
        if (isHorizontal()) {
            mLastMotionX = MotionEventCompat.getX(ev, newPointerIndex);
        } else {
            mLastMotionY = MotionEventCompat.getY(ev, newPointerIndex);
        }
        mActivePointerId = MotionEventCompat.getPointerId(ev, newPointerIndex);
        if (mVelocityTracker != null) {
            mVelocityTracker.clear();
        }
    }
}
 
开发者ID:ynztlxdeai,项目名称:TextReader,代码行数:19,代码来源:DirectionalViewpager.java

示例3: onTouchEvent

import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent ev) {
    final int action = ev.getActionMasked();
    switch (action) {
        case MotionEvent.ACTION_DOWN:
            int index = MotionEventCompat.getActionIndex(ev);
            mActivePointerId = MotionEventCompat.getPointerId(ev, index);
            if (mActivePointerId == INVALID_POINTER)
                break;
            mLastMotionX = ev.getX();
            mLastMotionY = ev.getY();
            break;

        case MotionEvent.ACTION_MOVE:
            int indexMove = MotionEventCompat.getActionIndex(ev);
            mActivePointerId = MotionEventCompat.getPointerId(ev, indexMove);

            if (mActivePointerId == INVALID_POINTER) {

            } else {
                final float y = ev.getY();
                float dy = y - mLastMotionY;
                if (checkIsTop() && dy >= 1.0f) {
                    bScrollDown = true;
                    bDraging = true;
                } else {
                    bScrollDown = false;
                    bDraging = false;
                }
                mLastMotionX = y;
            }
            break;

        case MotionEvent.ACTION_UP:
            mLastMotionY = 0;
            break;
    }
    return super.onTouchEvent(ev);
}
 
开发者ID:lo625090140,项目名称:lqrwechatrongcloud,代码行数:40,代码来源:FriendRefreshView.java

示例4: onInterceptTouchEvent

import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
/**
 * Override method to intercept only touch events over the drag view and to cancel the drag when
 * the action associated to the MotionEvent is equals to ACTION_CANCEL or ACTION_UP.
 *
 * @param ev captured.
 * @return true if the view is going to process the touch event or false if not.
 */
@Override
public boolean onInterceptTouchEvent(MotionEvent ev)
{
    if (!isEnabled())
    {
        return false;
    }
    switch (MotionEventCompat.getActionMasked(ev) & MotionEventCompat.ACTION_MASK)
    {
        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
            viewDragHelper.cancel();
            return false;
        case MotionEvent.ACTION_DOWN:
            int index = MotionEventCompat.getActionIndex(ev);
            activePointerId = MotionEventCompat.getPointerId(ev, index);
            if (activePointerId == INVALID_POINTER)
            {
                return false;
            }
            break;
        default:
            break;
    }
    boolean interceptTap = viewDragHelper.isViewUnder(dragView, (int) ev.getX(), (int) ev.getY());
    return viewDragHelper.shouldInterceptTouchEvent(ev) || interceptTap;
}
 
开发者ID:jbmlaird,项目名称:DiscogsBrowser,代码行数:35,代码来源:DraggableView.java

示例5: onSecondaryPointerUp

import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
private void onSecondaryPointerUp(MotionEvent ev) {
    final int pointerIndex = MotionEventCompat.getActionIndex(ev);
    final int pointerId = MotionEventCompat.getPointerId(ev, pointerIndex);
    if (pointerId == mActivePointerId) {
        final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
        mActivePointerId = MotionEventCompat.getPointerId(ev,
                newPointerIndex);
    }
}
 
开发者ID:GaoGersy,项目名称:AutoRecycleView,代码行数:10,代码来源:SuperSwipeRefreshLayout.java

示例6: onPointerUp

import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
private void onPointerUp(MotionEvent e) {
    final int actionIndex = MotionEventCompat.getActionIndex(e);
    if (MotionEventCompat.getPointerId(e, actionIndex) == mActivePointerId) {
        // Pick a new pointer to pick up the slack.
        final int newIndex = actionIndex == 0 ? 1 : 0;
        mActivePointerId = MotionEventCompat.getPointerId(e, newIndex);
        mLastTouchX = getMotionEventX(e, newIndex);
        mLastTouchY = getMotionEventY(e, newIndex);
    }
}
 
开发者ID:wp521,项目名称:MyFire,代码行数:11,代码来源:IRecyclerView.java

示例7: onSecondaryPointerUp

import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
private void onSecondaryPointerUp(MotionEvent ev) {
    final int pointerIndex = MotionEventCompat.getActionIndex(ev);
    final int pointerId = MotionEventCompat.getPointerId(ev, pointerIndex);
    if (pointerId == mActivePointerId) {
        final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
        mActivePointerId = MotionEventCompat.getPointerId(ev, newPointerIndex);
    }
}
 
开发者ID:838030195,项目名称:DaiGo,代码行数:9,代码来源:PullRefreshLayout.java

示例8: onSecondaryPointerUp

import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
private void onSecondaryPointerUp(MotionEvent ev) {
    final int pointerIndex = MotionEventCompat.getActionIndex(ev);
    final int pointerId = MotionEventCompat.getPointerId(ev, pointerIndex);
    if (pointerId == mActivePointerId) {
        // This was our active pointer going up. Choose a new
        // active pointer and adjust accordingly.
        final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
        mActivePointerId = MotionEventCompat.getPointerId(ev, newPointerIndex);
    }
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:11,代码来源:LingjuSwipeUpLoadRefreshLayout.java

示例9: onPointerUp

import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
private void onPointerUp(MotionEvent e) {
    final int actionIndex = MotionEventCompat.getActionIndex(e);
    if (MotionEventCompat.getPointerId(e, actionIndex) == mScrollPointerId) {
        // Pick a new pointer to pick up the slack.
        final int newIndex = actionIndex == 0 ? 1 : 0;
        mScrollPointerId = MotionEventCompat.getPointerId(e, newIndex);
        mInitialTouchX = mLastTouchX = (int) (MotionEventCompat.getX(e, newIndex) + 0.5f);
        mInitialTouchY = mLastTouchY = (int) (MotionEventCompat.getY(e, newIndex) + 0.5f);
    }
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:11,代码来源:RecyclerView.java

示例10: onSecondaryPointerUp

import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
private void onSecondaryPointerUp(MotionEvent ev) {
    final int pointerIndex = MotionEventCompat.getActionIndex(ev);
    final int pointerId = MotionEventCompat.getPointerId(ev, pointerIndex);
    if (pointerId == mActivePointerId) {
        // This was our active pointer going up. Choose a new
        // active pointer and adjust accordingly.
        final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
        mLastMotionX = MotionEventCompat.getX(ev, newPointerIndex);
        mActivePointerId = MotionEventCompat.getPointerId(ev, newPointerIndex);
        if (mVelocityTracker != null) {
            mVelocityTracker.clear();
        }
    }
}
 
开发者ID:ruiqiao2017,项目名称:Renrentou,代码行数:15,代码来源:XCCycleViewPager.java

示例11: onSecondaryPointerUp

import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
private void onSecondaryPointerUp(MotionEvent motionEvent) {
    final int pointerIndex = MotionEventCompat.getActionIndex(motionEvent);
    final int pointerId = motionEvent.getPointerId(pointerIndex);
    if (pointerId == activePointerId) {
        activePointerId = motionEvent.getPointerId(pointerIndex == 0 ? 1 : 0);
    }
}
 
开发者ID:Ilya-Gh,项目名称:Typewriter,代码行数:8,代码来源:TypewriterRefreshLayout.java

示例12: onSecondaryPointerUp

import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
private void onSecondaryPointerUp(MotionEvent ev) {
    final int pointerIndex = MotionEventCompat.getActionIndex(ev);
    final int pointerId = ev.getPointerId(pointerIndex);
    if (pointerId == mActivePointerId) {
        // This was our active pointer going up. Choose a new
        // active pointer and adjust accordingly.
        final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
        mActivePointerId = ev.getPointerId(newPointerIndex);
    }
}
 
开发者ID:coopese,项目名称:qmui,代码行数:11,代码来源:QMUIPullRefreshLayout.java

示例13: onTouchEvent

import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
public boolean onTouchEvent(MotionEvent ev) {
    if (super.onTouchEvent(ev)) {
        return true;
    }
    if (this.mViewPager == null || this.mViewPager.getAdapter().getCount() == 0) {
        return false;
    }
    int action = ev.getAction() & 255;
    switch (action) {
        case 0:
            this.mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
            this.mLastMotionX = ev.getX();
            break;
        case 1:
        case 3:
            if (!this.mIsDragging) {
                int count = this.mViewPager.getAdapter().getCount();
                int width = getWidth();
                float halfWidth = ((float) width) / 2.0f;
                float sixthWidth = ((float) width) / 6.0f;
                if (this.mCurrentPage > 0 && ev.getX() < halfWidth - sixthWidth) {
                    if (action != 3) {
                        this.mViewPager.setCurrentItem(this.mCurrentPage - 1);
                    }
                    return true;
                } else if (this.mCurrentPage < count - 1 && ev.getX() > halfWidth +
                        sixthWidth) {
                    if (action != 3) {
                        this.mViewPager.setCurrentItem(this.mCurrentPage + 1);
                    }
                    return true;
                }
            }
            this.mIsDragging = false;
            this.mActivePointerId = -1;
            if (this.mViewPager.isFakeDragging()) {
                this.mViewPager.endFakeDrag();
                break;
            }
            break;
        case 2:
            float x = MotionEventCompat.getX(ev, MotionEventCompat.findPointerIndex(ev, this
                    .mActivePointerId));
            float deltaX = x - this.mLastMotionX;
            if (!this.mIsDragging && Math.abs(deltaX) > ((float) this.mTouchSlop)) {
                this.mIsDragging = true;
            }
            if (this.mIsDragging) {
                this.mLastMotionX = x;
                if (this.mViewPager.isFakeDragging() || this.mViewPager.beginFakeDrag()) {
                    this.mViewPager.fakeDragBy(deltaX);
                    break;
                }
            }
            break;
        case 5:
            int index = MotionEventCompat.getActionIndex(ev);
            this.mLastMotionX = MotionEventCompat.getX(ev, index);
            this.mActivePointerId = MotionEventCompat.getPointerId(ev, index);
            break;
        case 6:
            int pointerIndex = MotionEventCompat.getActionIndex(ev);
            if (MotionEventCompat.getPointerId(ev, pointerIndex) == this.mActivePointerId) {
                this.mActivePointerId = MotionEventCompat.getPointerId(ev, pointerIndex == 0
                        ? 1 : 0);
            }
            this.mLastMotionX = MotionEventCompat.getX(ev, MotionEventCompat.findPointerIndex
                    (ev, this.mActivePointerId));
            break;
    }
    return true;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:73,代码来源:UnderlinePageIndicator.java

示例14: onTouchEvent

import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
public void onTouchEvent(RecyclerView recyclerView, MotionEvent event) {
    int newPointerIndex = 0;
    ItemTouchHelper.this.mGestureDetector.onTouchEvent(event);
    if (ItemTouchHelper.this.mVelocityTracker != null) {
        ItemTouchHelper.this.mVelocityTracker.addMovement(event);
    }
    if (ItemTouchHelper.this.mActivePointerId != -1) {
        int action = MotionEventCompat.getActionMasked(event);
        int activePointerIndex = MotionEventCompat.findPointerIndex(event, ItemTouchHelper.this.mActivePointerId);
        if (activePointerIndex >= 0) {
            ItemTouchHelper.this.checkSelectForSwipe(action, event, activePointerIndex);
        }
        ViewHolder viewHolder = ItemTouchHelper.this.mSelected;
        if (viewHolder != null) {
            switch (action) {
                case 1:
                    break;
                case 2:
                    if (activePointerIndex >= 0) {
                        ItemTouchHelper.this.updateDxDy(event, ItemTouchHelper.this.mSelectedFlags, activePointerIndex);
                        ItemTouchHelper.this.moveIfNecessary(viewHolder);
                        ItemTouchHelper.this.mRecyclerView.removeCallbacks(ItemTouchHelper.this.mScrollRunnable);
                        ItemTouchHelper.this.mScrollRunnable.run();
                        ItemTouchHelper.this.mRecyclerView.invalidate();
                        return;
                    }
                    return;
                case 3:
                    if (ItemTouchHelper.this.mVelocityTracker != null) {
                        ItemTouchHelper.this.mVelocityTracker.clear();
                        break;
                    }
                    break;
                case 6:
                    int pointerIndex = MotionEventCompat.getActionIndex(event);
                    if (MotionEventCompat.getPointerId(event, pointerIndex) == ItemTouchHelper.this.mActivePointerId) {
                        if (pointerIndex == 0) {
                            newPointerIndex = 1;
                        }
                        ItemTouchHelper.this.mActivePointerId = MotionEventCompat.getPointerId(event, newPointerIndex);
                        ItemTouchHelper.this.updateDxDy(event, ItemTouchHelper.this.mSelectedFlags, pointerIndex);
                        return;
                    }
                    return;
                default:
                    return;
            }
            ItemTouchHelper.this.select(null, 0);
            ItemTouchHelper.this.mActivePointerId = -1;
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:53,代码来源:ItemTouchHelper.java

示例15: onSecondaryPointerUp

import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
private void onSecondaryPointerUp(MotionEvent ev) {
    int pointerIndex = MotionEventCompat.getActionIndex(ev);
    if (MotionEventCompat.getPointerId(ev, pointerIndex) == this.mActivePointerId) {
        this.mActivePointerId = MotionEventCompat.getPointerId(ev, pointerIndex == 0 ? 1 : 0);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:7,代码来源:SwipeRefreshLayout.java


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