This library will no longer be updated ๐Ÿ˜ญ

Overview


ํ•œ๊ตญ์–ด

Download Android CI

No more boilerplate adapters and view holders.
Slush will make using RecyclerView easy and fast.

The goal of this project is to make RecyclerView, which is not very complicated, possible with Slush.

Features

  • ItemClickListener
  • DataBinding
  • DiffCallback
  • ObservableArrayList
  • LiveData
  • MultiType Adapter
  • (Divider)ItemDecoration
  • Swipe option

Setup

Add a dependency below at your build.gradle(app)

dependencies {
    implementation 'in.seunghyun:slush:1.2.2'
}

Basic Usage

You can use all the features with a single class called Slush.

Basically, you have to write some codes below. (Here, Replace the SimpleItem part into your item class to use.)

Slush.SingleType<SimpleItem>()
    .setItemLayout(R.layout.simple_binding_item) // Set item layout
    .setLayoutManager(LinearLayoutManager(this)) // Set LayoutManager (No need to write if already exists)
    .onBind { view, item ->
        view.itemName.text = item.name
    }
    .into(recyclerView)

Initialize views in item layout in onBind. (Similar to onBindViewHolder of RecyclerView Adapter)

ItemListEditor

ItemListEditor is an interface that allows you to edit the item list.

val result = Slush.SingleType<SimpleItem>()
    // Omit intermediate code
    .into(recyclerView)
val itemListEditor = result.itemListEditor

The available methods are listed here.

DataBinding

Slush supports data binding.

You should change onBind part to onBindData to use data binding.

.onBindData<SimpleItemBinding> { binding, item ->
    binding.item = item
}

And put your generated binding class into SimpleItemBinding part.

LiveData, ObservableList

If you use LiveData or ObservableList, you don't need to use ItemListEditor because slush will automatically observe the list and update RecyclerView.

LiveData

val itemsLiveData = MutableLiveData<List<SimpleItem>>()

Slush.SingleType<SimpleItem>()
    // Omit intermediate code
    .setItems(itemsLiveData, lifecycleOwner)
    .into(recyclerView)

Full code

Furthermore

BasicDiffCallback is applied by default when using LiveData.
If you don't want to use DiffCallback, you can put false as the third argument of setItems

.setItems(itemsLiveData, lifecycleOwner, false)

ObservableList

val observableItems = ObservableArrayList<SimpleItem>()

Slush.SingleType<SimpleItem>()
    // Omit intermediate code
    .setItems(observableItems)
    .into(recyclerView)

Full code

Furthermore

Slush does not remove the observer automatically.
So you can use ObserveController to remove the observer.

val result = Slush.SingleType<SimpleItem>()
    // Omit intermediate code
    .setItems(observableItems)
    .into(recyclerView)

val observeController = ObserveController(result)
observeController.stopObserving()

Options

You can apply these options selectively.

setItems

.setItems(items)

Set an initial item list.

onItemClick

.onItemClick { clickedView, position ->
    Log.d(TAG, "Clicked: $position")
}

Set a listener to be executed when item is clicked.

setDiffCallback

.setDiffCallback(BasicDiffCallback())

Set a DiffCallback to be used when you call changeAll in ItemListEditor
By default, calling changeAll replaces all data in the list, but if you set DiffCallback, only the modified part is changed, so animation occurs.
You can also use custom DiffCallback by inheriting SlushDiffCallback.

Samples

You can also see the sample codes here.

License

MIT License

Copyright (c) 2020 SeungHyun

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
Comments
  • onItemClick passing incorrect position

    onItemClick passing incorrect position

    nirock : I notice on your adapter's (SingleTypeAdapter) onBindViewHolder your using position to bind the data and those positions is later used to handle click event on respective ViewHolders (SingleTypeViewHolder,SingleTypeBindingViewHolder). This could lead to some issues after adding new item or removing items from recycler-view, Since onBindViewHolder not called on all the view on such cases to update the position. You better use getAdapterPosition to bind data and use getLayoutPosition on click events to get the clicked item. You may refer to this article for more: https://medium.com/@noureldeen.abouelkassem/difference-between-position-getadapterposition-and-getlayoutposition-in-recyclerview-80279a2711d1

    Thank you @nirocknrk

    fix important 
    opened by MinSeungHyun 0
  • Header View

    Header View

    If i might suggested another feature: A different header view that is displayed as the first item would be awesome could be something like this in the builder: addHeader(R.layout.header) { view -> ... }

    And also a footer as the last item should be added.

    I think then this library really suits all basic needs one can wish for ๐Ÿ˜Ž

    enhancement 
    opened by ueen 7
  • Divider

    Divider

    found this great library for dividers (especially recyclerViewDividerAsSpace) https://github.com/fondesa/recycler-view-divider maybe it could be integrated :)

    really love this library, let me know if you want me to make another PR

    enhancement 
    opened by ueen 0
  • Basic Diff

    Basic Diff

    added onDiffCallback to Slush with

    • areItemsTheSame
    • areContentsTheSame (defaults to false)

    just to determine if some unique identifier is the same allowing for smoother item animations

    includes https://github.com/MinSeungHyun/slush/pull/20

    opened by ueen 0
  • Swipe actions

    Swipe actions

    added swipeActions, use like this:

    .setSwipeActions(SlushSwipeActions<SimpleItem>()
                    .setLeft(SlushSwipeActions.Properties(icon = R.drawable.ic_left, color = getColor(R.color.blue), text = "Left"), 
                        object : SlushSwipeActions.SwipeAction<SimpleItem> {
                        override fun onSwipe(position: Int, item: ITEM) {
                            TODO("Not yet implemented")
                        }
                    }))
    
    opened by ueen 0
