Need help with Yasha?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

493 Stars 52 Forks Apache License 2.0 96 Commits 3 Opened issues


Kotlin-based modern RecyclerView rendering weapon

Services available


Need anything else?

Contributors list

# 16,648
95 commits

Read this in other languages: 中文, English, Changelog


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 '' }
  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, 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)

//Footers fun addFooter(t: T, position: Int = -1, delay: Boolean = false) fun addFooters(list: List, 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)

//Items fun addItem(t: T, position: Int = -1, delay: Boolean = false) fun addItems(list: List, 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, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.