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
AndroidXに潜む便利なヤツら
Search
Takuji Nishibayashi
April 19, 2019
Technology
0
160
AndroidXに潜む便利なヤツら
Takuji Nishibayashi
April 19, 2019
Tweet
Share
More Decks by Takuji Nishibayashi
See All by Takuji Nishibayashi
CameraX使ってみた
takuji31
0
86
kotlinx.datetime 使ってみた
takuji31
0
330
HiltのCustom Componentについて
takuji31
0
190
java.timeをAndroidで使う
takuji31
0
73
KSPを使ってコード生成
takuji31
0
310
Kotlin Symbol Processing API (KSP) を使って Kotlin ア プリケーションの開発を効率化する
takuji31
1
990
kotlinx.serialization
takuji31
0
550
kanmoba-returns-02.pdf
takuji31
0
180
AndroidXとKotlin Coroutines
takuji31
0
340
Other Decks in Technology
See All in Technology
10分で学ぶKubernetesコンテナセキュリティ/10min-k8s-container-sec
mochizuki875
3
330
Qiita埋め込み用スライド
naoki_0531
0
860
ゼロから創る横断SREチーム 挑戦と進化の軌跡
rvirus0817
2
260
社内イベント管理システムを1週間でAKSからACAに移行した話し
shingo_kawahara
0
180
コンテナセキュリティのためのLandlock入門
nullpo_head
2
320
バクラクのドキュメント解析技術と実データにおける課題 / layerx-ccc-winter-2024
shimacos
2
1k
Postman と API セキュリティ / Postman and API Security
yokawasa
0
200
ブラックフライデーで購入したPixel9で、Gemini Nanoを動かしてみた
marchin1989
1
520
5分でわかるDuckDB
chanyou0311
10
3.2k
ガバメントクラウドのセキュリティ対策事例について
fujisawaryohei
0
530
大幅アップデートされたRagas v0.2をキャッチアップ
os1ma
2
520
Wantedly での Datadog 活用事例
bgpat
1
430
Featured
See All Featured
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
Gamification - CAS2011
davidbonilla
80
5.1k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
How to Think Like a Performance Engineer
csswizardry
22
1.2k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
48
2.2k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
32
2.7k
What's in a price? How to price your products and services
michaelherold
243
12k
Building Adaptive Systems
keathley
38
2.3k
Mobile First: as difficult as doing things right
swwweet
222
9k
Code Reviewing Like a Champion
maltzj
520
39k
Making the Leap to Tech Lead
cromwellryan
133
9k
Transcript
AndroidXʹજΉศརͦ͏ͳϠπΒ @takuji31 Mobile Act KYOTO #1
ࣗݾհ
ࣗݾհ • @takuji31 id:takuji31 • Takuji Nishibayashi • Hatena Co.,
Ltd. • App Team • ίϛοΫDAYS • δϟϯϓϧʔΩʔʂ • ΧΫϤϜ
ࣗݾհ • Android • Kotlin • Flu-er • ! h-ps:/
/blog.takuji31.jp • " h-ps:/ /nazuna.takuji31.jp • # $ h-ps:/ /photo.takuji31.jp
AndroidX
LiveData? ViewModel? AppCompat? Naviga5on
ͬͯ·͢ΑͶ
ศརͳͭ৭ʑհ͠·͢
α൛ͷͷؚ·ΕΔͷͰ ͝ར༻ܭըతʹ
ଞʹ͍͍ͷ͋ͬͨΒ ڭ͍͑ͯͩ͘͞ʂ
androidx.ac*vity androidx.fragment
ComponentActivity.viewModels{} Fragment.viewModels{} Fragment.activityViewModels{}
ViewModelΛऔಘͰ͖Δ Delegated property
viewModels ҾͰ ViewModelStoreOwnerΛ୳͢ blockΛͤΔ
valʹͰ͖Δ
Goodbye! private lateinit var
@ContentView
ComponentAc*vity ͱ Fragmentʹ secondory constructor͕Ճ
constructorͷҾʹLayoutͷIDΛ ͤΔ
Goodbye setContentView()
DataBindingbind͢ΕΑͦ͞͏
androidx.lifecycle
ViewModelͱ͔LiveDataͱ͔ೖͬͯ ΔΞϨ
ViewModel.viewModelScope
ViewModelͷCorou,neScope
Context Dispatchers.Main + Job
onCleared() ͰΩϟϯηϧ
Saved State
ViewModelը໘ճసΛੜ͖Δ
Ac#vity͕ϝϞϦʔ͔Β ഁغ͞ΕΔ࣌ࢮ͵
SavedStateHandler Ͱঢ়ଶΛ෮ݩͰ͖Δ
γϯϓϧͳ set/get/remove/contains
getLiveData()
see. h&ps:/ /developer.android.com/ topic/libraries/architecture/ viewmodel-savedstate
androidx.navigation
Naviga&onͷΞϨ
androidx.navigation.safeargs androidx.navigation.safeargs.kotlin
Naviga&onͷxmlʹఆٛͨ͠ભҠઌ ͷargsΛࣗಈੜ
KotlinίʔυੜՄೳ
Goodbye createIntent() methods!
Naviga&onͰը໘ભҠ͠ͳͯ͘ ͑Δ
·ͣͬͯΈͯʂ
Fragment.navGraphViewModels()
ࢦఆͨ͠Naviga&onͷgraphͰੜ͖ ΔFragment
NavHostFragmentͷFragment Ͱ͏ɺΈ͍ͨͳײ͡ͷ࣌ʹ͑ͦ ͏
͜Εॻ͍ͯͯࠓ࣮ͯ͠Δը໘Ͱ ͑ͦ͏ͱࢥͬͨͷͰ͏༧ఆ
h"ps:/ /developer.android.com/ jetpack/androidx