Skip to content

Instantly share code, notes, and snippets.

View JoaquimLey's full-sized avatar
👨‍💻
Product oriented, software perfectionist and developer

Joaquim Ley JoaquimLey

👨‍💻
Product oriented, software perfectionist and developer
View GitHub Profile
import androidx.recyclerview.widget.ListAdapter
/**
* Creates a copy of itself if no new [data] is passed, this is used
* so [ListAdapter] correctly diffs and animates. :facepalms:
*/
fun <T> List<T>.refresh(data: List<T> = this): List<T> {
return mutableListOf<T>().apply { addAll(data) }.toList()
}