Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Paging Library は便利だぞ!
Search
Hunachi
June 08, 2018
Programming
1
460
Paging Library は便利だぞ!
#hakata_apk で発表した際のスライドです.
# Android
Hunachi
June 08, 2018
Tweet
Share
More Decks by Hunachi
See All by Hunachi
PDF Viewer作成の今までとこれから
hunachi
0
1.9k
Google Play ポリシー対応周りの整理/改善をしてみた
hunachi
0
360
レビューダイアログ機能の取り組みAndroid編 / Review Dialog for Android
hunachi
0
1.3k
Git Hands On for my lab.
hunachi
0
100
Google I/O 2018’s Extensions🦔
hunachi
1
2.5k
ML Kitはいいぞ!
hunachi
0
850
Androidについて.
hunachi
0
120
Other Decks in Programming
See All in Programming
Quine, Polyglot, 良いコード
qnighy
4
650
Jakarta EE meets AI
ivargrimstad
0
240
Webの技術スタックで マルチプラットフォームアプリ開発を可能にするElixirDesktopの紹介
thehaigo
2
1k
RubyLSPのマルチバイト文字対応
notfounds
0
120
Creating a Free Video Ad Network on the Edge
mizoguchicoji
0
120
카카오페이는 어떻게 수천만 결제를 처리할까? 우아한 결제 분산락 노하우
kakao
PRO
0
110
Pinia Colada が実現するスマートな非同期処理
naokihaba
4
230
Duckdb-Wasmでローカルダッシュボードを作ってみた
nkforwork
0
130
『ドメイン駆動設計をはじめよう』のモデリングアプローチ
masuda220
PRO
8
540
Why Jakarta EE Matters to Spring - and Vice Versa
ivargrimstad
0
1.2k
Enabling DevOps and Team Topologies Through Architecture: Architecting for Fast Flow
cer
PRO
0
340
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
100
Featured
See All Featured
Why Our Code Smells
bkeepers
PRO
334
57k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
A Tale of Four Properties
chriscoyier
156
23k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Done Done
chrislema
181
16k
How to Ace a Technical Interview
jacobian
276
23k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
10 Git Anti Patterns You Should be Aware of
lemiorhan
655
59k
Automating Front-end Workflow
addyosmani
1366
200k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
Transcript
Paging Libraryศརͩͧʂ # # #
ࣗݾհ ▪ ;ͳͪʢHana Kondoʣ ▪ ٱཹถߴઐ ੍ޚใֶՊ 4ʢΪϦΪϦ18ࡀʣ ▪ AndroidΛ৮ΓॳΊͯ1.5͘Β͍ʁͷ·ͩ·ͩະख़ऀɽ
▪ Kotlin͕͖ɽ ▪ ॳΊͯͷ෦֎LTͰ͢ɽ ▪ ·͔͞Γͬͯ·͢ʂ @Hunachi @_hunachi
Paging Library ͱ? ▪ RecyclerViewඞཁͳ͚ͩঃʑʹऔಘͯ͘͠ΕΔɽ Ø εΫϩʔϧ͍ͯͬͯ͠ऴʹۙͣ͘ͱଓ͖ͷItemΛऔಘͯ͘͠ΕΔɽ ▪ ॳΊͯදʹݱΕͨͷڈͷ9݄ɽ ▪
Android JetPackͷҰһʂ ▪ ࠓͷ Google I/O Ͱ҆ఆ൛͕ϦϦʔε͞Εͨʂʢ͔ͩΒnew!ʣ
None
▪ ແݶʹ͍ListΛऔಘ͍ͨ࣌͠ɼද͍͚ࣔͤͨͩ͞ใΛऔಘɽ Ø ແବͳ௨৴ϝϞϦΛΘͳ͍ɽ Ø εϜʔζʹߋ৽͞ΕΔͷͰɼUX্͕ɽ ▪ PagingΛࣗͰ࣮͠ͳ͍͍͔ͯ͘Βָʂ ▪ Roomͱͷ૬ੑൈ܈ʂҰॹʹ͏ͱΊͬͪΌָͰ͖Δʂ
▪ Data OK Ø NetɼDataBaseɼFileɽɽɽ ͏ར
͍ํ ᶃ ListAdapter Λͬͨ RecyclerView Λ࡞Δɽ ᶄ ListAdapter -> PagedListAdapterʹ͢Δɽ
ᶅ DataSource ͱ DataSource.Factory Λ࡞Δɽ ᶆ BuilderΛ࡞Δɽ ᶇ ViewModelʹLiveData<PagedList>Λ࡞Δɽ ᶈ submitListΛͯ͠ʂ Ͳ͏͍͏αΠΫϧͰಈ͔͘ɼCodelabͷWrap upʹॻ͍ͯ͋Δ ͷͰࠓճ࣮ํ๏ͷΈհ͠·͢ɽ
https://www.youtube.com/watch?v=QVMqCRs0BNA
ListAdapter -> PagedListAdapterʹ͢Δɽ
DataSourceͱDataSource.FactoryΛ࡞Δɽ σʔλݩ͕େ͖͚͘Δͱɼ3έʔε͋Δɽ 1. DataBaseʢRoomͱซ༻ʣ 2. DataBase + OtherSourceʢ ྫ: NetWork
ʣ 3. OtherSourceʢྫ: NetWork ʣ
DataBaseRoom ▪ List<Memo> -> DataSource.Factory<Int, Memo> ʹ͢Δ͚ͩɽ
DataBase + OtherSourceʢྫ: NetWork ʣ ▪ DB͔ΒσʔλΛऔಘ͠ɼσʔλ͕Γͳ͘ͳͬͨΒBoundaryCallbackʹ௨ɽ ▪ σʔλΛAPI͔Βऔ͖ͬͯͯɼDBΛߋ৽͢Δɽ ▪
PagingͷCodeLab͕͜ͷܗɽ https://codelabs.developers.google.com/codelabs/android-paging/.
ଓ͖ ▪ BoundaryCallback͜Μͳײ͡ɽ
OtherSourceʢྫ: NetWork ʣ ▪ DataSourceΛ͜Μͳײ͡Ͱ࡞Δɽʢσʔλݩ͕ϖʔδϯάʹରԠ͍ͯ͠Δʣ
ଓ͖ ▪ DataͷऴΘΓnullͰڭ͑ͯ͋͛Δɽ ▪ ΤϥʔϋϯυϦϯάɼϦτϥΠॲཧɼ Executorͱ͔LiveDataΛͬͯؤு ΔʂʢެࣜͷαϯϓϧΛΈΔͱ͍͍ͱࢥ͍·͢ʂʣ ▪ σʔλݩ͕ϖʔδϯάʹରԠ͍ͯ͠Δ߹ Ø
PageKeyedDataSource Λ͏ɽ Ø callbackͷҾ͕ ListͱݱࡏͷPageɽ ▪ σʔλݩ͕ϖʔδϯάʹରԠ͍ͯ͠ͳ͍߹ Ø ItemKeyedDataSource Λ͏ɽ Ø callbackͷҾ͕ Item ͷΈɽ
BuilderΛ࡞Δɽ
࠷ޙʹsubmitList͢Δɽ
▪ )* Demo,/0 ▪ 5 1 #&-4
6 ! ▪ "$ ▪ https://github.com/Hunachi/wantedly-coding-challenge-publicNetWork ▪ https://github.com/Hunachi/HunaSchedule2 DataBase!%'(+2 3-.
͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ɽ