Programming language: Kotlin
License: Apache License 2.0
Tags: Kotlin     RecyclerView     Android    
Latest version: v1.0.9

Yasha alternatives and similar packages

Based on the "Kotlin" category.
Alternatively, view Yasha alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of Yasha or a related project?

Add another 'Kotlin' Package



Read this in other languages: [中文](README.zh.md), [English](README.md), [Changelog](CHANGELOG.md)



Item introduction:

Kotlin-based modern RecyclerView rendering weapon

Item Features:

  • No Adapter required
  • No ViewHolder required
  • Support Coroutine
  • Support page loading
  • Support for MultiViewType
  • Support for Header and Footer
  • Support DiffUtil
  • Support Loading State
  • Support CleanUp, free resources to avoid memory leaks


  1. Add jitpack to build.gradle

    allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
  2. Add dependency

dependencies {
    implementation 'com.github.ssseasonnn:Yasha:1.1.0'

First Blood

How to quickly render a RecyclerView? Still tirelessly writing Adapter, ViewHolder? Let Yasha come to save you:

     //Render a list with ** dataSource ** as the data source
     recycler_view.linear(dataSource) {

         //Render an Item of type NormalItem
         renderItem<NormalItem> {
             //layout res

             //bind data 
             onBind {
                 tv_normal_content.text = data.toString()

         //Render an Header of type HeaderItem
         renderItem<HeaderItem> {
             //layout res

             //bind data 
             onBind {
                 tv_header_content.text = data.toString()

         //Render an Footer of type FooterItem
         renderItem<FooterItem> {

             //layout res

             //bind data 
             onBind {
                 tv_footer_content.text = data.toString()

As you can see, it's very simple and intuitive, and you don't see any Adapter or ViewHolder. Equipped with Yasha, go to Gank!

Double Kill

Rendering is done. Where does the data source come from? Yasha thoughtfully prepared a good partner for you:Sange

Sange is another powerful weapon. It can provide any data that Yasha needs. With it, Yasha can be like a fish. As in Dota, they are also inseparable. Friends who are familiar with Dota know that Yasha + Sange = Dark Night The sword is the same here. With both of them, why fear any headwinds?

//Create a DataSource
class DemoDataSource : YashaDataSource() {

    //loadInitial is responsible for loading list initialization data
    override fun loadInitial(loadCallback: LoadCallback<YashaItem>) {

        //Simulate the delay, don't worry, this method will be executed in an asynchronous thread, so you can rest assured to make network requests or database loading, etc.

        val allDataList = mutableListOf<YashaItem>()

        //Add Headers data
        for (i in 0 until 2) {
        //Add Items data
        for (i in 0 until 10) {
        //Add Footers data
        for (i in 0 until 2) {

        //Notify data loading is complete

    //loadAfter is responsible for loading the next page of data. Yasha will decide whether to trigger pagination loading by itself. You only need to do the logic to load the next page. Leave the rest to Yasha
    override fun loadAfter(loadCallback: LoadCallback<YashaItem>) {

        //when loading failed:
        if (page % 3 == 0) {

            //When data loading fails, you only need to simply tell Yasha a NULL value, and Yasha will automatically stop loading and display a status of loading failure.

        //when loading finished:
        if(page == 5) {
            //After the data is loaded, you only need to tell Yasha an empty list, and Yasha will automatically stop loading and display a loading status.            loadCallback.setResult(emptyList())

        //Load the next page of data:
        val items = mutableListOf<YashaItem>()
        for (i in page * 10 until (page + 1) * 10) {


Is it easy? That's right, the API provided by Yasha and Sange is simple and easy to understand. It can be quickly used without any threshold. It is an essential weapon for traveling at home and killing more goods!

In addition, Sange also provides many APIs for directly operating data sources, such as

fun addHeader(t: T, position: Int = -1, delay: Boolean = false)
fun addHeaders(list: List<T>, position: Int = -1, delay: Boolean = false) 
fun removeHeader(t: T, delay: Boolean = false) 
fun setHeader(old: T, new: T, delay: Boolean = false)
fun getHeader(position: Int): T
fun clearHeader(delay: Boolean = false)

fun addFooter(t: T, position: Int = -1, delay: Boolean = false)
fun addFooters(list: List<T>, position: Int = -1, delay: Boolean = false) 
fun removeFooter(t: T, delay: Boolean = false) 
fun setFooter(old: T, new: T, delay: Boolean = false)
fun getFooter(position: Int): T
fun clearFooter(delay: Boolean = false)

fun addItem(t: T, position: Int = -1, delay: Boolean = false)
fun addItems(list: List<T>, position: Int = -1, delay: Boolean = false) 
fun removeItem(t: T, delay: Boolean = false) 
fun setItem(old: T, new: T, delay: Boolean = false)
fun getItem(position: Int): T
fun clearItem(delay: Boolean = false)


Triple Kill

In addition, Yasha also prepared the status display for the younger friends, such as commonly used ** Loading *, * Loading failed *, * Loading completed **

If there is any dissatisfaction with the state that comes with it, it is very simple. The first method is to kill it. The second method is to replace it.

//kill it:
class DemoDataSource : YashaDataSource() {

    override fun onStateChanged(newState: Int) {
        //You just need to redo this method and comment out the call to super, so there is no status display!

//replace it:
recycler_view.linear(dataSource) {

    //Replace with your own state rendering
    renderItem<YashaStateItem> {
        //new state layout res

        //new state bind
        onBind {


Radiant wins, GG


Copyright 2019 Season.Zlc

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at


Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.

*Note that all licence references and agreements mentioned in the Yasha README section above are relevant to that project's source code only.