PowerRecyclerView??
V1.0.0
- ??????????
V1.0.1
-
??????
GridLayoutManager
-
?????????
V1.0.2
- ??
SwipRefreshRecycleView
?PowerRecyclerView
- ??
RefreshRecycleAdapter
?PowerAdapter
- ????????? ?
Adapter
?????RecycleView
- ?????
PowerRecyclerView
???????????? - ?????
ScrollBar
?? - ?????????bug
- ??????Item???Item???
V1.0.3
PowerAdapter
??????
V1.2.0
- ???
PowerRecyclerView
,??????SwipeRefreshLayout
?????????????????????????????Header
,???? PowerRefresh - ??????????Item????
- ???
PowerHolder
?????Holder
- ???? ???? ? ???? ?????
0?????Adapter ?? RefreshRecycleAdapter?
mRecycleView.setLayoutManager(new LinearLayoutManager(this));
mRecycleView.setAdapter(adapter);
mRecycleView.setOnRefreshListener(this);
adapter = new MyRecycleAdapter();
adapter.setLoadMoreListener(this);
adapter.setTotalCount(10);
1??????????????
RecyclerView.ViewHolder onViewHolderCreate(ViewGroup parent, int viewType);
void onViewHolderBind(RecyclerView.ViewHolder holder, int position);
2??????????????
boolean isHasMore();
//??????????????????? void isLoadingMore();
void loadMoreError();
3????????????
void setLoadMoreView(View view);
RecyclerView.ViewHolder onBottomViewHolderCreate(View loadMore);
void onBottomViewHolderBind(RecyclerView.ViewHolder holder, int loadState);
4???????????????set?append?????
void setList(List<T> data);
void appendList(List<T> data);
@Override public final void appendList(List<T> data) {
int positionStart = list.size();
list.addAll(data);
int itemCount = list.size() - positionStart;
if (positionStart == 0) {
notifyDataSetChanged();
}
else {
notifyItemRangeInserted(positionStart + 1, itemCount);
}
}
5??? ???????????
mRecycleView.setOnItemClickListener(new AdapterLoader.OnItemClickListener() {
@Override
public void onItemClick(View itemView, int position) {
toast.setText("????" + position);
toast.show();
}
}
);
adapter.setSelectedMode(AdapterLoader.SingleMode);
adapter.updateSelectMode(true);
adapter.setOnItemSelectListener(new AdapterLoader.OnItemSelectedListener() {
@Override
public void onItemSelected(View view, int position, boolean isSelected) {
Log.e("TAG", "onItemSelected: " + position + "::" + isSelected);
}
@Override
public void onNothingSelected() {
Log.e("TAG", "onNothingSelected: ");
}
}
);
6?GridLayoutManager??SpanSize
mRecycleView.setSpanSizeCallBack(new SwipeRefreshRecycleView.SpanSizeCallBack() {
@Override
public int getSpanSize(int position) {
return 1;
}
}
);
7???SpacesItemDecoration????????
/** * * @param space item????? * @param count ?? * @param showEdge ???????? */ public SpacesItemDecoration(int space, int count, boolean showEdge) {
this.spacing = space;
this.spanCount = count;
this.showEdge = showEdge;
pre = spacing * 1.0f / spanCount;
}
decor = new SpacesItemDecoration(30, 3, true);
mRecycleView.getRecycle().addItemDecoration(decor);
8?????
//?????TouchHelperCallback
TouchHelperCallback callback = new TouchHelperCallback();
//??????
callback.setItemDragSwipeCallBack(adapter);
//?????ItemTouchHelper
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(callback);
//?????RecycleView
itemTouchHelper.attachToRecyclerView(mRecycleView.getRecycle());
9????????
//1??????? adapter.setLoadMoreView(LayoutInflater.from(this).inflate(R.layout.layout_foot_self, mRecycleView, false));
//2??????Holder ??Adapter?????? @Override public RecyclerView.ViewHolder onBottomViewHolderCreate(View loadMore) {
return new BottomViewHolder(loadMore);
}
@Override public void onBottomViewHolderBind(RecyclerView.ViewHolder holder, int loadState) {
((BottomViewHolder) holder).onBind(getLoadMoreListener(), loadState);
}
PS: ????RecyclerView????? mRecycleView.setItemAnimator(new DefaultAnimator());