ItemDetailsLookup
abstract class ItemDetailsLookup<K : Any!>
kotlin.Any | |
↳ | androidx.recyclerview.selection.ItemDetailsLookup |
The Selection library calls getItemDetails(MotionEvent)
when it needs access to information about the area and/or ItemDetails
under a MotionEvent
. Your implementation must negotiate ViewHolder
lookup with the corresponding RecyclerView instance, and the subsequent conversion of the ViewHolder instance to an ItemDetails
instance.
Example
final class MyDetailsLookup extends ItemDetailsLookup<uri> { private final RecyclerView mRecyclerView; MyDetailsLookup(RecyclerView recyclerView) { mRecyclerView = recyclerView; } public @Nullable ItemDetails <uri> getItemDetails(@NonNull MotionEvent e) { View view = mRecyclerView.findChildViewUnder(e.getX(), e.getY()); if (view != null) { ViewHolder holder = mRecyclerView.getChildViewHolder(view); if (holder instanceof MyHolder) { return ((MyHolder) holder).getItemDetails(); } } return null; } } </uri> </uri>
Summary
Nested classes | |
---|---|
abstract |
An ItemDetails implementation provides the selection library with access to information about a specific RecyclerView item. |
Public constructors | |
---|---|
<init>() The Selection library calls |
Public methods | |
---|---|
abstract ItemDetailsLookup.ItemDetails<K>? |
getItemDetails(@NonNull e: MotionEvent) |
Public constructors
<init>
ItemDetailsLookup()
The Selection library calls getItemDetails(MotionEvent)
when it needs access to information about the area and/or ItemDetails
under a MotionEvent
. Your implementation must negotiate ViewHolder
lookup with the corresponding RecyclerView instance, and the subsequent conversion of the ViewHolder instance to an ItemDetails
instance.
Example
final class MyDetailsLookup extends ItemDetailsLookup<uri> { private final RecyclerView mRecyclerView; MyDetailsLookup(RecyclerView recyclerView) { mRecyclerView = recyclerView; } public @Nullable ItemDetails <uri> getItemDetails(@NonNull MotionEvent e) { View view = mRecyclerView.findChildViewUnder(e.getX(), e.getY()); if (view != null) { ViewHolder holder = mRecyclerView.getChildViewHolder(view); if (holder instanceof MyHolder) { return ((MyHolder) holder).getItemDetails(); } } return null; } } </uri> </uri>
Public methods
getItemDetails
@Nullable abstract fun getItemDetails(@NonNull e: MotionEvent): ItemDetailsLookup.ItemDetails<K>?
Return | |
---|---|
ItemDetailsLookup.ItemDetails<K>? |
the ItemDetails for the item under the event, or null. |