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
490
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
1
260
Adopting Kotlin Multiplatform in Brownfield Applications - DCNYC22
n8ebel
1
810
Demystify and Optimize Your Android Gradle Builds - Mobiconf 2021
n8ebel
1
500
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
510
NSC AD 340 5210 - Week 7
n8ebel
1
410
NSC AD 340 5210 - Week 6
n8ebel
1
360
NSC AD 340 5210 - Week 5
n8ebel
1
440
NSC AD 340 5210 - Week 4
n8ebel
2
520
Other Decks in Programming
See All in Programming
Agentic UI
manfredsteyer
PRO
0
180
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
3
710
OSもどきOS
arkw
0
570
肥大化するレガシーコードに立ち向かうためのインターフェース分離と依存の逆転 / JJUG CCC 2026 Spring
hirokunimaeta
0
570
TAKTでAI駆動開発の品質を設計する
j5ik2o
7
1.4k
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
2.1k
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
270
[2026年度第1回ORセミナー] 計画最適化ベンチャーと競技プログラミング人材
terryu16
0
270
Spring Security 実践 ─ GraphQL APIで実務に役立つ 認証・認可 を学ぶ
wagyu
0
250
Lessons from Spec-Driven Development
simas
PRO
0
210
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
11
4.3k
ユニットテストの先へ:テスト技法で要求・仕様を整理するJava開発実践 / Beyond_Unit_Testing_Practical_Java_Development_Techniques_for_Organizing_Requirements_and_Specifications
shimashima35
0
410
Featured
See All Featured
Making the Leap to Tech Lead
cromwellryan
135
9.9k
The Language of Interfaces
destraynor
162
27k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
340
Music & Morning Musume
bryan
47
7.2k
Between Models and Reality
mayunak
4
340
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
850
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.6k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.7k
Leo the Paperboy
mayatellez
7
1.8k
Balancing Empowerment & Direction
lara
6
1.2k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
150
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.5k
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