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
2.3k
Google Play ポリシー対応周りの整理/改善をしてみた
hunachi
0
370
レビューダイアログ機能の取り組み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
860
Androidについて.
hunachi
0
120
Other Decks in Programming
See All in Programming
LLM Supervised Fine-tuningの理論と実践
datanalyticslabo
7
1.3k
htmxって知っていますか?次世代のHTML
hiro_ghap1
0
340
Zoneless Testing
rainerhahnekamp
0
120
Beyond ORM
77web
7
960
php-conference-japan-2024
tasuku43
0
330
テストコード文化を0から作り、変化し続けた組織
kazatohiei
2
1.5k
「とりあえず動く」コードはよい、「読みやすい」コードはもっとよい / Code that 'just works' is good, but code that is 'readable' is even better.
mkmk884
3
500
17年周年のWebアプリケーションにTanStack Queryを導入する / Implementing TanStack Query in a 17th Anniversary Web Application
saitolume
0
250
From Translations to Multi Dimension Entities
alexanderschranz
2
130
なまけものオバケたち -PHP 8.4 に入った新機能の紹介-
tanakahisateru
1
120
MCP with Cloudflare Workers
yusukebe
2
220
PSR-15 はあなたのための ものではない? - phpcon2024
myamagishi
0
140
Featured
See All Featured
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
0
98
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
247
1.3M
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
17
2.3k
The Invisible Side of Design
smashingmag
298
50k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Docker and Python
trallard
42
3.1k
Unsuck your backbone
ammeep
669
57k
Six Lessons from altMBA
skipperchong
27
3.5k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
810
Mobile First: as difficult as doing things right
swwweet
222
9k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
520
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-.
͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ɽ