private static View findRangeLastItem( RecyclerView rv, ItemDraggableRange range, int firstVisiblePosition, int lastVisiblePosition) { if (firstVisiblePosition == RecyclerView.NO_POSITION || lastVisiblePosition == RecyclerView.NO_POSITION) { return null; } View v = null; final int childCount = rv.getChildCount(); for (int i = childCount - 1; i >= 0; i--) { final View v2 = rv.getChildAt(i); final RecyclerView.ViewHolder vh = rv.getChildViewHolder(v2); if (vh != null) { final int position = vh.getLayoutPosition(); if ((position >= firstVisiblePosition) && (position <= lastVisiblePosition) && range.checkInRange(position)) { v = v2; break; } } } return v; }
@Override public void onBindViewHolder(VH holder, int position) { if (isDragging()) { final long itemId = holder.getItemId(); final int origPosition = convertToOriginalPosition( position, mDraggingItemInitialPosition, mDraggingItemCurrentPosition); if (itemId == mDraggingItemId && holder != mDraggingItem) { if (mDraggingItem == null) { if (LOCAL_LOGI) { Log.i(TAG, "a new view holder object for the currently dragging item is assigned"); } mDraggingItem = holder; mDragDropManager.onNewDraggingItemViewBinded(holder); } else { Log.e(TAG, "an another view holder object for the currently dragging item is assigned"); } } int flags = RecyclerViewDragDropManager.STATE_FLAG_DRAGGING; if (itemId == mDraggingItemId) { flags |= RecyclerViewDragDropManager.STATE_FLAG_IS_ACTIVE; } if (mDraggableRange.checkInRange(position)) { flags |= RecyclerViewDragDropManager.STATE_FLAG_IS_IN_RANGE; } safeUpdateFlags(holder, flags); super.onBindViewHolder(holder, origPosition); } else { safeUpdateFlags(holder, 0); super.onBindViewHolder(holder, position); } }