Upgrade to Pro — share decks privately, control downloads, hide ads and more …

DiffUtil and ListAdapter

DiffUtil and ListAdapter

DiffUtil and ListAdapter
2018/04/19 potatotips 50

Masatoshi Kubode

April 19, 2018
Tweet

More Decks by Masatoshi Kubode

Other Decks in Programming

Transcript

  1. ©2018 Wantedly, Inc. • Calculates the differences between 2 lists

    • Detects change, insert, remove, move • Move detection is optional • O(n) • 1000 / 50 modifications 4.6ms on Nexus 5X DiffUtil
  2. ©2018 Wantedly, Inc. • Added in support library 27.1.0 •

    A RecyclerView.Adapter using DiffUtil • Just submitList(newItems) • Calculates the diff on a background thread • Notify diff results on the main thread ListAdapter
  3. ©2018 Wantedly, Inc. • Should not use with MutableList •

    Does nothing if same instance submitted ListAdapter Important point
  4. ©2018 Wantedly, Inc. • DiffUtil automates the adapter notification •

    Simplify around the adapter operations Conclusion