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
Now in Android Overview
Search
aosa4054
July 08, 2022
Programming
1.5k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Now in Android Overview
社内LT会で使用した資料です。
aosa4054
July 08, 2022
More Decks by aosa4054
See All by aosa4054
LazyVerticalGridに学ぶ 非スクローラブルなグリッドの作り方
aosa4054
0
780
実用 Picture in Picture
aosa4054
2
920
自作アプリのアイコンを作った話
aosa4054
0
250
Other Decks in Programming
See All in Programming
2年かけて Deno に DOMMatrix を実装した話 / How I implemented DOMMatrix in Deno over two years
petamoriken
0
180
Google Apps Script で Ruby を動かす
kawahara
0
110
AIエージェントで 変わるAndroid開発環境
takahirom
2
740
Build-to-own AI: Agentic Development for Humans
inesmontani
PRO
0
110
Welcome to the "Parametricity" 🏙️ − Generic だけど Specific な世界 −
guvalif
PRO
1
190
壊れたパーサから始める関数型設計と構成的なパーサ #fp_matsuri
raiga0310
2
410
Generative UI & AI-Assistants for Your Angular Solutions
manfredsteyer
PRO
1
270
ここ半年くらいでAIに作らせたR用ツール
eitsupi
0
330
霧の中の代数的エフェクト
funnyycat
1
440
Terraform標準の組織で AWS CDKをどう使うか
mu7889yoon
1
410
Laravelで学ぶ Webアプリケーションチューニング入門/web_application_tuning_101
hanhan1978
4
1.4k
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
280
Featured
See All Featured
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.9k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
200
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
330
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
390
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.7k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
420
Code Reviewing Like a Champion
maltzj
528
40k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
510
The Pragmatic Product Professional
lauravandoore
37
7.4k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
Transcript
Now in Android Overview ࣾGoogle I/O LTձ 2022/06/24 Shota Ara
Index • What is “Now in Android” • Architecture Overview
• Feature of “Now in Android” • Links
What is “Now in Android”
What is “Now in Android” • ઃܭʢσβΠϯʁʣɺ։ൃͷϕετ ϓϥΫςΟεΛ࠾༻ͨ͠ࢀߟΞϓϦ • ϑϧKotlin
/ Jetpack Compose • Androidͷχϡʔε͕ݟΕΔ • is not yet available on the Play Store
Architecture Overview
Architecture Overview MVVM Architecture with Flow • MVVM + Repository
• Room, DataStoreͷFlow IFΛ༻ • APIΞΫηεΞϓϦىಈ࣌ͷΈ • ىಈதΩϟογϡΛ༻ • ViewModelͰՃͨ͠FlowΛ ViewͰcollectAsStateͰߪಡ 6
ViewModel /* ؆୯ͷͨΊʹॾʑলུͯ͠·͢ɻ */ class ForYouViewModel { private val followedInterestsState:
StateFlow = repository.userDataStream .map { /* Ճ */ } .stateIn(/* ॳظείʔϓͳͲ */) val feedState: StateFlow = combine( followedInterestsState, /* ͦͷଞͷRepositoryΞΫηεͳͲ */ ) { /* * - combineͷ֤ཁૉ͕ඞཁͳॲཧ * - UiStateܕʹม */ } } RepositoryͷΛऔಘɾ Ճͯ͠ViewʹStateFlowΛ ެ։͢Δɻ
ViewModel /* ؆୯ͷͨΊʹॾʑলུͯ͠·͢ɻ */ class ForYouViewModel { private val followedInterestsState:
StateFlow = repository.userDataStream .map { /* Ճ */ } .stateIn(/* ॳظείʔϓͳͲ */) val feedState: StateFlow = combine( followedInterestsState, /* ͦͷଞͷRepositoryΞΫηεͳͲ */ ) { /* * - combineͷ֤ཁૉ͕ඞཁͳॲཧ * - UiStateܕʹม */ } } RepositoryͷΛऔಘɺ Ճ͠StateFlowʹม͢Δ ϦϙδτϦͷฦΓΛΞϓϦͷ υϝΠϯͷܕʹม
/* ؆୯ͷͨΊʹॾʑলུͯ͠·͢ɻ */ class ForYouViewModel { private val followedInterestsState: StateFlow
= repository.userDataStream .map { /* Ճ */ } .stateIn(/* ॳظείʔϓͳͲ */) val feedState: StateFlow = combine( followedInterestsState, /* ͦͷଞͷRepositoryΞΫηεͳͲ */ ) { /* * - combineͷ֤ཁૉ͕ඞཁͳॲཧ * - UiStateܕʹม */ } } ViewModel ෳͷFlow͔ΒҰͭͷ UiStateΛΈཱͯΔ
Feature of “Now in Android”
Feature of “Now in Android” App Startup •ΞϓϦͷىಈ࣌ʹॳظԽ͢Δඞཁ ͷ͋ΔϥΠϒϥϦͰɺͦͷॳظ ԽʹcontentProvider͕༻͍ΒΕΔ
͜ͱ͕͋Δ •ͦΕʹΑͬͯىಈ͕͘ͳΒͳ͍ ͨΊʹcontentProviderͷ੍ޚΛߦ ͳͬͯ͘ΕΔϥΠϒϥϦ 11
Feature of “Now in Android” App Startup in Now
in Android app •NiAΞϓϦ্Ͱςετͷ߹্ ཧతͳ͍ํʹͳ͍ͬͯͳ͍ •WorkerΛॳظԽ͠ɺWorkerʹ ΑͬͯAPIίʔϧΛߦͳ͍ͬͯΔ •ϨεϙϯεશͯϩʔΧϧʹ Ωϟογϡ͞ΕΔ 12
WindowSizeClass ը໘αΠζʹԠͯ͡දࣔ͢ΔUIΛ ม͍͑ͯΔɻ • BottomBar -> NavRail • χϡʔεͷΧϥϜ
WindowSizeClass Scaffold( /* ΖΖ */ bottomBar = { if (windowSizeClass.widthSizeClass
== WindowWidthSizeClass.Compat) { NiaBottomBar(/* ΖΖ */) } } ) { Row(/* ΖΖ */) { if (windowSizeClass.widthSizeClass != WindowWidthSizeClass.Compact) { NiaNavRail(/* ΖΖ */) } /* Viewͷίϯςϯπ */ } }
WindowSizeClass Scaffold( /* ΖΖ */ bottomBar = { if (windowSizeClass.widthSizeClass
== WindowWidthSizeClass.Compat) { NiaBottomBar(/* ΖΖ */) } } ) { Row(/* ΖΖ */) { if (windowSizeClass.widthSizeClass != WindowWidthSizeClass.Compact) { NiaNavRail(/* ΖΖ */) } /* Viewͷίϯςϯπ */ } } Material designͷجຊతͳߏΛ ࣮͍ͯ͠ΔComposable
WindowSizeClass Scaffold( /* ΖΖ */ bottomBar = { if (windowSizeClass.widthSizeClass
== WindowWidthSizeClass.Compat) { NiaBottomBar(/* ΖΖ */) } } ) { Row(/* ΖΖ */) { if (windowSizeClass.widthSizeClass != WindowWidthSizeClass.Compact) { NiaNavRail(/* ΖΖ */) } /* Viewͷίϯςϯπ */ } } Material 3ͰActivityΛҾͱͨ͠ τοϓϨϕϧ͔ؔΒऔಘͰ͖Δ
WindowSize Scaffold( /* ΖΖ */ bottomBar = { if (windowSizeClass.widthSizeClass
== WindowWidthSizeClass.Compat) { NiaBottomBar(/* ΖΖ */) } } ) { Row(/* ΖΖ */) { if (windowSizeClass.widthSizeClass != WindowWidthSizeClass.Compact) { NiaNavRail(/* ΖΖ */) } /* Viewͷίϯςϯπ */ } }
Links
Links • ϦϙδτϦ https://github.com/android/nowinandroid • հ͞Ε͍ͯΔAndroid Developers Blog
https://android-developers.googleblog.com/2022/05/now-in- android-sample-app-alpha.html • Now in Android ΞϓϦղઆ by yanzm͞Μ https://speakerdeck.com/yanzm/now-in-android-app