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
肥大化するレガシーコードに立ち向かうためのインターフェース分離と依存の逆転 / JJUG CCC 2026 Spring
hirokunimaeta
0
570
Oxlintのカスタムルールの現況
syumai
6
1.1k
The ROI of Quarkus for Spring Boot Applications
hollycummins
0
120
Spec Driven Development | AI Summit Lisbon
danielsogl
PRO
0
200
Datadog × OpenTelemetry 入門と実践のあいだ
kn_to_maxpno
1
160
jQueryをバージョンアップする前に使いたいjQuery Migrate
matsuo_atsushi
0
560
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
200
その問い、本当に正しいですか?AI時代のエンジニアに必要な哲学と認知科学 / ai-philosophy-cognitive-science
minodriven
11
5.8k
Skillsは効率化、Agentsは"自分の拡張"——Builder時代のエージェント編成(CC Night 2026)
wemra
1
140
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
1.6k
正しくソフトウェアを作る、前提を疑うための認知の視点 / doubt-premise
minodriven
21
6.7k
New "Type" system on PicoRuby
pocke
1
970
Featured
See All Featured
Raft: Consensus for Rubyists
vanstee
141
7.5k
The agentic SEO stack - context over prompts
schlessera
0
820
Designing Experiences People Love
moore
143
24k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
320
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.7k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.3k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.3k
Unsuck your backbone
ammeep
672
58k
The Invisible Side of Design
smashingmag
302
52k
RailsConf 2023
tenderlove
30
1.5k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
260
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