Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
NSC AD 340 5210 - Week 8
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Nate Ebel
June 02, 2020
Programming
530
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
Transcript
18 slides
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
More Decks by Nate Ebel
See All by Nate Ebel
Adopting Kotlin Multiplatform in Brownfield Applications - DCIT22
n8ebel
2
290
Adopting Kotlin Multiplatform in Brownfield Applications - DCNYC22
n8ebel
1
830
Demystify and Optimize Your Android Gradle Builds - Mobiconf 2021
n8ebel
2
530
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
540
NSC AD 340 5210 - Week 7
n8ebel
1
450
NSC AD 340 5210 - Week 6
n8ebel
1
380
NSC AD 340 5210 - Week 5
n8ebel
1
480
NSC AD 340 5210 - Week 4
n8ebel
2
570
Other Decks in Programming
See All in Programming
クラウドエージェントは、 何がそんなに便利なのか / what makes cloud agents so useful
rkaga
5
860
AI駆動開発4年目の現在地(『あなたはFDEになるべきか?』イベント資料)
kumaiu
0
620
クラウドゲーミングのパフォーマンス最適化に挑む / Cloud Gaming Performance Tuning
vivion
0
330
AI時代のシニアエンジニアとは
yosuke_furukawa
PRO
15
12k
3回つくってわかった、 定期実行ジョブ基盤の本質情報
takai
4
3.9k
ビジネスロジックを堅牢に~Scala 3のドメインプリミティブ~
j5ik2o
0
160
FactoryBotをやめればRSpecは速くなるのか?
yuta_onishi_97
0
1.7k
仕様駆動開発入門 (何を作るかを先に決めて渡す) | 目指せ Kiro マスター 05
inariku
PRO
2
150
Growing PicoRuby's Ecosystem on ESP32
yuuu
2
130
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
310
どうしても Eloquent でリポジトリパターンをやりたいんだ #phpcon_niigata / phpcon-niigata-2026
shogogg
0
140
baseline으로 마이그레이션, 리팩토링 안전하게 맡기기
fornewid
1
980
Featured
See All Featured
SEO for Brand Visibility & Recognition
aleyda
0
4.9k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1.1k
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
Leo the Paperboy
mayatellez
11
2.5k
30 Presentation Tips
portentint
PRO
1
470
Paper Plane (Part 1)
katiecoart
PRO
3
12k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
380
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
320
Utilizing Notion as your number one productivity tool
mfonobong
4
640
[RailsConf 2023] Rails as a piece of cake
palkan
59
7.1k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
990
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
800