DiffUtil and ListAdapter

DiffUtil and ListAdapter

DiffUtil and ListAdapter
2018/04/19 potatotips 50

E505897a79eede1a676f92740261e8f8?s=128

Masatoshi Kubode

April 19, 2018
Tweet

Transcript

  1. ©2018 Wantedly, Inc. DiffUtil and ListAdapter potatotips 50 19.Apr.2018 -

    Masatoshi Kubode
  2. ©2018 Wantedly, Inc. Self introduction Masatoshi Kubode Twitter: @swiz_ard GitHub:

    @kubode Qiita: @kubode Wantedly Visit UserGrowth
  3. ©2018 Wantedly, Inc. 1. DiffUtil 2. ListAdapter 3. Demo Agenda

  4. ©2018 Wantedly, Inc. DiffUtil

  5. ©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
  6. ©2018 Wantedly, Inc. ListAdapter

  7. ©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
  8. ©2018 Wantedly, Inc. Demo ListAdapter

  9. ©2018 Wantedly, Inc. • Should not use with MutableList •

    Does nothing if same instance submitted ListAdapter Important point
  10. ©2018 Wantedly, Inc. Conclusion

  11. ©2018 Wantedly, Inc. • DiffUtil automates the adapter notification •

    Simplify around the adapter operations Conclusion
  12. ©2018 Wantedly, Inc. https://github.com/kubode/DiffUtil-sample Repository

  13. ©2018 Wantedly, Inc. Thanks