public abstract static class RecyclerViewItemHelper.ItemInteractor extends ItemTouchHelper.Callback
ItemTouchHelper.Callback implementation which should be used as base class for
all interactors used by RecyclerViewItemHelper implementations.DEFAULT_DRAG_ANIMATION_DURATION, DEFAULT_SWIPE_ANIMATION_DURATION| Constructor and Description |
|---|
ItemInteractor() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract boolean |
canAttachAdapter(RecyclerView.Adapter adapter)
Called by the parent helper to check if the given adapter may be attached
to this interactor instance.
|
abstract boolean |
isActive()
Returns boolean flag indicating whether this interactor is currently active.
|
boolean |
isEnabled()
Returns boolean flag indicating whether this interactor is enabled or not.
|
protected void |
onAdapterAttached(RecyclerView.Adapter adapter)
Invoked whenever a new adapter is attached to this interactor instance.
|
protected void |
onAdapterDetached(RecyclerView.Adapter adapter)
Invoked before a new adapter is attached to this interactor instance if there
is already previous adapter attached.
|
protected void |
onAttachedToHelper(RecyclerViewItemHelper helper)
Invoked whenever
attachToHelper(RecyclerViewItemHelper) is called for this interactor
instance. |
void |
onChildDraw(Canvas canvas,
RecyclerView recyclerView,
RecyclerView.ViewHolder viewHolder,
float dX,
float dY,
int actionState,
boolean isCurrentlyActive) |
void |
onChildDrawOver(Canvas canvas,
RecyclerView recyclerView,
RecyclerView.ViewHolder viewHolder,
float dX,
float dY,
int actionState,
boolean isCurrentlyActive) |
void |
setEnabled(boolean enabled)
Sets a boolean flag indicating whether this interactor should be enabled or not.
|
protected boolean |
shouldHandleInteraction()
Checks whether this interactor should handle interaction due to received callback from
the parent helper.
|
canDropOver, chooseDropTarget, clearView, convertToAbsoluteDirection, convertToRelativeDirection, getAnimationDuration, getBoundingBoxMargin, getDefaultUIUtil, getMovementFlags, getMoveThreshold, getSwipeEscapeVelocity, getSwipeThreshold, getSwipeVelocityThreshold, interpolateOutOfBoundsScroll, isItemViewSwipeEnabled, isLongPressDragEnabled, makeFlag, makeMovementFlags, onMove, onMoved, onSelectedChanged, onSwipedprotected void onAttachedToHelper(@NonNull RecyclerViewItemHelper helper)
attachToHelper(RecyclerViewItemHelper) is called for this interactor
instance.helper - The helper that will use this interactor to support its specific feature.protected abstract boolean canAttachAdapter(@NonNull RecyclerView.Adapter adapter)
If this method returns true, onAdapterAttached(RecyclerView.Adapter)
will follow. If this interactor has attached any previous adapter, such adapter will be
detached via onAdapterDetached(RecyclerView.Adapter) before the new one is
attached.
adapter - The adapter to be checked if it may be attached.True if the parent helper may attach the adapter to this interactor,
false otherwise.protected void onAdapterAttached(@NonNull RecyclerView.Adapter adapter)
This method is called as result of call to RecyclerViewItemHelper.attachToRecyclerView(RecyclerView)
for the parent helper.
adapter - The adapter of the associated RecyclerView to which is the parent
helper attached.onAdapterDetached(RecyclerView.Adapter)protected void onAdapterDetached(@NonNull RecyclerView.Adapter adapter)
adapter - The previous adapter that has been detached from this interactor.onAdapterAttached(RecyclerView.Adapter)public void setEnabled(boolean enabled)
enabled - True to enable this interactor, false otherwise.isEnabled()public boolean isEnabled()
True if this interactor is enabled, false otherwise.setEnabled(boolean)public abstract boolean isActive()
True if this interactor performs some interaction logic at this time,
false otherwise.protected boolean shouldHandleInteraction()
This implementation checks whether this interactor instance is enabled at this time and also has valid adapter attached. However inheritance hierarchies may override this behaviour as they desire.
True if interaction should be handled, false otherwise.public void onChildDraw(@NonNull Canvas canvas, @NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive)
onChildDraw in class ItemTouchHelper.Callbackpublic void onChildDrawOver(@NonNull Canvas canvas, @NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive)
onChildDrawOver in class ItemTouchHelper.Callback