@Override public boolean onInterceptTouchEvent(RecyclerView view, MotionEvent e) { View childView = view.findChildViewUnder(e.getX(), e.getY()); if (childView != null && mListener != null && mGestureDetector.onTouchEvent(e)) { mListener.onItemClick(childView, view.getChildPosition(childView)); } return false; }
@Override public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { super.getItemOffsets(outRect, view, parent, state); if (mDivider == null) { return; } if (parent.getChildPosition(view) < 1) { return; } if (getOrientation(parent) == LinearLayoutManager.VERTICAL) { outRect.top = mDivider.getIntrinsicHeight(); } else { outRect.left = mDivider.getIntrinsicWidth(); } }
@Override public void onClick(View v) { Toast.makeText(getApplicationContext(), list.get(sectionedRecyclerViewAdapter.getIndexForPosition(recyclerView.getChildPosition(v))).name, Toast.LENGTH_SHORT).show(); } }
@Override public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { outRect.left = space; outRect.right = space; outRect.bottom = space; // Add top margin only for the first item to avoid double space between items if(parent.getChildPosition(view) == 0) outRect.top = space; } }
@Override public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) { View child = rv.findChildViewUnder(e.getX(), e.getY()); if (child != null && clickListener != null && gestureDetector.onTouchEvent(e)) { clickListener.onClick(rv.getChildPosition(child)); } return false; }
@Override public void onLongPress(MotionEvent e) { View child = recyclerView.findChildViewUnder(e.getX(), e.getY()); if (child != null && clickListener != null) { clickListener.onLongClick(recyclerView.getChildPosition(child)); } } });
@Override public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { if (parent.getChildPosition(view) == parent.getChildCount() - 1) { outRect.set(0, 0, 0, 0); } else { outRect.set(0, 0, 0, mDividerDrawable.getIntrinsicHeight()); } }
@Override public boolean onInterceptTouchEvent(RecyclerView view, MotionEvent e) { View childView = view.findChildViewUnder(e.getX(), e.getY()); if (childView != null && mListener != null && mGestureDetector.onTouchEvent(e)) { mListener.onItemClick(childView, view.getChildPosition(childView)); } return false; }
@Override public boolean onInterceptTouchEvent(RecyclerView view, MotionEvent e) { View childView = view.findChildViewUnder(e.getX(), e.getY()); if(childView != null && mListener != null && mGestureDetector.onTouchEvent(e)) { mListener.onItemClick(childView, view.getChildPosition(childView)); } return false; }
@Override public void onLongPress(MotionEvent e) { View child = recyclerView.findChildViewUnder(e.getX(), e.getY()); if (child != null && clickListener != null) { clickListener.onLongClick(child, recyclerView.getChildPosition(child)); } } });
@Override public void onLongPress(MotionEvent e) { View child = recyclerView.findChildViewUnder(e.getX(), e.getY()); if (child != null && clickListener != null) { clickListener.onLongClick(child, recyclerView.getChildPosition(child)); } } });
@Override public void onLongPress(MotionEvent e) { View child = recyclerView.findChildViewUnder(e.getX(), e.getY()); if (child != null && clickListener != null) { clickListener.onLongClick(child, recyclerView.getChildPosition(child)); } } });
@Override public void onLongPress(MotionEvent e) { View childView = recyclerView.findChildViewUnder(e.getX(), e.getY()); if(childView != null && mListener != null) { mListener.onItemLongClick(childView, recyclerView.getChildPosition(childView)); } } });
@Override public void getItemOffsets (Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { super.getItemOffsets(outRect, view, parent, state); if (divider == null) return; if (parent.getChildPosition(view) < 1) return; if (getOrientation(parent) == LinearLayoutManager.VERTICAL) outRect.top = divider.getIntrinsicHeight(); else outRect.left = divider.getIntrinsicWidth(); }
/** * Returns the adapter position of the first fully visible view. This position does not include * adapter changes that were dispatched after the last layout pass. * * @return The adapter position of the first fully visible item or * {@link RecyclerView#NO_POSITION} if there aren't any visible items. */ public int findFirstCompletelyVisibleItemPosition() { final View child = findOneVisibleChild(0, layoutManager.getChildCount(), true, false); return child == null ? NO_POSITION : recyclerView.getChildPosition(child); }
/** * Returns the adapter position of the first visible view. This position does not include * adapter changes that were dispatched after the last layout pass. * * @return The adapter position of the first visible item or {@link RecyclerView#NO_POSITION} if * there aren't any visible items. */ public int findFirstVisibleItemPosition() { final View child = findOneVisibleChild(0, layoutManager.getChildCount(), false, true); return child == null ? NO_POSITION : recyclerView.getChildPosition(child); }
/** * Returns the adapter position of the last visible view. This position does not include * adapter changes that were dispatched after the last layout pass. * * @return The adapter position of the last visible view or {@link RecyclerView#NO_POSITION} if * there aren't any visible items */ public int findLastVisibleItemPosition() { final View child = findOneVisibleChild(layoutManager.getChildCount() - 1, -1, false, true); return child == null ? NO_POSITION : recyclerView.getChildPosition(child); }
/** * Returns the adapter position of the last fully visible view. This position does not include * adapter changes that were dispatched after the last layout pass. * * @return The adapter position of the last fully visible view or * {@link RecyclerView#NO_POSITION} if there aren't any visible items. */ public int findLastCompletelyVisibleItemPosition() { final View child = findOneVisibleChild(layoutManager.getChildCount() - 1, -1, true, false); return child == null ? NO_POSITION : recyclerView.getChildPosition(child); }
@Override public boolean onSingleTapUp(MotionEvent event) { boolean handled = false; if (mTargetChild != null) { mTargetChild.setPressed(false); final int position = mHostView.getChildPosition(mTargetChild); final long id = mHostView.getAdapter().getItemId(position); handled = performItemClick(mHostView, mTargetChild, position, id); mTargetChild = null; } return handled; }
@Override public boolean onSingleTapUp(MotionEvent event) { boolean handled = false; if (mTargetChild != null) { mTargetChild.setPressed(false); final int position = mHostView.getChildPosition(mTargetChild); final long id = mHostView.getAdapter().getItemId(position); handled = performItemClick(mHostView, mTargetChild, position, id); mTargetChild = null; } return handled; }