Releases(1.2.2)
Owner
SeungHyun
ํ•˜๊ณ  ์‹ถ์€๊ฒŒ ๋งŽ์€ ์•ˆ๋“œ๋กœ์ด๋“œ ๊ฐœ๋ฐœ์ž
SeungHyun
RecyclerView extension library which provides advanced features. (ex. Google's Inbox app like swiping, Play Music app like drag and drop sorting)

Advanced RecyclerView This RecyclerView extension library provides Google's Inbox app like swiping, Play Music app like drag-and-drop sorting and expa

Haruki Hasegawa 5.2k Dec 23, 2022
Android library providing simple way to control divider items (ItemDecoration) of RecyclerView

RecyclerView-FlexibleDivider Android library providing simple way to control divider items of RecyclerView Release Note [Release Note] (https://github

Yoshihito Ikeda 2.4k Dec 18, 2022
Android Library to provide swipe, click and other functionality to RecyclerView

RecyclerViewEnhanced Android Library to provide swipe, click and other functionality to RecyclerView Usage Add this to your build.gradle file dependen

Nikhil Panju 1k Dec 29, 2022
Dividers is a simple Android library to create easy separators for your RecyclerViews

Dividers Dividers is an Android library to easily create separators for your RecyclerViews. It supports a wide range of dividers from simple ones, tha

Karumi 490 Dec 28, 2022
Android library defining adapter classes of RecyclerView to manage multiple view types

RecyclerView-MultipleViewTypeAdapter RecyclerView adapter classes for managing multiple view types Release Note [Release Note] (https://github.com/yqr

Yoshihito Ikeda 414 Nov 21, 2022
Android library for RecyclerView to manage order of items and multiple view types.

recyclerview-binder Android Library for RecyclerView to manage order of items and multiple view types. Features Insert any items to wherever you want

Satoru Fujiwara 185 Nov 15, 2022
The library that removes all boilerplate code allowing you to display lists with few lines of code.

VsRecyclerView The library that removes all boilerplate code allowing you to display lists with few lines of code. Gradle androidExtensions { expe

Valeriy Shtaits 13 Jun 19, 2021
An efficient TabLayout library implemented with RecyclerView.

RecyclerTabLayout An efficient TabLayout library implemented with RecyclerView. Features Efficient when having many tabs Easy setup with ViewPager (sa

Shinichi Nishimura 1.3k Dec 9, 2022
Android Library to provide swipe, click and other functionality to RecyclerView

RecyclerViewEnhanced Android Library to provide swipe, click and other functionality to RecyclerView Usage Add this to your build.gradle file dependen

Nikhil Panju 1k Dec 29, 2022
the library is a loop RecyclerView(expression), can show some effects when display

CircleRecyclerView the library is a loop RecyclerView, can show some effects when display screenshot CircularViewMode ScaleXViewMode & ScaleYViewMode

Matt Yao 704 Jan 5, 2023
Epoxy is an Android library for building complex screens in a RecyclerView

Epoxy Epoxy is an Android library for building complex screens in a RecyclerView. Models are automatically generated from custom views or databinding

Airbnb 8.1k Dec 29, 2022
Elegant design and convenient to use RecyclerView adapter library based on Kotlin DSL.

xAdapter: Kotlin DSL ้ฃŽๆ ผ็š„ Adapter ๅฐ่ฃ… 1ใ€็ฎ€ไป‹ ่ฏฅ้กน็›ฎๆ˜ฏ KotlinDSL ้ฃŽๆ ผ็š„ Adapter ๆก†ๆžถๅฐ่ฃ…๏ผŒ็”จๆฅ็ฎ€ๅŒ– Adapter ่ฐƒ็”จ๏ผŒๆ€ๆƒณๆ˜ฏ้‡‡็”จๅทฅๅŽ‚ๅ’Œๆž„ๅปบ่€…ๆ–นๅผ่Žทๅ– Adapter ้ฟๅ…ไปฃ็ ไธญๅฎšไน‰ๅคง้‡็š„ Adapter ็ฑปใ€‚่ฏฅ้กน็›ฎๅœจ BRVAH ็š„ Ada

ShouHeng 17 Oct 9, 2022
Handy library to integrate pagination, which allow no data layout, refresh layout, recycler view in one view and easy way to bind pagination in app.

Pagination View Handy library to integrate pagination, which allow no data layout, refresh layout, recycler view in one view and easy way to bind pagi

DhiWise 4 Dec 18, 2021
A customizable and easy-to-use Timeline View library for Android

TimelineView A customizable and easy-to-use Timeline View library for Android Can be used as a standalone view or as a RecyclerView decorator Setup 1.

Riccardo Lattarulo 189 Dec 10, 2022
An android library for quick setup of RecyclerView

SmartRecyclerView for Android An android library to quickly setup RecyclerView(List) with SwipeRefreshLayout Support, written entirely in Kotlin. Supp

Kunal Pasricha 16 Oct 18, 2022
Organize your images in beautiful collage with this library!

CollageImageView This app is an example. how to create collages with RecyclerView. See an example, how it's working: device-2021-04-24-015545.mp4 Inst

Sergey Grishin 16 Oct 14, 2022
Yet another adapter delegate library.

Yet another adapter delegate library. repositories { ... maven { url 'https://jitpack.io' } } ... dependencies { implementation("com.git

Mike 10 Dec 26, 2022
[NO LONGER MAINTAINED] Android library for better Picker DialogFragments

/!\ This Project is no longer maintained /!\ DialogFragments modeled after the AOSP Clock and Calendar apps to improve UX for picking time, date, numb

Code-Troopers 2.7k Dec 29, 2022
[NO LONGER MAINTAINED] Android library for better Picker DialogFragments

/!\ This Project is no longer maintained /!\ DialogFragments modeled after the AOSP Clock and Calendar apps to improve UX for picking time, date, numb

Code-Troopers 2.7k Dec 29, 2022
Force clear delaying & no longer needed Gradle tasks.

gradle-cleaner-intellij-plugin Force clear delaying & no longer needed Gradle tasks. Description Plugin for Intellij IDEA which performs simple comman

Kirill Biakov 26 Oct 28, 2021