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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
1
270
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
420
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
SREの積み重ねがAI駆動開発のガードレールになった ― 7つの実践/SRE Guardrails The 7
tomoyakitaura
8
3.9k
Contextとはなにか
chiroruxx
1
390
Haskell/Servantを通してWebミドルウェアを捉え直す
pizzacat83
1
480
共通化で考えるべきは、実装より公開する型だった
codeegg
0
210
Hatena Engineer Seminar #37「言語モデルの活用に関する研究」
slashnephy
0
510
Signal Forms: Details & Live Coding @enterJS 2026 in Mannheim
manfredsteyer
PRO
0
230
ランチタイムLT会3周年!ランチタイムLT会を3年間続けられたお話
y0hgi
1
140
Webフレームワークの ベンチマークについて
yusukebe
0
200
act2-costs.pdf
sumedhbala
0
110
Generative UI & AI-Assistants for Your Angular Solutions
manfredsteyer
PRO
1
160
分散システム、なんですぐ死んでしまうん?耐障害性を高めたいあなたのためのレジリエンスパターン入門
mshibuya
7
5.7k
Vite+ Unified Toolchain for the Web
naokihaba
0
740
Featured
See All Featured
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
300
SEO for Brand Visibility & Recognition
aleyda
0
4.6k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.5k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.4k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.6k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
460
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
190
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
62
44k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
AI: The stuff that nobody shows you
jnunemaker
PRO
8
820
Chasing Engaging Ingredients in Design
codingconduct
0
230
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
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