• Stars
    star
    289
  • Rank 143,419 (Top 3 %)
  • Language
    Kotlin
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Create fast, dynamic recycler views. No adapter, no view holders

logo

Create dynamic, fast and easy recycler view lists (including ViewPager2). 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, position: Int ->
            item_text.text = it.value
        }

That's it (for ViewPager2, just replace recycler_view with the ViewPager2 instance)! 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: Item, _ -> it.type == 1}) { item: Item, p: Int ->
                    item_text.text = it.value
                }
                .map(layout = R.layout.item_second, predicate = { it: Item, _ -> it.type == 2}) { item: Item, p: Int ->
                    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.

If you need control over your view's creation, you can pass a factory that allows you to create your own view:

        val list = listOf(Item("fast", 1), Item("recycler", 2), Item("view", 1))

        recycler_view.bind(list)
                .map(layoutFactory = LocalFactory(this), predicate = { it: Item, _ -> it.type == 1}) { item: Item, p: Int ->
                    item_text.text = it.value
                }
                .map(layout = R.layout.item_second, predicate = { it: Item, _ -> it.type == 2}) { item: Item, p: Int ->
                    item_second_text.text = it.value
                }
                .layoutManager(LinearLayoutManager(this))
				...
	class LocalFactory(val activity: AppCompatActivity) : LayoutFactory {
		override fun createView(parent: ViewGroup, type: Int): View {
			val view = LayoutInflater.from(activity).inflate(R.layout.item,
					parent, false)
			//Manipulate view as needed 
			return view		
		}
	}				

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

Manually

The recommended way to download is to copy the the library class and use it in your application.

Important: For the manual download you need Kotlin extensions to be enabled. To turn them on, simply place "apply plugin: 'kotlin-android-extensions'" inside of your app build.gradle

Gradle

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

Getting help

Dev Labs @devlabsbg

Radoslav Yankov @rado__yankov

Under MIT License.

More Repositories

1

transitioner

A library for dynamic view-to-view transitions
Kotlin
2,051
star
2

swift-video-generator

Swift
635
star
3

fullscreen-video-view

Java
98
star
4

football-stats

Tracking of football players and analysis
Python
95
star
5

twinkle

Twinkle Android view elements in Kotlin
Kotlin
61
star
6

sportify

Football match prediction game with simple rules, built on Symfony
JavaScript
33
star
7

flying-fab

Kotlin
19
star
8

samples

Code samples, used in our public articles, tutorials and courses
Swift
18
star
9

walk-detector

An android app that notifies you when you are walking for selected period of time
Java
13
star
10

SKCache

A caching library for each type in iOS
Swift
9
star
11

geofencing

Leaflet geofencing example implemented on ReactJS
JavaScript
7
star
12

devlabs-internal-code-conventions

DevLabs internal code conventions for writing beautiful code.
7
star
13

laravel-csv-importer

A CSV importer/exporter library for Laravel
PHP
6
star
14

hr-bot

HR Bot that finds the right persons for a Recruiter's job
PHP
6
star
15

game-scorer

Android application which helps you and your friends to keep track of the score in a game
Kotlin
6
star
16

gmail-dynamic-images

Update Gmail cached images with the real ones
JavaScript
4
star
17

dev-challenge

Gamified learning experience TODO list.
TypeScript
4
star
18

rap-generator

When all you need is a little 011100100110000101110000
JavaScript
3
star
19

laravel-csv-importer-examples

Examples for the Laravel CSV import/export package
PHP
3
star
20

conflist

[Work in Progress] Conflist: Product Hunt for conferences.
JavaScript
2
star
21

photo-watch-face

Watch face that uses images from folder for background
Java
2
star
22

tamabotchi

I am not a human. Or am I?
JavaScript
2
star
23

devlabs-website

Our cool, shiny, gingerbread & a bit legacy website!
HTML
2
star
24

hello-ue

Hello world app for UE Varna students.
JavaScript
2
star
25

devstoned

A revolution in digital board games
JavaScript
2
star
26

record-rtc-demo

JavaScript
1
star
27

rate-me-v2

JavaScript
1
star
28

carpooling

1
star
29

organic-skeleton

A boilerplate for building organic NodeJS web applications.
JavaScript
1
star
30

VideoGenerator

An Image to Video generator which stores the output in Photo Library
Swift
1
star
31

carpooling-app

JavaScript
1
star