Giter Site home page Giter Site logo

topotopo / android-common-recyclerview-adapter Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 1.0 427 KB

Use a single adapter for multiple lists in your app. Remove the boilerplate when binding different types of views to different data models.

License: Apache License 2.0

Kotlin 100.00%
recylcerview android generic-adapter common-adapter adapter databinding dynamic-adapter dynamic-list

android-common-recyclerview-adapter's Introduction

Common RecyclerView Adapter

  • Create a list of different views with its different or the same set of data to bind without the boilerplate code in the RecyclerView Adapter.
  • Use a single adapter for all the recyclerviews in your app.
  • Current version: 1.0.1-snapshot01
  • Built on top of RecyclerView, Databinding

Current version: 1.0.2

Image of Sample App

Setup

In your project’s root build.gradle, check if JCenter repository is added.

buildscript {
    repositories {
        jcenter()     
    }
}

In your app's build.gradle, add the dependency.

implementation 'com.mmicu.commonadapter:commonadapter:1.0.1-snapshot01'

Quick Start

Create a CommonItemHolder for every view type.

data class StatusFeedItemHolder(
    override var data: StatusModel?,
    override var layoutId: Int = R.layout.item_feed_status,
    override var variableId: Int?
) : CommonItemHolder<StatusModel>

Extend CommonRecyclerViewAdapter.

class AppRecyclerViewAdapter(
    listCommonHolder: MutableList<CommonItemHolder<*>>
) : CommonRecyclerViewAdapter(listCommonHolder)

Initialise the adapter.

private val sampleMovieList = mutableListOf<CommonItemHolder<*>>()
private lateinit var recyclerViewAdapter: CommonRecyclerViewAdapter

recyclerViewAdapter = AppRecyclerViewAdapter(
            sampleMovieList
        )

Optional: Add item click listener.

 recyclerViewAdapter.setItemClickListener { pos, data, view ->
            //Code here
        }

License

 Apache License
 Version 2.0, January 2004
 http://www.apache.org/licenses/

Authors

Maxine Micu, [email protected]

android-common-recyclerview-adapter's People

Contributors

topotopo avatar

Watchers

 avatar  avatar

Forkers

kangmifhd

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.