本文整理匯總了Java中android.support.v4.view.GestureDetectorCompat.onTouchEvent方法的典型用法代碼示例。如果您正苦於以下問題:Java GestureDetectorCompat.onTouchEvent方法的具體用法?Java GestureDetectorCompat.onTouchEvent怎麽用?Java GestureDetectorCompat.onTouchEvent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v4.view.GestureDetectorCompat
的用法示例。
在下文中一共展示了GestureDetectorCompat.onTouchEvent方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onInterceptTouchEvent
import android.support.v4.view.GestureDetectorCompat; //導入方法依賴的package包/類
@Override
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
if (recyclerView == null) {
this.recyclerView = rv;
this.baseQuickAdapter = (BaseQuickAdapter) recyclerView.getAdapter();
mGestureDetector = new GestureDetectorCompat(recyclerView.getContext(), new ItemTouchHelperGestureListener(recyclerView));
}
if (!mGestureDetector.onTouchEvent(e) && e.getActionMasked() == MotionEvent.ACTION_UP && mIsShowPress) {
if (mPressedView!=null){
mPressedView.setPressed(false);
mPressedView = null;
}
mIsShowPress = false;
mIsPrepressed = false;
}
return false;
}
示例2: PendingDrag
import android.support.v4.view.GestureDetectorCompat; //導入方法依賴的package包/類
/**
* Constructs a new PendingDrag that, if accepted by the DragHandler, begins with the
* {@code actionDown} event.
*
* @param controller The activity's {@link BlocklyController}.
* @param touchedView The initial touched {@link BlockView} of the drag.
* @param actionDown The first {@link MotionEvent#ACTION_DOWN} event.
*/
PendingDrag(@NonNull BlocklyController controller,
@NonNull BlockView touchedView, @NonNull MotionEvent actionDown) {
if (actionDown.getAction() != MotionEvent.ACTION_DOWN) {
throw new IllegalArgumentException();
}
mController = controller;
mHelper = controller.getWorkspaceHelper();
mLatestEventTime = actionDown.getEventTime();
mTouchedView = touchedView;
mPointerId = actionDown.getPointerId(actionDown.getActionIndex());
int pointerIdx = actionDown.findPointerIndex(mPointerId);
mTouchDownBlockX = (int) actionDown.getX(pointerIdx);
mTouchDownBlockY = (int) actionDown.getY(pointerIdx);
touchedView.getTouchLocationOnScreen(actionDown, mTouchDownScreen);
mHelper.screenToWorkspaceCoordinates(mTouchDownScreen, mTouchDownWorkspace);
mGestureDetector = new GestureDetectorCompat(mController.getContext(),
new GestureListener());
mGestureDetector.onTouchEvent(actionDown);
}
示例3: onInterceptTouchEvent
import android.support.v4.view.GestureDetectorCompat; //導入方法依賴的package包/類
@Override
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
if (!shouldDetectGesture()) {
return false; // 攔截手勢檢測
}
// 手勢檢測
if (recyclerView == null) {
this.recyclerView = rv;
this.baseAdapter = (T) recyclerView.getAdapter();
mGestureDetector = new GestureDetectorCompat(recyclerView.getContext(), new ItemTouchHelperGestureListener(recyclerView));
}
if (!mGestureDetector.onTouchEvent(e) && e.getActionMasked() == MotionEvent.ACTION_UP && mIsShowPress) {
if (mPressedView != null) {
BaseViewHolder vh = (BaseViewHolder) recyclerView.getChildViewHolder(mPressedView);
if (vh == null || vh.getItemViewType() != IRecyclerView.LOADING_VIEW || vh.getItemViewType() != FETCHING_VIEW) {
mPressedView.setPressed(false);
}
mPressedView = null;
}
mIsShowPress = false;
mIsPrepressed = false;
}
return false;
}
示例4: processRawEvent
import android.support.v4.view.GestureDetectorCompat; //導入方法依賴的package包/類
public void processRawEvent(GestureDetectorCompat mDetector, MotionEvent e) {
// record the touches
setTouches(e);
if (edgesTouched == 0 && e.getAction() == MotionEvent.ACTION_DOWN) {
edgesTouched = getEdgesTouched((int) e.getX(), (int) e.getY());
if (edgesTouched != 0) {
log.debug("Edges Touched: {}", edgesTouched);
}
}
mDetector.onTouchEvent(e);
if (touchFocusEnabled) {
if (e.getAction() == MotionEvent.ACTION_MOVE) {
if (logTouch) log.debug("onMouseMove: {},{}", X(e), Y(e));
client.getCurrentConnection().postMouseEvent(new MouseEvent(this, MouseEvent.MOUSE_MOVED, System.currentTimeMillis(), 0, X(e), Y(e), 0, 0, 0));
}
}
if (edgesTouched != 0 && (e.getAction() == MotionEvent.ACTION_UP || e.getAction() == MotionEvent.ACTION_POINTER_UP)) {
log.debug("Clearing Touched Edges");
edgesTouched = 0;
}
}
示例5: onInterceptTouchEvent
import android.support.v4.view.GestureDetectorCompat; //導入方法依賴的package包/類
@Override
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
if (!shouldDetectGesture()) {
return false; // 攔截手勢檢測
}
// 手勢檢測
if (recyclerView == null) {
this.recyclerView = rv;
this.baseAdapter = (T) recyclerView.getAdapter();
mGestureDetector = new GestureDetectorCompat(recyclerView.getContext(), new ItemTouchHelperGestureListener(recyclerView));
}
if (!mGestureDetector.onTouchEvent(e) && e.getActionMasked() == MotionEvent.ACTION_UP && mIsShowPress) {
if (mPressedView != null) {
BaseViewHolder vh = (BaseViewHolder) recyclerView.getChildViewHolder(mPressedView);
if (vh == null || vh.getItemViewType() != IRecyclerView.LOADING_VIEW || vh.getItemViewType() != IRecyclerView.FETCHING_VIEW) {
mPressedView.setPressed(false);
}
mPressedView = null;
}
mIsShowPress = false;
mIsPrepressed = false;
}
return false;
}
示例6: onInterceptTouchEvent
import android.support.v4.view.GestureDetectorCompat; //導入方法依賴的package包/類
@Override
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
LogUtil.e("onInterceptTouchEvent_RecyclerView");
if (mRecyclerView == null) {
mRecyclerView = rv;
mBaseWrappedAdapter = (BaseWrappedAdapter) mRecyclerView.getAdapter();
mGestureDetectorCompat = new GestureDetectorCompat(mRecyclerView.getContext(),
new CustomOnGestureListener(mRecyclerView));
}
// 這裏恢複長按下效果
if (!mGestureDetectorCompat.onTouchEvent(e) && e.getAction() == MotionEvent.ACTION_UP
&& isPressing) {
if (mPressedView != null) {
// 這裏要排除頭部和底部view
RecyclerView.ViewHolder viewHolder = mRecyclerView.getChildViewHolder(mPressedView);
if (viewHolder == null || !isHeaderViewOrFooterView(viewHolder.getItemViewType())) {
mPressedView.setPressed(false);
if (mPressedView instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) mPressedView;
for (int i = 0; i < viewGroup.getChildCount(); i++) {
if (!viewGroup.getChildAt(i).isPressed()) {
viewGroup.getChildAt(i).setPressed(false);
}
}
}
}
}
// 重置
isPressing = false;
}
// 不中斷
return false;
}