Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Expandingpager | 1,880 | 3 years ago | 4 | Java | ||||||
ExpandingPager is a card peek/pop controller | ||||||||||
Flipviewpager.draco | 1,845 | 4 years ago | 6 | Java | ||||||
This project aims to provide a working page flip implementation for usage in ListView. | ||||||||||
Loopingviewpager | 992 | 4 years ago | 23 | apache-2.0 | Java | |||||
An android ViewPager extension allowing infinite scrolling | ||||||||||
Rollviewpager | 926 | 4 years ago | 34 | Java | ||||||
A ViewPager can auto play and loop | ||||||||||
Adaptablebottomnavigation | 840 | 3 years ago | 7 | Java | ||||||
A simpler way for implementing the Bottom Navigation View on Android | ||||||||||
Expandablepager | 717 | 7 years ago | other | Java | ||||||
ViewPager that slides vertically. | ||||||||||
Creative Viewpager | 654 | 5 years ago | 6 | apache-2.0 | Kotlin | |||||
Creative View Pager easy to use in Android | ||||||||||
Banner Slider | 491 | a year ago | 82 | Java | ||||||
Banner slider is an easy to use library for implement image sliders in android apps. | ||||||||||
Banner | 453 | 2 years ago | 3 | apache-2.0 | Java | |||||
🔥🔥ViewPager,ViewPager2无限轮播功能。自定义Indicator,支持一屏三页,支持仿魅族banner效果。极其简单的使用方式 | ||||||||||
Efficientadapter | 427 | 5 | 1 | 4 years ago | 5 | February 21, 2021 | 2 | apache-2.0 | Java | |
Create a new adapter for a RecyclerView or ViewPager is now much easier. |
Create a new adapter for a RecyclerView or ViewPager is now much easier.
Create a list of elements into a RecyclerView or ViewPager is not that easy for a beginner, and repetitive for others. The goal of this library is to simplify that for you.
Create a class ViewHolder (BookViewHolder
for example). The method updateView
will be call with the object, when an update of your view is require:
public class BookViewHolder extends EfficientViewHolder<Book> {
public BookViewHolder(View itemView) { super(itemView); }
@Override
protected void updateView(Context context, Book object) {
TextView textView = findViewByIdEfficient(R.id.title_textview);
textView.setText(object.getTitle());
// or just
setText(R.id.title_textview, object.getTitle());
}
}
Give this ViewHolder class to the constructor of the adapter (SimpleAdapter) of your RecyclerView, with the resource id of your item view and the list of objects:
EfficientRecyclerAdapter<Plane> adapter = new EfficientRecyclerAdapter<Plane>(R.layout.item_book, BookViewHolder.class, listOfBooks);
recyclerView.setAdapter(adapter);
And that's it!
It's also working with a ViewPager:
EfficientPagerAdapter<Plane> adapter = new EfficientPagerAdapter<Plane>(R.layout.item_book, BookViewHolder.class, listOfBooks);
viewPager.setAdapter(adapter);
For a list of different kind of objects, layout, viewholder…
EfficientRecyclerAdapter adapter = new EfficientRecyclerAdapter(generateListObjects()) {
@Override
public int getItemViewType(int position) {
if (get(position) instanceof Plane) {
return VIEW_TYPE_PLANE;
} else {
return VIEW_TYPE_BOOK;
}
}
@Override
public Class<? extends EfficientViewHolder> getViewHolderClass(int viewType) {
switch (viewType) {
case VIEW_TYPE_BOOK:
return BookViewHolder.class;
case VIEW_TYPE_PLANE:
return PlaneViewHolder.class;
default:
return null;
}
}
@Override
public int getLayoutResId(int viewType) {
switch (viewType) {
case VIEW_TYPE_BOOK:
return R.layout.item_book;
case VIEW_TYPE_PLANE:
return R.layout.item_plane;
default:
return 0;
}
}
};
Because findViewById(int)
is CPU-consuming (this is why we use the ViewHolder pattern), this library use a findViewByIdEfficient(int id)
into the ViewHolder class.
You can use it like a findViewById(int id)
but the view return will be cached to be returned into the next call.
Your view id should be unique into your view hierarchy, but sometimes is not that easy (with an include for example). It's now easier to find a subview by specify the parent of this subview with findViewByIdEfficient(int parentId, int id)
to say "the view with this id into the parent with this id".
Your ViewHolder class can override the method isClickable()
to tell is this element is clickable or not.
By default, the view is clickable if you have a listener on your adapter.
This library includes the proguard configuration file. If you want to add it manually:
-keepclassmembers public class * extends com.skocken.efficientadapter.lib.viewholder.EfficientViewHolder {
public <init>(...);
}
dependencies {
compile 'com.skocken:efficientadapter:2.4.0'
}
If you are still using the deprecated Android Support Library (instead of AndroidX), please use the dependency 2.3.X instead.
Please fork this repository and contribute back using pull requests.
Any contributions, large or small, major features, bug fixes, additional language translations, unit/integration tests are welcomed and appreciated but will be thoroughly reviewed and discussed.