Skip to content

Instantly share code, notes, and snippets.

@JoaquimLey
Created December 19, 2019 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoaquimLey/3781d5fef1f499f467fe522ea2e5a128 to your computer and use it in GitHub Desktop.
Save JoaquimLey/3781d5fef1f499f467fe522ea2e5a128 to your computer and use it in GitHub Desktop.
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()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment