public abstract class XAdapter<T>
extends RecyclerView.Adapter
| 限定符和类型 | 类和说明 |
|---|---|
static interface |
XAdapter.ILoadMoreListener
加载更多接口
|
| 限定符和类型 | 字段和说明 |
|---|---|
protected android.content.Context |
context |
static int |
LOADER_CAN_LOAD |
static int |
LOADER_INIT
LOADER_NO_DATA 没有数据
LOADER_NO_MORE 已加载全部,有footerLayoutId显示Footer
LOADER_CAN_LOAD 可以加载更多
LOADER_LOADING 正在加载中,等待LoadMoreListener返回结果
LOADER_RETRY 加载更多失败
|
static int |
LOADER_LOADING |
static int |
LOADER_NO_DATA |
static int |
LOADER_NO_MORE |
static int |
LOADER_RETRY |
static int |
VIEW_TYPE_BLANK |
static int |
VIEW_TYPE_FOOTER |
static int |
VIEW_TYPE_FOOTER_LOADING |
static int |
VIEW_TYPE_FOOTER_NO_DATA |
static int |
VIEW_TYPE_FOOTER_NO_MORE |
static int |
VIEW_TYPE_FOOTER_RETRY |
static int[] |
VIEW_TYPE_FOOTERS |
| 构造器和说明 |
|---|
XAdapter(android.content.Context context)
use single Layout
|
XAdapter(android.content.Context context,
OnInitList initList) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addHeader(int headerLayoutId) |
void |
addHeader(int headerKey,
int headerLayoutId) |
void |
addItem(T item) |
void |
addItemNoFilter(int pos,
T item)
this method can only use in no filter mode
|
protected void |
beforeSetDataList(java.util.List<T> dataList) |
protected void |
bindingFooter(CustomHolder holder) |
protected void |
bindingFooterLoader(CustomHolder holder,
int layoutFooterViewType)
启用加载更多时绑定Footer
建议不想新建Layout的可以继承XAdapter
重写此方法,适应更种加载提示语等
|
protected void |
bindingHeader(CustomHolder holder,
int headerKey) |
void |
bindingHolder(CustomHolder holder,
java.util.List<T> dataList,
int pos)
绑定展示数据时执行,多次执行
|
protected void |
creatingFooter(CustomHolder holder) |
protected void |
creatingHeader(CustomHolder holder,
int headerKey) |
void |
creatingHolder(CustomHolder holder,
ViewTypeUnit viewTypeUnit)
创建Holder时执行,只执行一次或被销毁后再次会被执行
|
T |
getCurrentItem(CustomHolder holder) |
int |
getHeaderCount() |
int |
getHeaderPos(int headerKey) |
T |
getItem(int itemPosWithoutHeaderCount)
取得列表Item
|
int |
getItemCount()
Please use getDataList().size() to get items count,this method would add header and Footer if they exist
|
int |
getItemViewType(int position)
when you use layout list, you can override this method when binding holder views
|
int |
getLayoutId(java.lang.String mark) |
int |
getLoadingLayoutId() |
XAdapter.ILoadMoreListener |
getLoadMoreListener() |
int |
getLoadRetryLayoutId() |
int |
getNoDataLayoutId() |
java.util.List<T> |
getNoFilteredDataList()
适配器中的所有数据,包括被过滤掉的数据
|
OnInitList |
getOnInitList() |
java.util.List<T> |
getShowingList()
取得下在展示的数据集合
|
protected ViewTypeUnit |
getViewTypeUnitForLayout(T item)
根据Mark确定展示的Layout
override this method can show different holder for layout
don't return LAYOUT_FOOTER = -20331
|
protected void |
handleItemViewClick(CustomHolder holder,
T item,
int viewId,
ViewTypeUnit viewTypeUnit)
override this method to add holder rootView onclick event,when handle over continue to on ClickListener in creating holder set.
|
protected boolean |
handleItemViewLongClick(CustomHolder holder,
T item,
int viewId,
ViewTypeUnit viewTypeUnit) |
boolean |
hasFooter() |
boolean |
isHeader(int pos) |
void |
loadingMoreEnd(boolean noMoreData)
加载更多结束
|
void |
loadingMoreError()
加载更多异常
显示加载重试Footer
|
void |
onBindViewHolder(RecyclerView.ViewHolder holder,
int position)
展示
|
RecyclerView.ViewHolder |
onCreateViewHolder(android.view.ViewGroup parent,
int viewType)
only do once method
or
not use immediately adapterPosition method, like clickListener
|
void |
onViewAttachedToWindow(RecyclerView.ViewHolder holder)
Called when a view created by this adapter has been attached to a window.
|
void |
openLoadAnimation()
To open the animation when loading
|
void |
openLoadAnimation(BaseAnimation animation)
Set Custom ObjectAnimator
|
void |
refreshedNoData() |
void |
removeItem(int pos) |
void |
resetDataList()
已过时。
|
void |
setAnimationDuration(int animationDuration) |
void |
setAnimationInterpolator(android.view.animation.Interpolator animationInterpolator) |
void |
setDataList(java.util.List<T> dataList) |
protected java.util.List<T> |
setFilterForAdapter(java.util.List<T> mainList)
filter local main data list, it can use any time, it won't change the main data list.
|
void |
setFooter(int footerLayout) |
protected void |
setFullSpan(RecyclerView.ViewHolder holder)
thanks CymChad for this method
When set to true, the item will layout using all span area.
|
void |
setLoadingLayout(int loadingLayoutId) |
void |
setLoadMoreListener(XAdapter.ILoadMoreListener loadMoreListener) |
void |
setLoadRetryLayoutId(int loadRetryLayoutId) |
void |
setNoDataLayoutId(int noDataLayoutId) |
void |
setNoMoreLayoutId(int noMoreLayoutId) |
void |
setShowNoDataFooter(boolean showNoDataFooter) |
void |
setUseDefaultLoaderLayout(boolean useDefaultLoaderLayout) |
protected void |
startItemAnimation(BaseAnimation animation,
RecyclerView.ViewHolder holder)
set anim to start when loading
|
void |
updateItem(int pos,
T item) |
protected boolean |
useFilter()
是否使用过滤列表
|
public static final int VIEW_TYPE_BLANK
public static final int VIEW_TYPE_FOOTER
public static final int VIEW_TYPE_FOOTER_LOADING
public static final int VIEW_TYPE_FOOTER_NO_MORE
public static final int VIEW_TYPE_FOOTER_RETRY
public static final int VIEW_TYPE_FOOTER_NO_DATA
public static final int[] VIEW_TYPE_FOOTERS
public static final int LOADER_INIT
public static final int LOADER_NO_DATA
public static final int LOADER_NO_MORE
public static final int LOADER_CAN_LOAD
public static final int LOADER_LOADING
public static final int LOADER_RETRY
protected android.content.Context context
public XAdapter(android.content.Context context)
context - public XAdapter(android.content.Context context,
OnInitList initList)
public RecyclerView.ViewHolder onCreateViewHolder(android.view.ViewGroup parent,
int viewType)
parent - viewType - public void onBindViewHolder(RecyclerView.ViewHolder holder,
int position)
holder - position - public void onViewAttachedToWindow(RecyclerView.ViewHolder holder)
setFullSpan(RecyclerView.ViewHolder)holder - protected void setFullSpan(RecyclerView.ViewHolder holder)
holder - True if this item should traverse all spans.protected void startItemAnimation(BaseAnimation animation, RecyclerView.ViewHolder holder)
animation - holder - public void openLoadAnimation(BaseAnimation animation)
animation - ObjectAnimatorpublic void openLoadAnimation()
public void creatingHolder(CustomHolder holder, ViewTypeUnit viewTypeUnit) throws java.lang.Exception
holder - viewTypeUnit - java.lang.Exceptionpublic void bindingHolder(CustomHolder holder, java.util.List<T> dataList, int pos) throws java.lang.Exception
holder - dataList - pos - java.lang.Exceptionprotected ViewTypeUnit getViewTypeUnitForLayout(T item)
item - public int getItemViewType(int position)
position - public int getItemCount()
public boolean isHeader(int pos)
public T getItem(int itemPosWithoutHeaderCount)
itemPosWithoutHeaderCount - 列表中的Item位置, 不包括Header的Item,
如使用getAdapterPosition()需要减掉getHeaderCount()public T getCurrentItem(CustomHolder holder)
public OnInitList getOnInitList()
public void setAnimationDuration(int animationDuration)
public void setAnimationInterpolator(android.view.animation.Interpolator animationInterpolator)
public boolean hasFooter()
public int getHeaderCount()
public int getHeaderPos(int headerKey)
public int getLayoutId(java.lang.String mark)
public java.util.List<T> getNoFilteredDataList()
public java.util.List<T> getShowingList()
public void setDataList(java.util.List<T> dataList)
@Deprecated public void resetDataList()
public void removeItem(int pos)
public void addItemNoFilter(int pos,
T item)
pos - item - public void updateItem(int pos,
T item)
public void addItem(T item)
public void setFooter(int footerLayout)
public void addHeader(int headerLayoutId)
public void addHeader(int headerKey,
int headerLayoutId)
protected void creatingHeader(CustomHolder holder, int headerKey) throws java.lang.Exception
java.lang.Exceptionprotected void bindingHeader(CustomHolder holder, int headerKey) throws java.lang.Exception
java.lang.Exceptionprotected void creatingFooter(CustomHolder holder)
protected void bindingFooter(CustomHolder holder)
protected void bindingFooterLoader(CustomHolder holder, int layoutFooterViewType)
holder - layoutFooterViewType - LAYOUT_FOOTERprotected void beforeSetDataList(java.util.List<T> dataList)
protected void handleItemViewClick(CustomHolder holder, T item, int viewId, ViewTypeUnit viewTypeUnit)
holder - item - viewTypeUnit - protected boolean handleItemViewLongClick(CustomHolder holder, T item, int viewId, ViewTypeUnit viewTypeUnit)
protected java.util.List<T> setFilterForAdapter(java.util.List<T> mainList)
mainList - protected boolean useFilter()
public void loadingMoreEnd(boolean noMoreData)
noMoreData - true:没有更多的数据了, false:可以再次加载更多public void loadingMoreError()
public void refreshedNoData()
public XAdapter.ILoadMoreListener getLoadMoreListener()
public void setLoadMoreListener(XAdapter.ILoadMoreListener loadMoreListener)
public void setLoadingLayout(int loadingLayoutId)
public int getLoadingLayoutId()
public void setNoMoreLayoutId(int noMoreLayoutId)
public int getNoDataLayoutId()
public void setNoDataLayoutId(int noDataLayoutId)
public int getLoadRetryLayoutId()
public void setLoadRetryLayoutId(int loadRetryLayoutId)
public void setUseDefaultLoaderLayout(boolean useDefaultLoaderLayout)
public void setShowNoDataFooter(boolean showNoDataFooter)