DiffUtil and ListAdapter
by
Masatoshi Kubode
Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
©2018 Wantedly, Inc. DiffUtil and ListAdapter potatotips 50 19.Apr.2018 - Masatoshi Kubode
Slide 2
Slide 2 text
©2018 Wantedly, Inc. Self introduction Masatoshi Kubode Twitter: @swiz_ard GitHub: @kubode Qiita: @kubode Wantedly Visit UserGrowth
Slide 3
Slide 3 text
©2018 Wantedly, Inc. 1. DiffUtil 2. ListAdapter 3. Demo Agenda
Slide 4
Slide 4 text
©2018 Wantedly, Inc. DiffUtil
Slide 5
Slide 5 text
©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
Slide 6
Slide 6 text
©2018 Wantedly, Inc. ListAdapter
Slide 7
Slide 7 text
©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
Slide 8
Slide 8 text
©2018 Wantedly, Inc. Demo ListAdapter
Slide 9
Slide 9 text
©2018 Wantedly, Inc. • Should not use with MutableList • Does nothing if same instance submitted ListAdapter Important point
Slide 10
Slide 10 text
©2018 Wantedly, Inc. Conclusion
Slide 11
Slide 11 text
©2018 Wantedly, Inc. • DiffUtil automates the adapter notification • Simplify around the adapter operations Conclusion
Slide 12
Slide 12 text
©2018 Wantedly, Inc. https://github.com/kubode/DiffUtil-sample Repository
Slide 13
Slide 13 text
©2018 Wantedly, Inc. Thanks