Android library for easy to use RecyclerView
- Paginate : Paginate for RecyclerView
- ItemClick : Item Click for RecyclerView
- Expandable : Expandable for RecyclerView
- FastSmoothScroll : SmoothScroll speed scroll for RecyclerView
Gradle:
compile 'com.bobomee.android:recyclerviewhelper:1.0.8'
- Paginate :PaginateFragment
- ItemClick :ItemClickFragment
- Expanable :ExpandRecyclerFragment
- FastScroll : FastScrollFragment
ItemClickSupport itemClickSupport = ItemClickSupport.from(recyclerView).add();
itemClickSupport.addOnItemClickListener(new ItemClick.OnItemClickListener() {
@Override public void onItemClick(RecyclerView parent, View child, int position, long id) {
mToast.setText("Item clicked: " + position);
mToast.show();
mBaseRecyclerAdapter.delete(position);
}
});
itemClickSupport.addOnItemLongClickListener(new ItemLongClick.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(RecyclerView parent, View child, int position, long id) {
mToast.setText("Item long pressed: " + position);
mToast.show();
return false;
}
});
mRoot = new ArrayList<>();
TreeNode<Genre> genre = new TreeNode<Genre>(new Genre("Jazz", R.drawable.ic_saxaphone);
genre.addChilds(TreeNode ...);
//...
mRoot.add(genre);
TreeViewAdapter treeViewAdapter =
new TreeViewAdapter(mRoot, Arrays.asList(new ArtistViewBind(), new GenreViewBinder()));
rv.setAdapter(treeViewAdapter);
treeViewAdapter.addExpandCollapseListener(new ExpandCollapseListener() {
@Override public void onGroupExpanded(RecyclerView.ViewHolder _holder, TreeNode _treeNode) {
//...
}
@Override public void onGroupCollapsed(RecyclerView.ViewHolder _holder, TreeNode _treeNode) {
//..
}
@Override public void toggle(RecyclerView.ViewHolder _holder, TreeNode _treeNode) {
//ToastUtil.show(getActivity(),"toggle");
}
});
treeViewAdapter.addOnTreeNodeClickListener(new OnTreeNodeClickListener() {
@Override public void onClick(TreeNode node, RecyclerView.ViewHolder holder) {
//ToastUtil.show(getActivity(), "addOnTreeNodeClick");
}
});
mRecyclerView.setAdapter(mItemAdapter);
RecyclerFastScroller fastScroller = (RecyclerFastScroller) view.findViewById(R.id.fast_scroller);
fastScroller.setBubbleTextCreator(mItemAdapter);
fastScroller.setRecyclerView(mRecyclerView);
fastScroller.addOnScrollStateChangeListener(this);
int color = getColorAccent(mActivity);
fastScroller.setAccentColor(color);
//#TopSnappedSmoothScroller#calculateSpeedPerPixel
@Override
protected float calculateSpeedPerPixel(DisplayMetrics displayMetrics) {
return MILLISECONDS_PER_INCH / displayMetrics.densityDpi;
}
// smoothscroll
mRecyclerView.setLayoutManager(
new SmoothScrollStaggeredLayoutManager(mActivity,2, StaggeredGridLayoutManager.VERTICAL));
mFloatingActionButton.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
mRecyclerView.smoothScrollToPosition(0);
}
});
Paginate.Callbacks callbacks = new Paginate.Callbacks() {
@Override
public void onLoadMore() {
// Load next page of data (e.g. network or database)
}
@Override
public boolean isLoading() {
// Indicate whether new page loading is in progress or not
return loadingInProgress;
}
@Override
public boolean hasLoadedAllItems() {
// Indicate whether all data (pages) are loaded or not
return hasLoadedAllItems;
}
};