A not-so-powerful and yet easy peasy tool to setup your Android RecyclerView in a convenient way. Be practical, may not be fancy.
-
Provides various RecyclerView presentation template:
- Vertical List
- Horizontal List
- Basic Grid
- Vertical Staggered Grid
- Horizontal Staggered Grid
-
Provides handy way to setup RecyclerView presentation without boilerplate by using extending abstract class during compilation:
PeasyRecyclerView.VerticalList
PeasyRecyclerView.HorizontalList
PeasyRecyclerView.BasicGrid
PeasyRecyclerView.VerticalStaggeredGrid
PeasyRecyclerView.HorizontalStaggeredGrid
-
Provides handy way to setup RecyclerView presentation without boilerplate by using method calls during runtime:
asVerticalListView()
asHorizontalListView()
asGridView()
asVerticalStaggeredGridView()
asHorizontalStaggeredGridView()
-
Elimates needs of anonymous inner-classes for listeners by overriding methods intuitively:
onItemClick(...)
onItemLongClick(...)
onViewScrolled(...)
onViewScrollStateChanged(...)
onViewReachingEndOfList(...)
onInterceptTouchEvent(...)
-
Retains Android promoted implement in better ways, no proprietary knowledge required to start with, you will still see these:
onCreateViewHolder(...)
onBindViewHolder(...)
getItemViewType(...)
- Let's set up RecyclerView as Vertical List
public final class SampleRV extends PeasyRecyclerView.VerticalList<PeasyRVInbox.ModelInbox> {
public SampleRV(@NonNull Context context, RecyclerView recyclerView, ArrayList arrayList) {
super(context, recyclerView, arrayList);
}
@Override
protected PeasyViewHolder onCreateViewHolder(LayoutInflater inflater, ViewGroup parent, int viewType) {
// TODO Do Nothing but initializing view holder with layout_id
return null;
}
@Override
protected int getItemViewType(int position, PeasyRVInbox.ModelInbox item) {
// TODO Do Nothing but returning view type accordingly
return 0;
}
@Override
protected void onBindViewHolder(Context context, PeasyViewHolder holder, int position, PeasyRVInbox.ModelInbox item) {
// TODO Do Nothing but checking instance and populating item to view with view holder
}
}
- Elimates boilerplate implementation such as listeners
- Just override intuitively what you can find
- Popular implementation
onItemClick
,onViewScrolled
public final class SampleRV extends PeasyRecyclerView.VerticalList<PeasyRVInbox.ModelInbox> {
public SampleRV(@NonNull Context context, RecyclerView recyclerView, ArrayList arrayList) {
super(context, recyclerView, arrayList);
}
@Override
protected PeasyViewHolder onCreateViewHolder(LayoutInflater inflater, ViewGroup parent, int viewType) {
// TODO Do Nothing but initializing view holder with layout_id
return null;
}
@Override
protected int getItemViewType(int position, PeasyRVInbox.ModelInbox item) {
// TODO Do Nothing but returning view type accordingly
return 0;
}
@Override
protected void onBindViewHolder(Context context, PeasyViewHolder holder, int position, PeasyRVInbox.ModelInbox item) {
// TODO Do Nothing but checking instance and populating item to view with view holder
}
@Override
public void onItemClick(View view, int viewType, int position, PeasyRVInbox.ModelInbox item, PeasyViewHolder viewHolder) {
// TODO Do Nothing but defining click action on PeasyRVInbox item
super.onItemClick(view, viewType, position, item, viewHolder);
}
@Override
public boolean onItemLongClick(View view, int viewType, int position, PeasyRVInbox.ModelInbox item, PeasyViewHolder viewHolder) {
// TODO Do Nothing but defining long click action on PeasyRVInbox item
return super.onItemLongClick(view, viewType, position, item, viewHolder);
}
@Override
public void onViewScrolled(RecyclerView recyclerView, int dx, int dy) {
// TODO Everything during RecyclerView scrolling
super.onViewScrolled(recyclerView, dx, dy);
}
@Override
public void onViewScrollStateChanged(RecyclerView recyclerView, int newState) {
// TODO Everything after RecyclerView scroll state updated
super.onViewScrollStateChanged(recyclerView, newState);
}
@Override
public void onViewReachingEndOfList(RecyclerView recyclerView, int threshold) {
// TODO Everything during RecyclerView scrolled to reach End of List
super.onViewReachingEndOfList(recyclerView, threshold);
}
@Override
public void onViewInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
super.onViewInterceptTouchEvent(rv, e);
}
}
- Activity which host
android.support.v7.widget.RecyclerView
- Child class of
PeasyRecyclerView
- Glue provided
RecyclerView
withRecyclerView.Adapter
with desiredPeasyRecyclerView.Presentation
- Serves as model T to
PeasyRVInbox<T>
- Serve as view holders to
PeasyRVInbox<T>
- Serve as Coordinator Content to
PeasyRVInbox<T>
Please checkout source code
Please checkout live demo
dependencies {
implementation 'com.github.kopihao:peasy-recyclerview:1.0.+'
}
For documentation and additional information please visit official website.
For enquiries and solutions please visit stackoverflow.
Licensed under the Apache License, Version 2.0 (the "License");
Copyright 2013 Kopihao.MY