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
NSC AD 340 5210 - Week 8
Search
Nate Ebel
June 02, 2020
Programming
500
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
NSC AD 340 5210 - Week 8
Nate Ebel
June 02, 2020
More Decks by Nate Ebel
See All by Nate Ebel
Adopting Kotlin Multiplatform in Brownfield Applications - DCIT22
n8ebel
2
270
Adopting Kotlin Multiplatform in Brownfield Applications - DCNYC22
n8ebel
1
820
Demystify and Optimize Your Android Gradle Builds - Mobiconf 2021
n8ebel
2
520
Building an Android CI Pipeline with GitHub Actions - Chicago Roboto 2020
n8ebel
1
1.1k
Kotlin First - Taking Advantage of Kotlin for Android Development // 360AnDev 2020
n8ebel
0
520
NSC AD 340 5210 - Week 7
n8ebel
1
440
NSC AD 340 5210 - Week 6
n8ebel
1
370
NSC AD 340 5210 - Week 5
n8ebel
1
450
NSC AD 340 5210 - Week 4
n8ebel
2
540
Other Decks in Programming
See All in Programming
go-spidermonkeyでAIエージェントのCode Modeを実装する
syumai
3
1.5k
Webの地図
yosuke_furukawa
PRO
1
450
LL言語やWebフレームワークのPostgreSQL対応 〜DBの機能がユーザーに届くまで〜
kentaroutakeda
0
140
Webプラットフォームで議論されているセキュリティ課題 / Security issues being discussed on Web Platforms
petamoriken
0
240
Hono + Inertia + React で LP を構築した話
oukayuka
2
220
PHPプロジェクトの結合バランスを可視化する #php_night
kajitack
0
230
標準パッケージに uuid が追加された 背景から見る Go らしい意思決定 / go_127_uuid_decision
convto
4
2.9k
Laravelのアプリケーションをどこにデプロイするか #ツナギメオフライン.9
akase244
0
120
ソフトウェアラスタライザ
fadis
1
790
Snowflakeで業務アプリを作ろう。 Snowflakeのアプリ機能解説&実践ガイド
ayumu_yamaguchi
1
150
typoなんかねぇよ
raspython3
0
670
AIを上手に使っていこうとしたら越境せざるを得なくなった話 〜実践1年で見えた境界を越えなければならない理由と進め方〜 / Crossing borders with AI
tomoyakitaura
4
1.1k
Featured
See All Featured
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
870
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
190
How Software Deployment tools have changed in the past 20 years
geshan
1
34k
How to Ace a Technical Interview
jacobian
281
24k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.6k
Believing is Seeing
oripsolob
1
210
Docker and Python
trallard
47
4.2k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
680
The Art of Programming - Codeland 2020
erikaheidi
57
14k
A designer walks into a library…
pauljervisheath
211
25k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
560
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
440
Transcript
Week 8 Lecture ViewBinding, ViewModel and MVVM
What are we building this week? Replacing findViewById() using ViewBinding
02 Project Demo ViewBinding 01 Saving data across configuration changes ViewModel Scoping 04 Android ViewModel Implementing MVVM using Android ViewModel 03
Project Demo What are we building this week?
Week 8 Project Updates • Refactoring ForecastDetailsFragment • Using ViewBinding
to replace calls to findViewById() • Using ViewModel to implement MVVM • Saving data across configuration changes using ViewModel scoping
ViewBinding Replacing calls to findViewById()
Generate statically typed view references Removes any need for findViewById()
Access Generated View Properties // inflate layout and get ViewBinding
reference val binding = FragmentForecastDetailsBinding.inflate(inflater, parent, false) // access null-safe properties to reference you views binding.descriptionText.text = viewState.description binding.dateText.text = viewState.date binding.forecastIcon.load(viewState.iconUrl)
Enable ViewBinding // app/build.gradle android { … viewBinding { enabled
= true } }
ViewModel Separating business logic from UI presentation
“The ViewModel class is designed to store and manage UI-related
data in a lifecycle conscious way. The ViewModel class allows data to survive configuration changes such as screen rotations”
• Manage data sources • Format data • Save data
across configuration change • Expose data to be displayed in the UI Using ViewModel
MVVM Separation of business logic and UI presentation
MVVM VIEW VIEW MODEL MODEL
MVVM FRAGMENT VIEW MODEL REPOSITORIES
ViewModel Scoping Save data across configuration changes
• Avoid creating a new ViewModel in response to configuration
changes • Reuse existing ViewModels (and data) within different scopes ◦ Fragment ◦ Activity ◦ Navigation Graph ViewModel Scoping
• More responsive apps • Fewer network and database requests
• Better user experience ViewModel Scoping
Demo