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
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
860
Contemporary Test Cases
maaretp
0
140
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2.2k
見せてあげますよ、「本物のLaravel批判」ってやつを。
77web
7
7.7k
Kaigi on Rails 2024 〜運営の裏側〜
krpk1900
1
210
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
120
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
1
290
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
110
CSC509 Lecture 12
javiergs
PRO
0
160
イベント駆動で成長して委員会
happymana
1
320
as(型アサーション)を書く前にできること
marokanatani
10
2.6k
C++でシェーダを書く
fadis
6
4.1k
Featured
See All Featured
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.3k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Designing Experiences People Love
moore
138
23k
Thoughts on Productivity
jonyablonski
67
4.3k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
Bash Introduction
62gerente
608
210k
Designing for Performance
lara
604
68k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
Unsuck your backbone
ammeep
668
57k
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-.
͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ɽ