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
430
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
いまどきの Codex で開発する visionOS アプリの開発スタイルについて
karad
0
160
Jindong: Introducing Declarative Haptics in Compose Multiplatform
l2hyunwoo
0
130
FastAPI の並行処理モデルを完全に理解する
hoto17296
8
3k
ソフトウェアエンジニアにとっての生成AI - 特性を知って使い倒す / generative ai for software enginner
kishida
7
2.1k
Webエンジニアなのにブラウザの仕組みがわからないので、Pythonで自作してみた
tatsuki12
4
1.1k
VibeCodingからAgenticWorkflowへ
starfish719
0
870
引き算の組織 ― アウトカムとAIに全振りするために辞めたこと ― / Organization by Subtraction
hirokiyamamoto14
PRO
0
300
初めての模倣学習とVLA
natsutan
0
250
書籍「プロフェッショナルAI駆動開発」紹介スライド
juntaromatsumoto
0
580
「人を評価する AI」の設計と実装
ryoyanara
0
240
承認済みなのに差戻しできてしまうバグ、型で潰せます
shinchit
0
110
Go を使い始めて 2 ヶ月の学び / My first two months with Go
contour_gara
0
380
Featured
See All Featured
Discover your Explorer Soul
emna__ayadi
2
1.3k
Google's AI Overviews - The New Search
badams
0
1.1k
How GitHub (no longer) Works
holman
316
150k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
800
Skip the Path - Find Your Career Trail
mkilby
1
190
Ruling the World: When Life Gets Gamed
codingconduct
0
310
Build your cross-platform service in a week with App Engine
jlugia
234
19k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.7k
[SF Ruby Conf 2025] Rails X
palkan
2
1.3k
Automating Front-end Workflow
addyosmani
1369
210k
Six Lessons from altMBA
skipperchong
29
4.5k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
550
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