SkillAgentSearch skills...

RecyclerViewListAdapterAsyncListDiffDemo

RecyclerView's new ListAdapter & AsyncListDeff demo in kotlin

Install / Use

/learn @sayem405/RecyclerViewListAdapterAsyncListDiffDemo
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

RecyclerViewListAdapterAsyncListDiffDemo

This is a demo of using new recyclerView's ListAdapter using Kotlin. Demo shows simple insert delete operation. This List adapter uses new AsyncListDiffer inside. AsyncListDiffer calculates the diffs of list item differences asynchronously. So, no need to worry about any threading implementation.

those ListAdapter & AsyncListDiffer are available from support library 27.1.0. So, consider to update it before using it.

Demo

prerequisite

need knowledge about RecyclerView & DiffUtil.Callback

Advantage

  1. Less code
  2. No need to worry about threading during comparing diffs

Disadvantage

you can not update any data in same list. Always need to pass a new list inside adapter to update your views. This is due to inside AsyncListDiffer there is a checking that if it founds old list reference it ommits the calculations of DiffUtil.Callback.

public void submitList(final List<T> newList) {
        if (newList == mList) {
            // nothing to do
            return;
        }

        // rest of the code
}
View on GitHub
GitHub Stars4
CategoryDevelopment
Updated1y ago
Forks0

Languages

Kotlin

Security Score

60/100

Audited on Jan 11, 2025

No findings