public abstract class BaseQuickAdapter<T,K extends BaseViewHolder>
extends <any>
| 限定符和类型 | 类和说明 |
|---|---|
static interface |
BaseQuickAdapter.AnimationType |
static interface |
BaseQuickAdapter.OnItemChildClickListener
Interface definition for a callback to be invoked when an itemchild in this
view has been clicked
|
static interface |
BaseQuickAdapter.OnItemChildLongClickListener
Interface definition for a callback to be invoked when an childView in this
view has been clicked and held.
|
static interface |
BaseQuickAdapter.OnItemClickListener
Interface definition for a callback to be invoked when an item in this
RecyclerView itemView has been clicked.
|
static interface |
BaseQuickAdapter.OnItemLongClickListener
Interface definition for a callback to be invoked when an item in this
view has been clicked and held.
|
static interface |
BaseQuickAdapter.RequestLoadMoreListener |
static interface |
BaseQuickAdapter.SpanSizeLookup |
static interface |
BaseQuickAdapter.UpFetchListener |
| 限定符和类型 | 字段和说明 |
|---|---|
static int |
ALPHAIN
Use with
openLoadAnimation(int) |
static int |
EMPTY_VIEW |
static int |
FOOTER_VIEW |
static int |
HEADER_VIEW |
static int |
LOADING_VIEW |
protected android.content.Context |
mContext |
protected java.util.List<T> |
mData |
protected android.view.LayoutInflater |
mLayoutInflater |
protected int |
mLayoutResId |
static int |
SCALEIN
Use with
openLoadAnimation(int) |
static int |
SLIDEIN_BOTTOM
Use with
openLoadAnimation(int) |
static int |
SLIDEIN_LEFT
Use with
openLoadAnimation(int) |
static int |
SLIDEIN_RIGHT
Use with
openLoadAnimation(int) |
protected static java.lang.String |
TAG |
| 构造器和说明 |
|---|
BaseQuickAdapter(int layoutResId) |
BaseQuickAdapter(int layoutResId,
java.util.List<T> data)
Same as QuickAdapter#QuickAdapter(Context,int) but with
some initialization data.
|
BaseQuickAdapter(java.util.List<T> data) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
add(int position,
T item)
已过时。
use
addData(int, Object) instead |
void |
addData(java.util.Collection<? extends T> newData)
add new data to the end of mData
|
void |
addData(int position,
java.util.Collection<? extends T> newData)
add new data in to certain location
|
void |
addData(int position,
T data)
add one new data in to certain location
|
void |
addData(T data)
add one new data
|
int |
addFooterView(android.view.View footer)
Append footer to the rear of the mFooterLayout.
|
int |
addFooterView(android.view.View footer,
int index) |
int |
addFooterView(android.view.View footer,
int index,
int orientation)
Add footer view to mFooterLayout and set footer view position in mFooterLayout.
|
int |
addHeaderView(android.view.View header)
Append header to the rear of the mHeaderLayout.
|
int |
addHeaderView(android.view.View header,
int index)
Add header view to mHeaderLayout and set header view position in mHeaderLayout.
|
int |
addHeaderView(android.view.View header,
int index,
int orientation) |
void |
bindToRecyclerView(RecyclerView recyclerView)
same as recyclerView.setAdapter(), and save the instance of recyclerView
|
int |
collapse(int position)
Collapse an expandable item that has been expanded..
|
int |
collapse(int position,
boolean animate)
Collapse an expandable item that has been expanded..
|
int |
collapse(int position,
boolean animate,
boolean notify)
Collapse an expandable item that has been expanded..
|
protected abstract void |
convert(K helper,
T item)
Implement this method and use the helper to adapt the view to the given item.
|
protected K |
createBaseViewHolder(android.view.View view)
if you want to use subclass of BaseViewHolder in the adapter,
you must override the method to create new ViewHolder.
|
protected K |
createBaseViewHolder(android.view.ViewGroup parent,
int layoutResId) |
void |
disableLoadMoreIfNotFullPage() |
void |
disableLoadMoreIfNotFullPage(RecyclerView recyclerView)
check if full page after
setNewData(List), if full, it will enable load more again. |
void |
enableLoadMoreEndClick(boolean enable)
Load more without data when settings are clicked loaded
|
int |
expand(int position)
Expand an expandable item with animation.
|
int |
expand(int position,
boolean animate)
Expand an expandable item
|
int |
expand(int position,
boolean animate,
boolean shouldNotify)
Expand an expandable item
|
void |
expandAll() |
int |
expandAll(int position,
boolean init)
expand the item and all its subItems
|
int |
expandAll(int position,
boolean animate,
boolean notify) |
java.util.List<T> |
getData()
Get the data of list
|
protected int |
getDefItemViewType(int position) |
android.view.View |
getEmptyView()
When the current adapter is empty, the BaseQuickAdapter can display a special view
called the empty view.
|
int |
getEmptyViewCount()
if show empty view will be return 1 or not will be return 0
|
android.widget.LinearLayout |
getFooterLayout()
Return root layout of footer
|
int |
getFooterLayoutCount()
if addFooterView will be return 1, if not will be return 0
|
int |
getFooterViewsCount()
已过时。
|
android.widget.LinearLayout |
getHeaderLayout()
Return root layout of header
|
int |
getHeaderLayoutCount()
if addHeaderView will be return 1, if not will be return 0
|
int |
getHeaderViewsCount()
已过时。
|
T |
getItem(int position)
Get the data item associated with the specified position in the data set.
|
int |
getItemCount() |
long |
getItemId(int position)
Get the row id associated with the specified position in the list.
|
protected android.view.View |
getItemView(int layoutResId,
android.view.ViewGroup parent) |
int |
getItemViewType(int position) |
int |
getLoadMoreViewCount()
Load more view count
|
int |
getLoadMoreViewPosition()
Gets to load more locations
|
MultiTypeDelegate<T> |
getMultiTypeDelegate() |
BaseQuickAdapter.OnItemChildClickListener |
getOnItemChildClickListener() |
BaseQuickAdapter.OnItemChildLongClickListener |
getOnItemChildLongClickListener() |
BaseQuickAdapter.OnItemClickListener |
getOnItemClickListener() |
BaseQuickAdapter.OnItemLongClickListener |
getOnItemLongClickListener() |
int |
getParentPosition(T item)
Get the parent item position of the IExpandable item
|
protected RecyclerView |
getRecyclerView() |
android.view.View |
getViewByPosition(int position,
int viewId)
get the specific view by position,e.g. getViewByPosition(2, R.id.textView)
|
android.view.View |
getViewByPosition(RecyclerView recyclerView,
int position,
int viewId) |
boolean |
isExpandable(T item) |
void |
isFirstOnly(boolean firstOnly) |
protected boolean |
isFixedViewType(int type) |
boolean |
isFooterViewAsFlow() |
boolean |
isHeaderViewAsFlow() |
boolean |
isLoading() |
boolean |
isLoadMoreEnable()
Returns the enabled status for load more.
|
boolean |
isUpFetchEnable() |
boolean |
isUpFetching() |
void |
isUseEmpty(boolean isUseEmpty)
Set whether to use empty view
|
void |
loadMoreComplete()
Refresh complete
|
void |
loadMoreEnd()
Refresh end, no more data
|
void |
loadMoreEnd(boolean gone)
Refresh end, no more data
|
void |
loadMoreFail()
Refresh failed
|
void |
notifyLoadMoreToLoading()
The notification starts the callback and loads more
|
void |
onAttachedToRecyclerView(RecyclerView recyclerView) |
void |
onBindViewHolder(K holder,
int position)
To bind different types of holder and solve different the bind events
|
protected K |
onCreateDefViewHolder(android.view.ViewGroup parent,
int viewType) |
K |
onCreateViewHolder(android.view.ViewGroup parent,
int viewType) |
void |
onViewAttachedToWindow(K 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 |
openLoadAnimation(int animationType)
Set the view animation type.
|
void |
remove(int position)
remove the item associated with the specified position of adapter
|
void |
removeAllFooterView()
remove all footer view from mFooterLayout and set null to mFooterLayout
|
void |
removeAllHeaderView()
remove all header view from mHeaderLayout and set null to mHeaderLayout
|
void |
removeFooterView(android.view.View footer)
remove footer view from mFooterLayout,
When the child count of mFooterLayout is 0, mFooterLayout will be set to null.
|
void |
removeHeaderView(android.view.View header)
remove header view from mHeaderLayout.
|
void |
replaceData(java.util.Collection<? extends T> data)
use data to replace all item in mData. this method is different
setNewData(List),
it doesn't change the mData reference |
void |
setAutoLoadMoreSize(int preLoadNumber)
已过时。
|
void |
setData(int index,
T data)
change data
|
void |
setDuration(int duration)
Sets the duration of the animation.
|
void |
setEmptyView(int layoutResId) |
void |
setEmptyView(int layoutResId,
android.view.ViewGroup viewGroup) |
void |
setEmptyView(android.view.View emptyView) |
void |
setEnableLoadMore(boolean enable)
Set the enabled state of load more.
|
int |
setFooterView(android.view.View header) |
int |
setFooterView(android.view.View header,
int index) |
int |
setFooterView(android.view.View header,
int index,
int orientation) |
void |
setFooterViewAsFlow(boolean footerViewAsFlow) |
protected void |
setFullSpan(RecyclerView.ViewHolder holder)
When set to true, the item will layout using all span area.
|
void |
setHeaderAndEmpty(boolean isHeadAndEmpty) |
void |
setHeaderFooterEmpty(boolean isHeadAndEmpty,
boolean isFootAndEmpty)
set emptyView show if adapter is empty and want to show headview and footview
|
int |
setHeaderView(android.view.View header) |
int |
setHeaderView(android.view.View header,
int index) |
int |
setHeaderView(android.view.View header,
int index,
int orientation) |
void |
setHeaderViewAsFlow(boolean headerViewAsFlow) |
void |
setLoadMoreView(LoadMoreView loadingView)
Set custom load more
|
void |
setMultiTypeDelegate(MultiTypeDelegate<T> multiTypeDelegate) |
void |
setNewData(java.util.List<T> data)
setting up a new instance to data;
|
void |
setNotDoAnimationCount(int count)
up fetch end
|
void |
setOnItemChildClickListener(BaseQuickAdapter.OnItemChildClickListener listener)
Register a callback to be invoked when an itemchild in View has
been clicked
|
void |
setOnItemChildLongClickListener(BaseQuickAdapter.OnItemChildLongClickListener listener)
Register a callback to be invoked when an itemchild in this View has
been long clicked and held
|
void |
setOnItemClick(android.view.View v,
int position)
override this method if you want to override click event logic
|
void |
setOnItemClickListener(BaseQuickAdapter.OnItemClickListener listener)
Register a callback to be invoked when an item in this RecyclerView has
been clicked.
|
boolean |
setOnItemLongClick(android.view.View v,
int position)
override this method if you want to override longClick event logic
|
void |
setOnItemLongClickListener(BaseQuickAdapter.OnItemLongClickListener listener)
Register a callback to be invoked when an item in this RecyclerView has
been long clicked and held
|
void |
setOnLoadMoreListener(BaseQuickAdapter.RequestLoadMoreListener requestLoadMoreListener)
已过时。
This method is because it can lead to crash: always call this method while RecyclerView is computing a layout or scrolling.
|
void |
setOnLoadMoreListener(BaseQuickAdapter.RequestLoadMoreListener requestLoadMoreListener,
RecyclerView recyclerView) |
void |
setPreLoadNumber(int preLoadNumber) |
void |
setSpanSizeLookup(BaseQuickAdapter.SpanSizeLookup spanSizeLookup) |
void |
setStartUpFetchPosition(int startUpFetchPosition) |
void |
setUpFetchEnable(boolean upFetch) |
void |
setUpFetching(boolean upFetching) |
void |
setUpFetchListener(BaseQuickAdapter.UpFetchListener upFetchListener) |
protected void |
startAnim(android.animation.Animator anim,
int index)
set anim to start when loading
|
public static final int ALPHAIN
openLoadAnimation(int)public static final int SCALEIN
openLoadAnimation(int)public static final int SLIDEIN_BOTTOM
openLoadAnimation(int)public static final int SLIDEIN_LEFT
openLoadAnimation(int)public static final int SLIDEIN_RIGHT
openLoadAnimation(int)protected static final java.lang.String TAG
protected android.content.Context mContext
protected int mLayoutResId
protected android.view.LayoutInflater mLayoutInflater
protected java.util.List<T> mData
public static final int HEADER_VIEW
public static final int LOADING_VIEW
public static final int FOOTER_VIEW
public static final int EMPTY_VIEW
public BaseQuickAdapter(int layoutResId,
java.util.List<T> data)
layoutResId - The layout resource id of each item.data - A new list is created out of this one to avoid mutable listpublic BaseQuickAdapter(java.util.List<T> data)
public BaseQuickAdapter(int layoutResId)
protected RecyclerView getRecyclerView()
public void bindToRecyclerView(RecyclerView recyclerView)
@Deprecated public void setOnLoadMoreListener(BaseQuickAdapter.RequestLoadMoreListener requestLoadMoreListener)
public void setOnLoadMoreListener(BaseQuickAdapter.RequestLoadMoreListener requestLoadMoreListener, RecyclerView recyclerView)
public void disableLoadMoreIfNotFullPage()
public void disableLoadMoreIfNotFullPage(RecyclerView recyclerView)
setNewData(List), if full, it will enable load more again.
不是配置项!!
这个方法是用来检查是否满一屏的,所以只推荐在 setNewData(List) 之后使用
原理很简单,先关闭 load more,检查完了再决定是否开启
不是配置项!!
recyclerView - your recyclerViewsetNewData(List)public void setUpFetchEnable(boolean upFetch)
public boolean isUpFetchEnable()
public void setStartUpFetchPosition(int startUpFetchPosition)
public boolean isUpFetching()
public void setUpFetching(boolean upFetching)
public void setUpFetchListener(BaseQuickAdapter.UpFetchListener upFetchListener)
public void setNotDoAnimationCount(int count)
public void setLoadMoreView(LoadMoreView loadingView)
loadingView - 加载视图public int getLoadMoreViewCount()
public int getLoadMoreViewPosition()
public boolean isLoading()
public void loadMoreEnd()
public void loadMoreEnd(boolean gone)
gone - if true gone the load more viewpublic void loadMoreComplete()
public void loadMoreFail()
public void setEnableLoadMore(boolean enable)
enable - True if load more is enabled, false otherwise.public boolean isLoadMoreEnable()
public void setDuration(int duration)
duration - The length of the animation, in milliseconds.public void setNewData(java.util.List<T> data)
data - @Deprecated
public void add(int position,
T item)
addData(int, Object) insteadposition - item - public void addData(int position,
T data)
position - public void addData(T data)
public void remove(int position)
position - public void setData(int index,
T data)
public void addData(int position,
java.util.Collection<? extends T> newData)
position - the insert positionnewData - the new data collectionpublic void addData(java.util.Collection<? extends T> newData)
newData - the new data collectionpublic void replaceData(java.util.Collection<? extends T> data)
setNewData(List),
it doesn't change the mData referencedata - data collectionpublic java.util.List<T> getData()
public T getItem(int position)
position - Position of the item whose data we want within the adapter's
data set.@Deprecated public int getHeaderViewsCount()
ViewGroup.getChildCount() of getHeaderLayout() to replace.@Deprecated public int getFooterViewsCount()
ViewGroup.getChildCount() of getFooterLayout() to replace.public int getHeaderLayoutCount()
public int getFooterLayoutCount()
public int getEmptyViewCount()
public int getItemCount()
public int getItemViewType(int position)
protected int getDefItemViewType(int position)
public K onCreateViewHolder(android.view.ViewGroup parent, int viewType)
public void notifyLoadMoreToLoading()
public void enableLoadMoreEndClick(boolean enable)
enable - public void onViewAttachedToWindow(K holder)
holder - protected void setFullSpan(RecyclerView.ViewHolder holder)
holder - True if this item should traverse all spans.public void onAttachedToRecyclerView(RecyclerView recyclerView)
protected boolean isFixedViewType(int type)
public void setHeaderViewAsFlow(boolean headerViewAsFlow)
public boolean isHeaderViewAsFlow()
public void setFooterViewAsFlow(boolean footerViewAsFlow)
public boolean isFooterViewAsFlow()
public void setSpanSizeLookup(BaseQuickAdapter.SpanSizeLookup spanSizeLookup)
spanSizeLookup - instance to be used to query number of spans occupied by each itempublic void onBindViewHolder(K holder, int position)
holder - position - getDefItemViewType(int)public void setOnItemClick(android.view.View v,
int position)
v - position - public boolean setOnItemLongClick(android.view.View v,
int position)
v - position - public void setMultiTypeDelegate(MultiTypeDelegate<T> multiTypeDelegate)
public MultiTypeDelegate<T> getMultiTypeDelegate()
protected K onCreateDefViewHolder(android.view.ViewGroup parent, int viewType)
protected K createBaseViewHolder(android.view.ViewGroup parent, int layoutResId)
protected K createBaseViewHolder(android.view.View view)
view - viewpublic android.widget.LinearLayout getHeaderLayout()
public android.widget.LinearLayout getFooterLayout()
public int addHeaderView(android.view.View header)
header - public int addHeaderView(android.view.View header,
int index)
addHeaderView(View).header - index - the position in mHeaderLayout of this header.
When index = -1 or index big= child count in mHeaderLayout,
the effect of this method is the same as that of addHeaderView(View).public int addHeaderView(android.view.View header,
int index,
int orientation)
header - index - orientation - public int setHeaderView(android.view.View header)
public int setHeaderView(android.view.View header,
int index)
public int setHeaderView(android.view.View header,
int index,
int orientation)
public int addFooterView(android.view.View footer)
footer - public int addFooterView(android.view.View footer,
int index)
public int addFooterView(android.view.View footer,
int index,
int orientation)
addFooterView(View).footer - index - the position in mFooterLayout of this footer.
When index = -1 or index big= child count in mFooterLayout,
the effect of this method is the same as that of addFooterView(View).public int setFooterView(android.view.View header)
public int setFooterView(android.view.View header,
int index)
public int setFooterView(android.view.View header,
int index,
int orientation)
public void removeHeaderView(android.view.View header)
header - public void removeFooterView(android.view.View footer)
footer - public void removeAllHeaderView()
public void removeAllFooterView()
public void setEmptyView(int layoutResId,
android.view.ViewGroup viewGroup)
public void setEmptyView(int layoutResId)
public void setEmptyView(android.view.View emptyView)
public void setHeaderAndEmpty(boolean isHeadAndEmpty)
isHeadAndEmpty - false will not show headView if the data is empty true will show emptyView and headViewpublic void setHeaderFooterEmpty(boolean isHeadAndEmpty,
boolean isFootAndEmpty)
isHeadAndEmpty - isFootAndEmpty - public void isUseEmpty(boolean isUseEmpty)
isUseEmpty - public android.view.View getEmptyView()
@Deprecated public void setAutoLoadMoreSize(int preLoadNumber)
public void setPreLoadNumber(int preLoadNumber)
protected void startAnim(android.animation.Animator anim,
int index)
anim - index - protected android.view.View getItemView(int layoutResId,
android.view.ViewGroup parent)
layoutResId - ID for an XML layout resource to loadparent - Optional view to be the parent of the generated hierarchy or else simply an object that
provides a set of LayoutParams values for root of the returned
hierarchypublic void openLoadAnimation(int animationType)
animationType - One of ALPHAIN, SCALEIN, SLIDEIN_BOTTOM,
SLIDEIN_LEFT, SLIDEIN_RIGHT.public void openLoadAnimation(BaseAnimation animation)
animation - ObjectAnimatorpublic void openLoadAnimation()
public void isFirstOnly(boolean firstOnly)
firstOnly - true just show anim when first loading false show anim when load the data every timeprotected abstract void convert(K helper, T item)
helper - A fully initialized helper.item - The item that needs to be displayed.public android.view.View getViewByPosition(int position,
int viewId)
public android.view.View getViewByPosition(RecyclerView recyclerView,
int position,
int viewId)
public long getItemId(int position)
position - The position of the item within the adapter's data set whose row id we want.public int expand(int position,
boolean animate,
boolean shouldNotify)
position - position of the itemanimate - expand items with animationshouldNotify - notify the RecyclerView to rebind items, false if you want to do it
yourself.public int expand(int position,
boolean animate)
position - position of the item, which includes the header layout count.animate - expand items with animationpublic int expand(int position)
position - position of the item, which includes the header layout count.public int expandAll(int position,
boolean animate,
boolean notify)
public int expandAll(int position,
boolean init)
position - position of the item, which includes the header layout count.init - whether you are initializing the recyclerView or not.
if true, it won't notify recyclerView to redraw UI.public void expandAll()
public int collapse(int position,
boolean animate,
boolean notify)
position - the position of the item, which includes the header layout count.animate - collapse with animation or not.notify - notify the recyclerView refresh UI or not.public int collapse(int position)
position - the position of the item, which includes the header layout count.public int collapse(int position,
boolean animate)
position - the position of the item, which includes the header layout count.public boolean isExpandable(T item)
public int getParentPosition(T item)
public void setOnItemClickListener(BaseQuickAdapter.OnItemClickListener listener)
listener - The callback that will be invoked.public void setOnItemChildClickListener(BaseQuickAdapter.OnItemChildClickListener listener)
listener - The callback that will runpublic void setOnItemLongClickListener(BaseQuickAdapter.OnItemLongClickListener listener)
listener - The callback that will runpublic void setOnItemChildLongClickListener(BaseQuickAdapter.OnItemChildLongClickListener listener)
listener - The callback that will runpublic final BaseQuickAdapter.OnItemLongClickListener getOnItemLongClickListener()
public final BaseQuickAdapter.OnItemClickListener getOnItemClickListener()
public final BaseQuickAdapter.OnItemChildClickListener getOnItemChildClickListener()
public final BaseQuickAdapter.OnItemChildLongClickListener getOnItemChildLongClickListener()