Skip to content

📟Very easy endless scrolled, onClick item and simple use recyclerView adapter

License

Notifications You must be signed in to change notification settings

FarshidRoohi/CustomAdapterRecyclerview

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Custom Adapter RecyclerView

API Android Arsenal

Very simple use android recyclerView adapter and endlessScrolled in android support library recyclerView

  • Manage Loading and Error Layout in The List Row
  • Ability add custom layout in progress pagination and default layout
  • Support linear, Grid, StaggeredGrid LayoutManger for endless
  • Clean to uses
screenShot:

screen show

Recyclerview version

gradle :
  implementation 'androidx.recyclerview:recyclerview:$VERSION'
  implementation 'io.github.farshidroohi:customAdapterRecycleView:2.1.4'

Example

Sample Adapter

class MyAdapter : AdapterRecyclerView<String?>(R.layout.my_item, R.layout.progress_view, R.layout.item_error,R.id.btnTrayAgain) {

    override fun onBindView(viewHolder: ItemViewHolder, position: Int, context: Context, element: String?) {
        val binding = MyItemBinding.bind(viewHolder.itemView)
        binding.myTitle.text = element
    }

}

View Binding:

android {
...

  buildFeatures {
        viewBinding = true
   }
   
}

Sample Single View Type Adapter Code:

class MyAdapter : AdapterRecyclerView<String?>(
    R.layout.my_item,
    R.layout.progress_view,
    R.layout.item_error,
    R.id.btnTrayAgain
) {

    override fun onBindView(
        viewHolder: RecyclerView.ViewHolder,
        position: Int,
        context: Context,
        element: String?
    ) {
        val binding = MyItemBinding.bind(viewHolder.itemView)
        binding.txtTitle.text = element
    }

}

Sample Use Adapter:

    val myAdapter = MyAdapter()
    
    myAdapter.onRetryClicked = {
         // onClick Error Button
     }
     
     
    recyclerView.onLoadMoreListener {
           // set onLoad More Listener for Pagination
     }
       
    recyclerView.onItemClickListener(
           onClickItem = { position ->
                // OnClick Item
        }, onLongClickItem = { position ->
               // OnLong Click Item
     })

Multi View Type Sample: Code