本文整理汇总了Java中android.support.v4.view.MotionEventCompat.getPointerId方法的典型用法代码示例。如果您正苦于以下问题:Java MotionEventCompat.getPointerId方法的具体用法?Java MotionEventCompat.getPointerId怎么用?Java MotionEventCompat.getPointerId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.view.MotionEventCompat
的用法示例。
在下文中一共展示了MotionEventCompat.getPointerId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onSecondaryPointerUp
import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
private void onSecondaryPointerUp(MotionEvent ev)
{
if (DEBUG)
{
Log.v(TAG, "onSecondaryPointerUp called");
}
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();
}
}
}
示例2: onTouchEvent
import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent event) {
mDragHelper.processTouchEvent(event);
final int action = event.getActionMasked();
switch (action) {
case MotionEvent.ACTION_DOWN:
break;
case MotionEvent.ACTION_UP:
mLastMotionY = 0;
bDraging = false;
bScrollDown = false;
rainbowRotateAngle = 0;
break;
case MotionEvent.ACTION_MOVE:
int index = MotionEventCompat.getActionIndex(event);
int pointerId = MotionEventCompat.getPointerId(event, index);
if (shouldIntercept()) {
mDragHelper.captureChildView(mContentView, pointerId);
}
break;
}
return true;
}
示例3: 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;
}
示例4: 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);
}
}
示例5: 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;
}
示例6: onTouchEvent
import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
/**
* Override method to dispatch touch event to the dragged view.
*
* @param ev captured.
* @return true if the touch event is realized over the drag or second view.
*/
@Override
public boolean onTouchEvent(MotionEvent ev)
{
int actionMasked = MotionEventCompat.getActionMasked(ev);
if ((actionMasked & MotionEventCompat.ACTION_MASK) == MotionEvent.ACTION_DOWN)
{
activePointerId = MotionEventCompat.getPointerId(ev, actionMasked);
}
if (activePointerId == INVALID_POINTER)
{
return false;
}
viewDragHelper.processTouchEvent(ev);
if (isClosed())
{
return false;
}
boolean isDragViewHit = isViewHit(dragView, (int) ev.getX(), (int) ev.getY());
boolean isSecondViewHit = isViewHit(secondView, (int) ev.getX(), (int) ev.getY());
analyzeTouchToMaximizeIfNeeded(ev, isDragViewHit);
if (isMaximized())
{
dragView.dispatchTouchEvent(ev);
}
else
{
dragView.dispatchTouchEvent(cloneMotionEventWithAction(ev, MotionEvent.ACTION_CANCEL));
}
return isDragViewHit || isSecondViewHit;
}
示例7: onInterceptTouchEvent
import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
/**
* 监听滑动手势
* @param e
* @return
*/
@Override
public boolean onInterceptTouchEvent(MotionEvent e) {
final int action = MotionEventCompat.getActionMasked(e);
final int actionIndex = MotionEventCompat.getActionIndex(e);
switch (action) {
case MotionEvent.ACTION_DOWN: {
mActivePointerId = MotionEventCompat.getPointerId(e, 0);
mLastTouchX = (int) (MotionEventCompat.getX(e, actionIndex) + 0.5f);
mLastTouchY = (int) (MotionEventCompat.getY(e, actionIndex) + 0.5f);
}
break;
case MotionEvent.ACTION_POINTER_DOWN: {
mActivePointerId = MotionEventCompat.getPointerId(e, actionIndex);
mLastTouchX = (int) (MotionEventCompat.getX(e, actionIndex) + 0.5f);
mLastTouchY = (int) (MotionEventCompat.getY(e, actionIndex) + 0.5f);
}
break;
case MotionEventCompat.ACTION_POINTER_UP: {
onPointerUp(e);
}
break;
}
return super.onInterceptTouchEvent(e);
}
示例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;
mLastMotionX = MotionEventCompat.getX(ev, newPointerIndex);
mActivePointerId = MotionEventCompat.getPointerId(ev, newPointerIndex);
if (mVelocityTracker != null) {
mVelocityTracker.clear();
}
}
}
示例9: 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);
}
}
示例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) {
final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
mActivePointerId = MotionEventCompat.getPointerId(ev, newPointerIndex);
}
}
示例11: onSecondaryPointerUp
import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
private void onSecondaryPointerUp(MotionEvent ev) {
if (DEBUG) Log.v(TAG, "onSecondaryPointerUp called");
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();
}
}
}
示例12: 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;
}
}
}
示例13: checkSelectForSwipe
import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
private boolean checkSelectForSwipe(int action, MotionEvent motionEvent, int pointerIndex) {
if (this.mSelected != null || action != 2 || this.mActionState == 2 || !this.mCallback.isItemViewSwipeEnabled()) {
return false;
}
if (this.mRecyclerView.getScrollState() == 1) {
return false;
}
ViewHolder vh = findSwipedView(motionEvent);
if (vh == null) {
return false;
}
int swipeFlags = (65280 & this.mCallback.getAbsoluteMovementFlags(this.mRecyclerView, vh)) >> 8;
if (swipeFlags == 0) {
return false;
}
float x = MotionEventCompat.getX(motionEvent, pointerIndex);
float dx = x - this.mInitialTouchX;
float dy = MotionEventCompat.getY(motionEvent, pointerIndex) - this.mInitialTouchY;
float absDx = Math.abs(dx);
float absDy = Math.abs(dy);
if (absDx < ((float) this.mSlop) && absDy < ((float) this.mSlop)) {
return false;
}
if (absDx > absDy) {
if (dx < 0.0f && (swipeFlags & 4) == 0) {
return false;
}
if (dx > 0.0f && (swipeFlags & 8) == 0) {
return false;
}
} else if (dy < 0.0f && (swipeFlags & 1) == 0) {
return false;
} else {
if (dy > 0.0f && (swipeFlags & 2) == 0) {
return false;
}
}
this.mDy = 0.0f;
this.mDx = 0.0f;
this.mActivePointerId = MotionEventCompat.getPointerId(motionEvent, 0);
select(vh, 1);
return true;
}
示例14: onTouchEvent
import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
public boolean onTouchEvent(MotionEvent ev) {
int action = MotionEventCompat.getActionMasked(ev);
if (this.mReturningToStart && action == 0) {
this.mReturningToStart = false;
}
if (!isEnabled() || this.mReturningToStart || canChildScrollUp() || this.mNestedScrollInProgress) {
return false;
}
int pointerIndex;
float overscrollTop;
switch (action) {
case 0:
this.mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
this.mIsBeingDragged = false;
break;
case 1:
pointerIndex = MotionEventCompat.findPointerIndex(ev, this.mActivePointerId);
if (pointerIndex < 0) {
Log.e(LOG_TAG, "Got ACTION_UP event but don't have an active pointer id.");
return false;
}
overscrollTop = (MotionEventCompat.getY(ev, pointerIndex) - this.mInitialMotionY) * DRAG_RATE;
this.mIsBeingDragged = false;
finishSpinner(overscrollTop);
this.mActivePointerId = -1;
return false;
case 2:
pointerIndex = MotionEventCompat.findPointerIndex(ev, this.mActivePointerId);
if (pointerIndex < 0) {
Log.e(LOG_TAG, "Got ACTION_MOVE event but have an invalid active pointer id.");
return false;
}
overscrollTop = (MotionEventCompat.getY(ev, pointerIndex) - this.mInitialMotionY) * DRAG_RATE;
if (this.mIsBeingDragged) {
if (overscrollTop > 0.0f) {
moveSpinner(overscrollTop);
break;
}
return false;
}
break;
case 3:
return false;
case 5:
pointerIndex = MotionEventCompat.getActionIndex(ev);
if (pointerIndex >= 0) {
this.mActivePointerId = MotionEventCompat.getPointerId(ev, pointerIndex);
break;
}
Log.e(LOG_TAG, "Got ACTION_POINTER_DOWN event but have an invalid action index.");
return false;
case 6:
onSecondaryPointerUp(ev);
break;
}
return true;
}
示例15: 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;
float leftThird = halfWidth - sixthWidth;
float rightThird = halfWidth + sixthWidth;
float eventX = ev.getX();
if (eventX < leftThird) {
if (this.mCurrentPage > 0) {
if (action != 3) {
this.mViewPager.setCurrentItem(this.mCurrentPage - 1);
}
return true;
}
} else if (eventX > rightThird) {
if (this.mCurrentPage < count - 1) {
if (action != 3) {
this.mViewPager.setCurrentItem(this.mCurrentPage + 1);
}
return true;
}
} else if (!(this.mCenterItemClickListener == null || action == 3)) {
this.mCenterItemClickListener.onCenterItemClick(this.mCurrentPage);
}
}
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;
}