All Projects → MinSeungHyun → slush

MinSeungHyun / slush

Licence: MIT license
This library will no longer be updated 😭

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to slush

PrimeAdapter
PrimeAdapter makes working with RecyclerView easier.
Stars: ✭ 54 (+107.69%)
Mutual labels:  recyclerview, recyclerview-adapter
Linkage Recyclerview
即使不用饿了么订餐,也请务必收藏好该库!🔥 一行代码即可接入,二级联动订餐列表。
Stars: ✭ 2,970 (+11323.08%)
Mutual labels:  recyclerview, androidx
Async Expandable List
Stars: ✭ 221 (+750%)
Mutual labels:  recyclerview, recyclerview-adapter
Airbnb Android Google Map View
This is a sample Android Application which has Google Map view similar to what AirBnb Android Application. Moving Markers like Uber/Ola. Custom Google Search for places. Recycler view with Animations added.
Stars: ✭ 175 (+573.08%)
Mutual labels:  recyclerview, recyclerview-adapter
Modular2Recycler
Modular²Recycler is a RecyclerView.Adapter that is modular squared.
Stars: ✭ 72 (+176.92%)
Mutual labels:  recyclerview, recyclerview-adapter
Moretype
new method to build data in RecyclerView with Kotlin!
Stars: ✭ 189 (+626.92%)
Mutual labels:  recyclerview, recyclerview-adapter
Adapterdelegates
"Favor composition over inheritance" for RecyclerView Adapters
Stars: ✭ 2,735 (+10419.23%)
Mutual labels:  recyclerview, recyclerview-adapter
Android Rv Swipe Delete
RecyclerView swipe to delete example.
Stars: ✭ 143 (+450%)
Mutual labels:  recyclerview, recyclerview-adapter
MultiTypeAdapter
RecyclerView通用多类型适配器MultiTypeAdapter,以布局文件为单位更细粒度的条目复用。
Stars: ✭ 18 (-30.77%)
Mutual labels:  recyclerview, recyclerview-adapter
BaseRecyclerViewAdapter
RecyclerView通用适配器
Stars: ✭ 14 (-46.15%)
Mutual labels:  recyclerview, recyclerview-adapter
Customadapter
RV Adapter 优雅封装,抽取列表模版,可以快速的添加一个列表,使用组装的方式构建Adapter,抽象Cell 角色,负责创建ViewHolder,绑定数据和逻辑处理。Cell为一个独立的组件。
Stars: ✭ 172 (+561.54%)
Mutual labels:  recyclerview, recyclerview-adapter
AdapterCommands
Drop in solution to animate RecyclerView's dataset changes by using command pattern
Stars: ✭ 74 (+184.62%)
Mutual labels:  recyclerview, recyclerview-adapter
Fastadapter
快速使用的RecyclerView Adapter
Stars: ✭ 170 (+553.85%)
Mutual labels:  recyclerview, recyclerview-adapter
Flap
Flap(灵动),一个基于 RecyclerView 的页面组件化框架。
Stars: ✭ 204 (+684.62%)
Mutual labels:  recyclerview, recyclerview-adapter
Drag Select Recyclerview
👇 Easy Google Photos style multi-selection for RecyclerViews, powered by Kotlin and AndroidX.
Stars: ✭ 1,818 (+6892.31%)
Mutual labels:  recyclerview, androidx
Admobadapter
It wraps your Adapter to display Admob native ads and banners in a ListView/RecyclerView data set. It based on the Yahoo fetchr project https://github.com/yahoo/fetchr
Stars: ✭ 224 (+761.54%)
Mutual labels:  recyclerview, recyclerview-adapter
Easyadapter
Recyclerview adapter library- Create adapter in just 3 lines of code
Stars: ✭ 122 (+369.23%)
Mutual labels:  recyclerview, recyclerview-adapter
Easyrecyclerview
🎞 Easy recyclerview for Android
Stars: ✭ 131 (+403.85%)
Mutual labels:  recyclerview, recyclerview-adapter
recyclerview-adapters
Multiple item adapters for RecyclerView (inspired by Merge Adapter)
Stars: ✭ 24 (-7.69%)
Mutual labels:  recyclerview, recyclerview-adapter
recyclerview-expandable
RecyclerView implementation of traex's ExpandableLayout
Stars: ✭ 70 (+169.23%)
Mutual labels:  recyclerview, recyclerview-adapter


한국어

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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].