Java Code Examples for android.support.v4.view.GestureDetectorCompat#onTouchEvent()
The following examples show how to use
android.support.v4.view.GestureDetectorCompat#onTouchEvent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleClickListener.java From AndroidBase with Apache License 2.0 | 6 votes |
@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; }
Example 2
Source File: SimpleClickListener.java From NIM_Android_UIKit with MIT License | 6 votes |
@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; }
Example 3
Source File: BaseItemClickListener.java From TestChat with Apache License 2.0 | 5 votes |
@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; }