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