本文整理汇总了Java中android.support.v4.view.MotionEventCompat.ACTION_POINTER_UP属性的典型用法代码示例。如果您正苦于以下问题:Java MotionEventCompat.ACTION_POINTER_UP属性的具体用法?Java MotionEventCompat.ACTION_POINTER_UP怎么用?Java MotionEventCompat.ACTION_POINTER_UP使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.support.v4.view.MotionEventCompat
的用法示例。
在下文中一共展示了MotionEventCompat.ACTION_POINTER_UP属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: onInterceptTouchEvent
/**
* 监听滑动手势
* @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);
}
示例3: onInterceptTouchEvent
/**
* 在OnTouchEvent事件之前调用
*
* @param ev touch事件
* @return false不拦截,反之拦截
*/
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
findTarget();
final int action = MotionEventCompat.getActionMasked(ev);
if (isBackToStart && action == MotionEvent.ACTION_DOWN)
isBackToStart = false;
switch (mType) {
case BOTTOM:
if (!isEnabled() || isBackToStart || (!mBothType && canChildScrollDown()) || isRefreshing)
return false;
break;
case TOP:
default:
if (!isEnabled() || isBackToStart || (!mBothType && canChildScrollUp()) || isRefreshing)
return false;
break;
}
switch (action) {
case MotionEvent.ACTION_DOWN:
if (InterceptTouchActionDown(ev)) return false;
case MotionEvent.ACTION_MOVE:
if (InterceptTouchActionMove(ev)) return false;
break;
case MotionEventCompat.ACTION_POINTER_UP:
onSecondaryPointerUp(ev);
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
isReady = false;
mActivePointerId = -1;
break;
}
return isReady;
}
示例4: onInterceptTouchEvent
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
ensureTarget();
final int action = MotionEventCompat.getActionMasked(ev);
if (mReturningToStart && action == MotionEvent.ACTION_DOWN) {
mReturningToStart = false;
}
if (!isEnabled() || mReturningToStart || canChildScrollUp() || mRefreshing) {
// Fail fast if we're not in a state where a swipe is possible
return false;
}
switch (action) {
case MotionEvent.ACTION_DOWN:
setTargetOffsetTopAndBottom(mOriginalOffsetTop - mCircleView.getTop(), true);
mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
mIsBeingDragged = false;
final float initialDownY = getMotionEventY(ev, mActivePointerId);
if (initialDownY == -1) {
return false;
}
mInitialDownY = initialDownY;
break;
case MotionEvent.ACTION_MOVE:
if (mActivePointerId == INVALID_POINTER) {
Log.e(LOG_TAG, "Got ACTION_MOVE event but don't have an active pointer id.");
return false;
}
final float y = getMotionEventY(ev, mActivePointerId);
if (y == -1) {
return false;
}
final float yDiff = y - mInitialDownY;
if (yDiff > mTouchSlop && !mIsBeingDragged) {
mInitialMotionY = mInitialDownY + mTouchSlop;
mIsBeingDragged = true;
mProgress.setAlpha(STARTING_PROGRESS_ALPHA);
}
break;
case MotionEventCompat.ACTION_POINTER_UP:
onSecondaryPointerUp(ev);
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
mIsBeingDragged = false;
mActivePointerId = INVALID_POINTER;
break;
}
return mIsBeingDragged;
}
示例5: onInterceptTouchEvent
/**
* 主要判断是否应该拦截子View的事件<br>
* 如果拦截,则交给自己的OnTouchEvent处理<br>
* 否者,交给子View处理<br>
*/
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
ensureTarget();
final int action = MotionEventCompat.getActionMasked(ev);
if (mReturningToStart && action == MotionEvent.ACTION_DOWN) {
mReturningToStart = false;
}
if (!isEnabled() || mReturningToStart || mRefreshing || !isChildScrollToTop()) {
// 如果子View可以滑动,不拦截事件,交给子View处理-下拉刷新
// 或者子View没有滑动到底部不拦截事件-上拉加载更多
return false;
}
// 下拉刷新判断
switch (action) {
case MotionEvent.ACTION_DOWN:
setTargetOffsetTopAndBottom(
mOriginalOffsetTop - mHeadViewContainer.getTop(), true);// 恢复HeaderView的初始位置
mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
mIsBeingDragged = false;
final float initialMotionY = getMotionEventY(ev, mActivePointerId);
if (initialMotionY == -1) {
return false;
}
mInitialMotionY = initialMotionY;// 记录按下的位置
case MotionEvent.ACTION_MOVE:
if (mActivePointerId == INVALID_POINTER) {
return false;
}
final float y = getMotionEventY(ev, mActivePointerId);
if (y == -1) {
return false;
}
float yDiff = y - mInitialMotionY;// 计算下拉距离
if (yDiff > mTouchSlop && !mIsBeingDragged) {// 判断是否下拉的距离足够
mIsBeingDragged = true;// 正在下拉
}
break;
case MotionEventCompat.ACTION_POINTER_UP:
onSecondaryPointerUp(ev);
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
mIsBeingDragged = false;
mActivePointerId = INVALID_POINTER;
break;
}
return mIsBeingDragged;// 如果正在拖动,则拦截子View的事件
}
示例6: onInterceptTouchEvent
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (!allowDrag)
return false;
ensureTarget();
final int action = MotionEventCompat.getActionMasked(ev);
if (mReturningToStart && action == MotionEvent.ACTION_DOWN) {
mReturningToStart = false;
}
final boolean isTop = !canChildScrollUp();
final boolean isBottom = !canChildScrollDown();
if (!isEnabled() || mReturningToStart || (!isTop && !isBottom) || tRefreshing || bRefreshing) {
// Fail fast if we're not in a state where a swipe is possible
return false;
}
switch (action) {
case MotionEvent.ACTION_DOWN:
if (!bOriginalOffsetCalculated) {
bCurrentTargetOffsetTop = bOriginalOffsetTop = getMeasuredHeight();
bOriginalOffsetCalculated = true;
Log.e(TAG, "onLayout>>set bOriginalOffsetTop=" + bOriginalOffsetTop);
}
tIsBeingDragged = false;
bIsBeingDragged = false;
if (isTop) {
setTargetOffsetTopAndBottom(tCircleView, tOriginalOffsetTop - tCircleView.getTop(), true);
} else if (isBottom) {
setTargetOffsetTopAndBottom(bCircleView, bOriginalOffsetTop - bCircleView.getTop(), true);
} else
return false;
mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
final float initialDownY = getMotionEventY(ev, mActivePointerId);
if (initialDownY == -1) {
return false;
}
mInitialDownY = initialDownY;
break;
case MotionEvent.ACTION_MOVE:
if (mActivePointerId == INVALID_POINTER) {
android.util.Log.e(LOG_TAG, "Got ACTION_MOVE event but don't have an active pointer id.");
return false;
}
final float y = getMotionEventY(ev, mActivePointerId);
if (y == -1) {
return false;
}
final float yDiff = y - mInitialDownY;
if (isTop && yDiff > mTouchSlop && !tIsBeingDragged) {
mInitialMotionY = mInitialDownY + mTouchSlop;
tIsBeingDragged = true;
tProgress.setAlpha(STARTING_PROGRESS_ALPHA);
} else if (isBottom && yDiff < 0 && Math.abs(yDiff) > mTouchSlop && !bIsBeingDragged) {
mInitialMotionY = mInitialDownY - mTouchSlop;
bIsBeingDragged = true;
bProgress.setAlpha(STARTING_PROGRESS_ALPHA);
}
break;
case MotionEventCompat.ACTION_POINTER_UP:
onSecondaryPointerUp(ev);
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
tIsBeingDragged = false;
bIsBeingDragged = false;
mActivePointerId = INVALID_POINTER;
break;
}
return tIsBeingDragged || bIsBeingDragged;
}
示例7: onInterceptTouchEvent
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (!allowDrag)
return false;
ensureTarget();
final int action = MotionEventCompat.getActionMasked(ev);
/*if (mReturningToStart && action == MotionEvent.ACTION_DOWN) {
mReturningToStart = false;
}*/
final boolean isTop = !canChildScrollUp();
final boolean isBottom = !canChildScrollDown();
if (!isEnabled() || mReturningToStart || (!isTop && !isBottom) || tRefreshing || bRefreshing) {
// Fail fast if we're not in a state where a swipe is possible
return false;
}
switch (action) {
case MotionEvent.ACTION_DOWN:
if (!bOriginalOffsetCalculated) {
bCurrentTargetOffsetTop = bOriginalOffsetTop = getMeasuredHeight();
bOriginalOffsetCalculated = true;
Log.e(TAG, "onLayout>>set bOriginalOffsetTop=" + bOriginalOffsetTop);
}
tIsBeingDragged = false;
bIsBeingDragged = false;
if (isBottom) {
setTargetOffsetTopAndBottom(bCircleView, bOriginalOffsetTop - bCircleView.getTop(), true);
} else
return false;
mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
final float initialDownY = getMotionEventY(ev, mActivePointerId);
if (initialDownY == -1) {
return false;
}
mInitialDownY = initialDownY;
break;
case MotionEvent.ACTION_MOVE:
if (mActivePointerId == INVALID_POINTER) {
android.util.Log.e(LOG_TAG, "Got ACTION_MOVE event but don't have an active pointer id.");
return false;
}
final float y = getMotionEventY(ev, mActivePointerId);
if (y == -1) {
return false;
}
final float yDiff = y - mInitialDownY;
if (isBottom && yDiff < 0 && Math.abs(yDiff) > mTouchSlop && !bIsBeingDragged) {
mInitialMotionY = mInitialDownY - mTouchSlop;
bIsBeingDragged = true;
bProgress.setAlpha(STARTING_PROGRESS_ALPHA);
}
break;
case MotionEventCompat.ACTION_POINTER_UP:
onSecondaryPointerUp(ev);
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
tIsBeingDragged = false;
bIsBeingDragged = false;
mActivePointerId = INVALID_POINTER;
break;
}
return tIsBeingDragged || bIsBeingDragged;
}
示例8: onInterceptTouchEvent
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
ensureTargetView();
final int action = MotionEventCompat.getActionMasked(ev);
int pointerIndex;
if (!isEnabled() || canChildScrollUp() || mNestedScrollInProgress) {
Log.d(TAG, "fast end onIntercept: isEnabled = " + isEnabled() + "; canChildScrollUp = "
+ canChildScrollUp() + " ; mNestedScrollInProgress = " + mNestedScrollInProgress);
return false;
}
switch (action) {
case MotionEvent.ACTION_DOWN:
mIsDragging = false;
mActivePointerId = ev.getPointerId(0);
pointerIndex = ev.findPointerIndex(mActivePointerId);
if (pointerIndex < 0) {
return false;
}
mInitialDownX = ev.getX(pointerIndex);
mInitialDownY = ev.getY(pointerIndex);
break;
case MotionEvent.ACTION_MOVE:
pointerIndex = ev.findPointerIndex(mActivePointerId);
if (pointerIndex < 0) {
Log.e(TAG, "Got ACTION_MOVE event but have an invalid active pointer id.");
return false;
}
final float x = ev.getX(pointerIndex);
final float y = ev.getY(pointerIndex);
startDragging(x, y);
break;
case MotionEventCompat.ACTION_POINTER_UP:
onSecondaryPointerUp(ev);
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
mIsDragging = false;
mActivePointerId = INVALID_POINTER;
break;
}
return mIsDragging;
}
示例9: onInterceptTouchEvent
/**
* 主要判断是否应该拦截子View的事件<br>
* 如果拦截,则交给自己的OnTouchEvent处理<br>
* 否者,交给子View处理<br>
*/
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
ensureTarget();
final int action = MotionEventCompat.getActionMasked(ev);
if (mReturningToStart && action == MotionEvent.ACTION_DOWN) {
mReturningToStart = false;
}
if (!isEnabled() || mReturningToStart || mRefreshing || mLoadMore
|| (!isChildScrollToTop() && !isChildScrollToBottom())) {
// 如果子View可以滑动,不拦截事件,交给子View处理-下拉刷新
// 或者子View没有滑动到底部不拦截事件-上拉加载更多
return false;
}
// 下拉刷新判断
switch (action) {
case MotionEvent.ACTION_DOWN:
setTargetOffsetTopAndBottom(
mOriginalOffsetTop - mHeadViewContainer.getTop(), true);// 恢复HeaderView的初始位置
mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
mIsBeingDragged = false;
final float initialMotionY = getMotionEventY(ev, mActivePointerId);
if (initialMotionY == -1) {
return false;
}
mInitialMotionY = initialMotionY;// 记录按下的位置
case MotionEvent.ACTION_MOVE:
if (mActivePointerId == INVALID_POINTER) {
Log.e(LOG_TAG, "Got ACTION_MOVE event but don't have an active pointer id.");
return false;
}
final float y = getMotionEventY(ev, mActivePointerId);
if (y == -1) {
return false;
}
float yDiff = 0;
if (isChildScrollToBottom()) {
yDiff = mInitialMotionY - y;// 计算上拉距离
if (yDiff > mTouchSlop && !mIsBeingDragged) {// 判断是否下拉的距离足够
mIsBeingDragged = true;// 正在上拉
}
} else {
yDiff = y - mInitialMotionY;// 计算下拉距离
if (yDiff > mTouchSlop && !mIsBeingDragged) {// 判断是否下拉的距离足够
mIsBeingDragged = true;// 正在下拉
}
}
break;
case MotionEventCompat.ACTION_POINTER_UP:
onSecondaryPointerUp(ev);
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
mIsBeingDragged = false;
mActivePointerId = INVALID_POINTER;
break;
}
return mIsBeingDragged;// 如果正在拖动,则拦截子View的事件
}
示例10: onInterceptTouchEvent
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (!isEnabled() || (canChildScrollUp() && !mRefreshing)) {
return false;
}
final int action = MotionEventCompat.getActionMasked(ev);
switch (action) {
case MotionEvent.ACTION_DOWN:
if (!mRefreshing) {
setTargetOffsetTop(0);
}
mActivePointerId = ev.getPointerId(0);
mIsBeingDragged = false;
final float initialMotionY = getMotionEventY(ev, mActivePointerId);
if (initialMotionY == -1) {
return false;
}
mInitialMotionY = initialMotionY;
mInitialOffsetTop = mCurrentOffsetTop;
mDispatchTargetTouchDown = false;
mDragPercent = 0;
break;
case MotionEvent.ACTION_MOVE:
if (mActivePointerId == INVALID_POINTER) {
return false;
}
final float y = getMotionEventY(ev, mActivePointerId);
if (y == -1) {
return false;
}
final float yDiff = y - mInitialMotionY;
if (mRefreshing) {
mIsBeingDragged = !(yDiff < 0 && mCurrentOffsetTop <= 0);
} else if (yDiff > mTouchSlop && !mIsBeingDragged) {
mIsBeingDragged = true;
}
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
mIsBeingDragged = false;
mActivePointerId = INVALID_POINTER;
break;
case MotionEventCompat.ACTION_POINTER_UP:
onSecondaryPointerUp(ev);
break;
}
return mIsBeingDragged;
}
示例11: onInterceptTouchEvent
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (!mEnabled)
return false;
final int action = ev.getAction() & MotionEventCompat.ACTION_MASK;
if (DEBUG)
if (action == MotionEvent.ACTION_DOWN)
Log.v(TAG, "Received ACTION_DOWN");
if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP
|| (action != MotionEvent.ACTION_DOWN && mIsUnableToDrag)) {
endDrag();
return false;
}
switch (action) {
case MotionEvent.ACTION_MOVE:
determineDrag(ev);
break;
case MotionEvent.ACTION_DOWN:
int index = MotionEventCompat.getActionIndex(ev);
mActivePointerId = MotionEventCompat.getPointerId(ev, index);
if (mActivePointerId == INVALID_POINTER)
break;
mLastMotionX = mInitialMotionX = MotionEventCompat.getX(ev, index);
mLastMotionY = MotionEventCompat.getY(ev, index);
if (thisTouchAllowed(ev)) {
mIsBeingDragged = false;
mIsUnableToDrag = false;
if (isMenuOpen() && mViewBehind.menuTouchInQuickReturn(mContent, mCurItem, ev.getX() + mScrollX)) {
mQuickReturn = true;
}
} else {
mIsUnableToDrag = true;
}
break;
case MotionEventCompat.ACTION_POINTER_UP:
onSecondaryPointerUp(ev);
break;
}
if (!mIsBeingDragged) {
if (mVelocityTracker == null) {
mVelocityTracker = VelocityTracker.obtain();
}
mVelocityTracker.addMovement(ev);
}
return mIsBeingDragged || mQuickReturn;
}
示例12: onInterceptTouchEvent
@Override
public boolean onInterceptTouchEvent(MotionEvent ev)
{
if (!mEnabled)
{
return false;
}
final int action = ev.getAction() & MotionEventCompat.ACTION_MASK;
if (DEBUG)
{
if (action == MotionEvent.ACTION_DOWN)
{
Log.v(TAG, "Received ACTION_DOWN");
}
}
if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP
|| (action != MotionEvent.ACTION_DOWN && mIsUnableToDrag))
{
endDrag();
return false;
}
switch (action)
{
case MotionEvent.ACTION_MOVE:
determineDrag(ev);
break;
case MotionEvent.ACTION_DOWN:
int index = MotionEventCompat.getActionIndex(ev);
mActivePointerId = MotionEventCompat.getPointerId(ev, index);
if (mActivePointerId == INVALID_POINTER)
{
break;
}
mLastMotionX = mInitialMotionX = MotionEventCompat.getX(ev, index);
mLastMotionY = MotionEventCompat.getY(ev, index);
if (thisTouchAllowed(ev))
{
mIsBeingDragged = false;
mIsUnableToDrag = false;
if (isMenuOpen() && mViewBehind.menuTouchInQuickReturn(mContent, mCurItem, ev.getX() + mScrollX))
{
mQuickReturn = true;
}
}
else
{
mIsUnableToDrag = true;
}
break;
case MotionEventCompat.ACTION_POINTER_UP:
onSecondaryPointerUp(ev);
break;
}
if (!mIsBeingDragged)
{
if (mVelocityTracker == null)
{
mVelocityTracker = VelocityTracker.obtain();
}
mVelocityTracker.addMovement(ev);
}
return mIsBeingDragged || mQuickReturn;
}
示例13: onInterceptTouchEvent
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (!mEnabled)
return false;
final int action = ev.getAction() & MotionEventCompat.ACTION_MASK;
if (DEBUG)
if (action == MotionEvent.ACTION_DOWN)
Log.v(TAG, "Received ACTION_DOWN");
if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP
|| (action != MotionEvent.ACTION_DOWN && mIsUnableToDrag)) {
endDrag();
return false;
}
switch (action) {
case MotionEvent.ACTION_MOVE:
determineDrag(ev);
break;
case MotionEvent.ACTION_DOWN:
int index = MotionEventCompat.getActionIndex(ev);
mActivePointerId = MotionEventCompat.getPointerId(ev, index);
if (mActivePointerId == INVALID_POINTER)
break;
mLastMotionX = mInitialMotionX = MotionEventCompat.getX(ev, index);
mLastMotionY = MotionEventCompat.getY(ev, index);
if (thisTouchAllowed(ev)) {
mIsBeingDragged = false;
mIsUnableToDrag = false;
if (isMenuOpen() && mViewBehind.menuTouchInQuickReturn(mContent, mCurItem, ev.getX() + mScrollX)) {
mQuickReturn = true;
}
} else {
mIsUnableToDrag = true;
}
break;
case MotionEventCompat.ACTION_POINTER_UP:
onSecondaryPointerUp(ev);
break;
}
if (!mIsBeingDragged) {
if (mVelocityTracker == null) {
mVelocityTracker = VelocityTracker.obtain();
}
mVelocityTracker.addMovement(ev);
}
return mIsBeingDragged || mQuickReturn;
}
示例14: onInterceptTouchEvent
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
ensureTarget();
final int action = MotionEventCompat.getActionMasked(ev);
int pointerIndex;
if (mReturningToStart && action == MotionEvent.ACTION_DOWN) {
mReturningToStart = false;
}
if (!isEnabled() || mReturningToStart || canChildScrollUp()
|| mRefreshing || mNestedScrollInProgress) {
// Fail fast if we're not in a state where a swipe is possible
return false;
}
switch (action) {
case MotionEvent.ACTION_DOWN:
setTargetOffsetTopAndBottom(mOriginalOffsetTop - mCircleView.getTop(), true);
mActivePointerId = ev.getPointerId(0);
mIsBeingDragged = false;
pointerIndex = ev.findPointerIndex(mActivePointerId);
if (pointerIndex < 0) {
return false;
}
mInitialDownY = ev.getY(pointerIndex);
break;
case MotionEvent.ACTION_MOVE:
if (mActivePointerId == INVALID_POINTER) {
Log.e(LOG_TAG, "Got ACTION_MOVE event but don't have an active pointer id.");
return false;
}
pointerIndex = ev.findPointerIndex(mActivePointerId);
if (pointerIndex < 0) {
return false;
}
final float y = ev.getY(pointerIndex);
startDragging(y);
break;
case MotionEventCompat.ACTION_POINTER_UP:
onSecondaryPointerUp(ev);
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
mIsBeingDragged = false;
mActivePointerId = INVALID_POINTER;
break;
}
return mIsBeingDragged;
}
示例15: onInterceptTouchEvent
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (mRefreshView == null) {
return false;
}
Log.d(TAG, "onInterceptTouchEvent: "+ev.toString());
final int action = MotionEventCompat.getActionMasked(ev);
if (mReturningToStart && action == MotionEvent.ACTION_DOWN) {
// Fail fast if we're not in a state where a swipe is possible
mReturningToStart = false;
}
if (!isEnabled() || canChildScrollUp() || mReturningToStart || mRefreshing) {// 不拦截(禁止掉了 || 刷新中 )
return false;
}
switch (ev.getAction()){
case MotionEvent.ACTION_DOWN:
mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
mIsBeingDragged = false;
final float initialDownY = getMotionEventY(ev, mActivePointerId);
if (initialDownY == -1) {//如果没有有效点击,就往下传递
return false;
}
mInitialDownY = initialDownY;
mIsInterceptedMoveEvent = false;
break;
case MotionEvent.ACTION_MOVE:
if (mActivePointerId == INVALID_POINTER) {
Log.e(TAG, "Got ACTION_MOVE event but don't have an active pointer id.");
return false;
}
final float y = getMotionEventY(ev, mActivePointerId);
if (y == -1) {
return false;
}
mIsInterceptedMoveEvent = true;
determineUserWhetherBeingDragged(y);
break;
case MotionEventCompat.ACTION_POINTER_UP:
onSecondaryPointerUp(ev);
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
mIsBeingDragged = false;
mActivePointerId = INVALID_POINTER;
break;
}
return mIsBeingDragged;
}