本文整理汇总了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;
}
示例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();
}
}
}
示例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);
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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();
}
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
}
}
示例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);
}
}