本文整理汇总了Java中android.support.v4.view.MotionEventCompat.getActionMasked方法的典型用法代码示例。如果您正苦于以下问题:Java MotionEventCompat.getActionMasked方法的具体用法?Java MotionEventCompat.getActionMasked怎么用?Java MotionEventCompat.getActionMasked使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.view.MotionEventCompat
的用法示例。
在下文中一共展示了MotionEventCompat.getActionMasked方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onTouchEvent
import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
@Override
public void onTouchEvent(RecyclerView rv, MotionEvent e)
{
if (!mIsActive)
return;
int action = MotionEventCompat.getActionMasked(e);
switch (action)
{
case MotionEvent.ACTION_MOVE:
if (!mInTopSpot && !mInBottomSpot)
updateSelectedRange(rv, e);
processAutoScroll(e);
break;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_POINTER_UP:
reset();
break;
}
}
示例2: onInterceptTouchEvent
import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
@Override
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
if (!mIsActive || rv.getAdapter().getItemCount() == 0)
return false;
int action = MotionEventCompat.getActionMasked(e);
switch (action) {
case MotionEvent.ACTION_POINTER_DOWN:
case MotionEvent.ACTION_DOWN:
reset();
break;
case MotionEvent.ACTION_UP:
if (mSelectListener != null) {
mSelectListener.onItemLongClickUp();
}
}
mRecyclerView = rv;
int height = rv.getHeight();
mTopBoundFrom = 0 + mTouchRegionTopOffset;
mTopBoundTo = 0 + mTouchRegionTopOffset + mAutoScrollDistance;
mBottomBoundFrom = height + mTouchRegionBottomOffset - mAutoScrollDistance;
mBottomBoundTo = height + mTouchRegionBottomOffset;
return true;
}
示例3: onTouchEvent
import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
public boolean onTouchEvent(CoordinatorLayout parent, V child, MotionEvent event) {
if (!child.isShown()) {
return false;
}
int action = MotionEventCompat.getActionMasked(event);
if (this.mState == 1 && action == 0) {
return true;
}
this.mViewDragHelper.processTouchEvent(event);
if (action == 0) {
reset();
}
if (this.mVelocityTracker == null) {
this.mVelocityTracker = VelocityTracker.obtain();
}
this.mVelocityTracker.addMovement(event);
if (action != 2 || Math.abs(((float) this.mInitialY) - event.getY()) <= ((float) this.mViewDragHelper.getTouchSlop())) {
return true;
}
this.mViewDragHelper.captureChildView(child, event.getPointerId(event.getActionIndex()));
return true;
}
示例4: 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_VIEW_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;
}
示例5: dispatchTouchEvent
import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
final int action = MotionEventCompat.getActionMasked(ev);
switch (action) {
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
// swipeToRefresh -> finger up -> finger down if the status is still swipeToRefresh
// in onInterceptTouchEvent ACTION_DOWN event will stop the scroller
// if the event pass to the child view while ACTION_MOVE(condition is false)
// in onInterceptTouchEvent ACTION_MOVE the ACTION_UP or ACTION_CANCEL will not be
// passed to onInterceptTouchEvent and onTouchEvent. Instead It will be passed to
// child view's onTouchEvent. So we must deal this situation in dispatchTouchEvent
onActivePointerUp();
break;
}
return super.dispatchTouchEvent(ev);
}
示例6: onTouchEvent
import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
public boolean onTouchEvent(MotionEvent ev) {
int action = MotionEventCompat.getActionMasked(ev);
if (action == 0) {
this.mEatingTouch = false;
}
if (!this.mEatingTouch) {
boolean handled = super.onTouchEvent(ev);
if (action == 0 && !handled) {
this.mEatingTouch = true;
}
}
if (action == 1 || action == 3) {
this.mEatingTouch = false;
}
return true;
}
示例7: setToggleDragOnLongPress
import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
/**
* Set the drag event should be trigger on long press.
* Work when the toggleViewId has been set.
*
* @param longPress by default is true.
*/
public void setToggleDragOnLongPress(boolean longPress) {
mDragOnLongPress = longPress;
if (mDragOnLongPress) {
mOnToggleViewTouchListener = null;
mOnToggleViewLongClickListener = new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
if (mItemTouchHelper != null && itemDragEnabled) {
mItemTouchHelper.startDrag((RecyclerView.ViewHolder) v.getTag(R.id.BaseQuickAdapter_viewholder_support));
}
return true;
}
};
} else {
mOnToggleViewTouchListener = new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN
&& !mDragOnLongPress) {
if (mItemTouchHelper != null && itemDragEnabled) {
mItemTouchHelper.startDrag((RecyclerView.ViewHolder) v.getTag(R.id.BaseQuickAdapter_viewholder_support));
}
return true;
} else {
return false;
}
}
};
mOnToggleViewLongClickListener = null;
}
}
示例8: onTouchEvent
import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent event) {
if (!isEnabled()) {
return false;
}
int actionMasked = MotionEventCompat.getActionMasked(event);
switch (actionMasked) {
case MotionEvent.ACTION_DOWN:
mDownX = event.getX();
startDragging(event, isInScrollingContainer());
break;
case MotionEvent.ACTION_MOVE:
if (isDragging()) {
updateDragging(event);
} else {
final float x = event.getX();
if (Math.abs(x - mDownX) > mTouchSlop) {
startDragging(event, false);
}
}
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
stopDragging();
break;
}
return true;
}
示例9: onTouchEvent
import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent event) {
final int action = MotionEventCompat.getActionMasked(event);
switch (action) {
case MotionEvent.ACTION_MOVE:
int moveX = (int) event.getRawX();
if (moveX > mInitX && isSliding) {
mParentView.scrollBy(mTempX - moveX, 0);
if (window != null) {
int pre = (int) ((((float) moveX / (float) mViewWidth) * 153f) + 102f);
backDrawable.setAlpha(255 - pre);
window.setBackgroundDrawable(backDrawable);
}
} else if (moveX < mInitX) {
mParentView.scrollTo(0, 0);
}
mTempX = moveX;
break;
case MotionEvent.ACTION_UP:
isSliding = false;
if (mParentView.getScrollX() <= -mViewWidth / 2) {
isFinish = true;
scrollToRight();
} else {
isFinish = false;
scrollToOrigin();
}
break;
}
return true;
}
示例10: onInterceptTouchEvent
import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
final int action = MotionEventCompat.getActionMasked(ev);
switch (action) {
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP: {
mViewDragHelper.cancel();
return false;
}
}
return mViewDragHelper.shouldInterceptTouchEvent(ev);
}
示例11: onInterceptTouchEvent
import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
public boolean onInterceptTouchEvent(MotionEvent event) {
int action = MotionEventCompat.getActionMasked(event);
float x = event.getRawX();
float y = event.getRawY();
// Always take care of the touch gesture being complete.
if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) {
// Release the drag.
reset(initialMotionX, initialMotionY);
return false;
}
if (action != MotionEvent.ACTION_DOWN) {
if (isBeingDragged) {
return true;
}
}
switch (action) {
case MotionEvent.ACTION_DOWN:
initialMotionX = lastMotionX = x;
initialMotionY = lastMotionY = y;
break;
case MotionEvent.ACTION_MOVE:
final float xDiff = Math.abs(x - initialMotionX);
final float yDiff = Math.abs(y - initialMotionY);
if (xDiff > touchSlop && xDiff > yDiff) {
isBeingDragged = true;
//direction horizon
direction = DIRECTION_LEFT_RIGHT;
} else if (yDiff > touchSlop && yDiff > xDiff) {
isBeingDragged = true;
//direction vertical
direction = DIRECTION_TOP_BOTTOM;
}
break;
}
return isBeingDragged;
}
示例12: 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);
}
示例13: onTouchEvent
import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent ev) {
switch (MotionEventCompat.getActionMasked(ev)) {
case MotionEvent.ACTION_DOWN:
getParent().requestDisallowInterceptTouchEvent(true);
stopAutoScroll();
break;
case MotionEvent.ACTION_UP:
getParent().requestDisallowInterceptTouchEvent(false);
startAutoScroll();
break;
}
return super.onTouchEvent(ev);
}
示例14: onTouchForwarded
import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
private boolean onTouchForwarded(MotionEvent srcEvent) {
boolean z = true;
View src = this.mSrc;
ListPopupWindow popup = getPopup();
if (popup == null || !popup.isShowing()) {
return false;
}
DropDownListView dst = popup.mDropDownList;
if (dst == null || !dst.isShown()) {
return false;
}
MotionEvent dstEvent = MotionEvent.obtainNoHistory(srcEvent);
toGlobalMotionEvent(src, dstEvent);
toLocalMotionEvent(dst, dstEvent);
boolean handled = dst.onForwardedEvent(dstEvent, this.mActivePointerId);
dstEvent.recycle();
int action = MotionEventCompat.getActionMasked(srcEvent);
boolean keepForwarding;
if (action == 1 || action == 3) {
keepForwarding = false;
} else {
keepForwarding = true;
}
if (!(handled && keepForwarding)) {
z = false;
}
return z;
}
示例15: onTouchEvent
import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent event) {
if (!isEnabled()) {
return super.onTouchEvent(event);
}
int action = MotionEventCompat.getActionMasked(event);
float eventX = event.getX();
//L.e("call: onTouchEvent([event])-> " + action + " x:" + eventX);
switch (action) {
case MotionEvent.ACTION_DOWN:
//L.e("call: onTouchEvent([event])-> DOWN:" + " x:" + eventX);
isTouchDown = true;
notifyListenerStartTouch();
calcProgress(eventX);
getParent().requestDisallowInterceptTouchEvent(true);
break;
case MotionEvent.ACTION_MOVE:
calcProgress(eventX);
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
isTouchDown = false;
notifyListenerStopTouch();
getParent().requestDisallowInterceptTouchEvent(false);
break;
}
return true;
}