Giter Club home page Giter Club logo

fast-list's Introduction

logo

Create dynamic, fast and easy recycler view lists. No adapters, no view holders.

Download Twitter URL

Usage

FastList supports 2 types of lists- single layout lists and dynamic lists.

  • Here's how to create a simple single layout list:
        val list = listOf(Item("fast", 1), Item("recycler", 2), Item("view", 1))

        recycler_view.bind(list, R.layout.item) { it : Item ->
            item_text.text = it.value
        }

That's it! The first parameter is the list you want to show, the second is the ID of the layout and the third one is a function for binding each element. It uses Kotlin Extensions, so you can directly address the XML views and set them up.

  • The second type is dynamic lists with multiple layouts:
        val list = listOf(Item("fast", 1), Item("recycler", 2), Item("view", 1))

        recycler_view.bind(list)
                .map(layout = R.layout.item, predicate = { it.type == 1}) {
                    item_text.text = it.value
                }
                .map(layout = R.layout.item_second, predicate = { it.type == 2}) {
                    item_second_text.text = it.value
                }
                .layoutManager(LinearLayoutManager(this))

The map function accepts 3 parameters. The first is the ID of the layout for the type. The second is the predicate function by which you want to sort your items. The last one is the "view holder" binding function for each element. It uses Kotlin Extensions, so you can directly address the XML views and set them up.

You can also update a list in a shown recycler view with this DiffUtils update function:

        ...
        val list2 = listOf(Item("fast", 1))

        recycler_view.update(list2)

Download

Gradle

dependencies {
  implementation 'bg.devlabs.fastlist:fast-list:$latest_version'

}

Maven

<dependency>
  <groupId>bg.devlabs.fastlist</groupId>
  <artifactId>fast-list</artifactId>
  <version>latest_version</version>
  <type>pom</type>
</dependency>

Manually

You can also manually download the library class and use it in your application.


Compatibility

Minimum Android SDK: API level 19


Author

Radoslav Yankov @Radoslav_Y


Getting help

If you spot a problem you can open an issue on the Github page, or alternatively, you can tweet us at @devlabsbg


License

FastList is released under the MIT License.

fast-list's People

Contributors

radoyankov avatar

Watchers

 avatar

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.