Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class RecycleOntouchListner implements RecyclerView.OnItemTouchListener {
- private GestureDetector mGestureDetector;
- private ClickListener mClickListner;
- public RecycleOntouchListner(Context mContext, ClickListener clickListner) {
- this.mClickListner = clickListner;
- mGestureDetector = new GestureDetector(mContext, new GestureDetector.SimpleOnGestureListener() {
- @Override
- public boolean onSingleTapUp(MotionEvent e) {
- return true;
- }
- });
- }
- @Override
- public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
- View child = rv.findChildViewUnder(e.getX(), e.getY());
- if (child != null && mClickListner != null && mGestureDetector.onTouchEvent(e)) {
- mClickListner.OnClick(child, rv.getChildAdapterPosition(child));
- return false;
- }
- return false;
- }
- @Override
- public void onTouchEvent(RecyclerView rv, MotionEvent e) {
- }
- @Override
- public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement