-
- All Implemented Interfaces:
-
com.chad.library.adapter.base.fullspan.FullSpanAdapterType
public abstract class LoadStateAdapter<VH extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<VH> implements FullSpanAdapterType
Load state Adapter 加载状态的父类,"加载更多"、"向上加载"都继承于此
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceLoadStateAdapter.LoadStateListener
-
Field Summary
Fields Modifier and Type Field Description private LoadStateloadStateprivate final BooleanisLoadingprivate RecyclerViewrecyclerView
-
Constructor Summary
Constructors Constructor Description LoadStateAdapter()
-
Method Summary
Modifier and Type Method Description final LoadStategetLoadState()Changing this property will immediately notify the Adapter to change the item it's presenting. final UnitsetLoadState(LoadState loadState)final BooleangetIsLoading()final RecyclerViewgetRecyclerView()final UnitsetRecyclerView(RecyclerView recyclerView)final VHonCreateViewHolder(ViewGroup parent, Integer viewType)abstract VHonCreateViewHolder(ViewGroup parent, LoadState loadState)Called to create a ViewHolder for the given LoadState. final UnitonBindViewHolder(VH holder, Integer position)final UnitonBindViewHolder(VH holder, Integer position, List<Object> payloads)abstract UnitonBindViewHolder(VH holder, LoadState loadState)Called to bind the passed LoadState to the ViewHolder. final IntegergetItemViewType(Integer position)final IntegergetItemCount()UnitonAttachedToRecyclerView(RecyclerView recyclerView)UnitonDetachedFromRecyclerView(RecyclerView recyclerView)IntegergetStateViewType(LoadState loadState)Override this method to use different view types per LoadState. BooleandisplayLoadStateAsItem(LoadState loadState)Returns true if the LoadState should be displayed as a list item when active. final UnitaddLoadStateListener(LoadStateAdapter.LoadStateListener listener)final UnitremoveLoadStateListener(LoadStateAdapter.LoadStateListener listener)-
Methods inherited from class com.chad.library.adapter.base.loadState.LoadStateAdapter
bindViewHolder, canRestoreState, createViewHolder, findRelativeAdapterPositionIn, getItemId, getStateRestorationPolicy, hasObservers, hasStableIds, notifyDataSetChanged, notifyItemChanged, notifyItemChanged, notifyItemInserted, notifyItemMoved, notifyItemRangeChanged, notifyItemRangeChanged, notifyItemRangeInserted, notifyItemRangeRemoved, notifyItemRemoved, onFailedToRecycleView, onViewAttachedToWindow, onViewDetachedFromWindow, onViewRecycled, registerAdapterDataObserver, setHasStableIds, setStateRestorationPolicy, unregisterAdapterDataObserver -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getLoadState
final LoadState getLoadState()
Changing this property will immediately notify the Adapter to change the item it's presenting. LoadState.None is the initial state.
要在适配器中显示的 LoadState。更改此属性将立即通知适配器更改 item 的样式。 LoadState.None 为初始状态。
-
setLoadState
final Unit setLoadState(LoadState loadState)
-
getIsLoading
final Boolean getIsLoading()
-
getRecyclerView
final RecyclerView getRecyclerView()
-
setRecyclerView
final Unit setRecyclerView(RecyclerView recyclerView)
-
onCreateViewHolder
final VH onCreateViewHolder(ViewGroup parent, Integer viewType)
-
onCreateViewHolder
abstract VH onCreateViewHolder(ViewGroup parent, LoadState loadState)
Called to create a ViewHolder for the given LoadState.
调用此方法,为 LoadState 创建 ViewHolder。
- Parameters:
parent- The ViewGroup into which the new View will be added after it is bound to an adapter position.loadState- The LoadState to be initially presented by the new ViewHolder.
-
onBindViewHolder
final Unit onBindViewHolder(VH holder, Integer position)
-
onBindViewHolder
abstract Unit onBindViewHolder(VH holder, LoadState loadState)
Called to bind the passed LoadState to the ViewHolder.
调用此方法,将 LoadState 状态绑定至 ViewHolder
- Parameters:
loadState- LoadState to display.
-
getItemViewType
final Integer getItemViewType(Integer position)
-
getItemCount
final Integer getItemCount()
-
onAttachedToRecyclerView
@CallSuper() Unit onAttachedToRecyclerView(RecyclerView recyclerView)
-
onDetachedFromRecyclerView
@CallSuper() Unit onDetachedFromRecyclerView(RecyclerView recyclerView)
-
getStateViewType
Integer getStateViewType(LoadState loadState)
Override this method to use different view types per LoadState. 重写此方法以对每个 LoadState 使用不同的 View 类型。
By default, this LoadStateAdapter only uses a single view type.
-
displayLoadStateAsItem
Boolean displayLoadStateAsItem(LoadState loadState)
Returns true if the LoadState should be displayed as a list item when active.
By default, LoadState.Loading and LoadState.Error present as list items, others do not.
如果 LoadState 在激活时需要显示item,则返回 true。 默认情况下,LoadState.Loading 和 LoadState.Error 将会显示,其他则不显示。
-
addLoadStateListener
final Unit addLoadStateListener(LoadStateAdapter.LoadStateListener listener)
-
removeLoadStateListener
final Unit removeLoadStateListener(LoadStateAdapter.LoadStateListener listener)
-
-
-
-