This is a sample project showing how to use EasyListView - A Better RecyclerView
Get rid of the old Recycler View with adapter and have fun showing list of views easily with EasyListView just like Flutter. Use the very easy builder pattern for setting up your list with only 8 to 10 lines of code.
- Android Studio (Gradle build system)*
- A project where you want to add a list of views like RecyclerView
In App Gradle File
dependencies {
...
implementation 'com.github.msayanece:EasyListView:0.0.4'
}
In Project Gradle File
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
-
In your Activity or Fragment : Where you have added the RecyclerView in your layout and get the RecyclerView object of your layout in your Java or Kotlin file and pass it to the SDK.
-
Create a ListTile object to map the getter methods of the model
ListTile<ItemsPOJO> listTile = new ListTile<ItemsPOJO>(ItemsPOJO.class)
.addTitle("getName") //Argument-> method name of the Model to be mapped
.addDescription("getDesc") //Argument-> method name of the Model to be mapped
.addIcon(EasyListView.IconPosition.LEADING, "getImage");
////Argument->LEADING or TRAILING and method name of the Model to be mapped
- Build the EasyListView with your ListTile object.
new EasyListView.Builder<ItemsPOJO>(this)
.addRecyclerView(recyclerView) // Pass your RecyclerView
.addListItems(listItems) // The List of items to display
.addItemModel(ItemsPOJO.class) // The Item Model.class
.addRow(listTile) // Add the ListTile object you have just created
.setCount(5) // Optional set item count
.setOnItemClickListener(this) // Optional set on click listener
.setOnBindViewHolderCalledListener(this) // Optional set on bind view holder to write your own logic
.Build();
-
In your Activity or Fragment : Where you have added the RecyclerView in your layout and get the RecyclerView object of your layout in your Java or Kotlin file and pass it to the SDK.
-
Create your custom layout for the row template.
-
Create the model class and annotate with
@ID(viewResID)
to the correspondinggetter
method for setting model data automatically without any logic, when the list loads.
You can skip this step, if you are going to write your own logic inside the onBindViewHolderListener using the setOnBindViewHolderCalledListener() method.
- Build the EasyListView with your own custom objects.
new EasyListView.Builder<CustomItemsPOJO>(this)
.addRecyclerView(recyclerView) //Mandatory, the RecyclerView object
.addListItems(listItems) //Mandatory, the list of Items (Models)
.addItemModel(CustomItemsPOJO.class) //Mandatory, the Model .class
.setCount(5) //Optional, set count of items in the list
.addLayoutManager(new LinearLayoutManager(this)) //Optional, The SDK will use this layout manager only for the custom setup
.addRow(R.layout.child_layout) // The custom layout of Recycler child
.setOnItemClickListener(this) //Optional
.setOnBindViewHolderCalledListener(this) //Optional, if you want to execute your own logic
.Build();
- If you want you may write your own logic inside the callback methods of the OnBindViewHolderCalledListener.
For more detailed documentation please see EasyListView - A Better RecyclerView
- Fork this repository to your github profile (On the Top-Right corner).
- Copy the URL of your repository on your profile from your browser.
- Open Android Studio.
- click on File --> New --> Project from Version Control --> Git.
- Paste the URL on GIT Repository URL Box.
- Select your Parent Directory (Where the project should be installed in your local Computer).
- Change the Directory name if you want.
- Click on Clone. ( After cloning if any pop-up appears, Click on Remove Selected)
And You are done.
After gradle build finished, you can run it on your Emulator or real device by clicking on the green triangular buuton on the top.
Gradle
Sayan Mukherjee - Android Developer See also the list of contributors who participated in this project.
This project is free and open source to use in any project if you want.
This Project is based on The EasyListView a better RecyclerView of Android. Other concepts of Java like circleimageview, SuperNova-Emoji, recyclerview and Google's Glide library has been used in this project.