Android Jetpack: ViewModel
ViewModel is part of the Lifecycle library which was designed to help you solve common Android Lifecycle challenges and to make your apps more maintainable and testable.
A ViewModel holds your app's UI data in a lifecycle conscious way that survives configuration changes. Separating your app's UI data from your Activity and Fragment classes lets you better follow the single responsibility principle: Your Activities and Fragments are responsible for drawing data to the screen, while your ViewModel can take care of holding and processing all the data needed for the UI.
Making a ViewModel is simple:
* Adding the Lifecycle library to your build.gradle file
* Extending the ViewModel class
* Use ViewModelProviders to associate your ViewModel with your UI controller
Then you can move all of your UI related data into your new ViewModel. If you need to customize ViewModel construction, you can create a ViewModelProvider.NewInstanceFactory. ViewModels also work great with the LiveData class to create reactive UIs!
A few words of warning: don't store Contexts in ViewModels and don't confuse ViewModels with the onSaveInstanceState method.
For more information, check out the video and links below!
Gradle dependencies → https://goo.gl/nnrvKT
ViewModels - A Simple Example (Good place to start for very basic usage) → https://goo.gl/pa2F1C
ViewModel Documentation → https://goo.gl/T3Jrzt
ViewModels - Persistence, onSaveInstanceState(), Restoring UI State and Loaders → https://goo.gl/LC1hXV
Architecture Blueprint sample with Lifecycle library
* Java → https://goo.gl/tPsEdh
* Kotlin → https://goo.gl/L3NWQH
Architecture Components samples → https://goo.gl/KCztpb
ViewModels and LiveData Patterns and Antipatterns → https://goo.gl/1t3tmL
Example of ViewModel factory in sample app → https://goo.gl/s7R86g
Architecture Components landing page → https://d.android.com/arch
Guide to app architecture → https://goo.gl/Vqtt34
Watch more Android Jetpack videos here → https://goo.gl/kw8LPv
Subscribe to the Android Developers channel here → https://goo.gl/vLYDU
#jetpack #featured
Видео Android Jetpack: ViewModel канала Android Developers
A ViewModel holds your app's UI data in a lifecycle conscious way that survives configuration changes. Separating your app's UI data from your Activity and Fragment classes lets you better follow the single responsibility principle: Your Activities and Fragments are responsible for drawing data to the screen, while your ViewModel can take care of holding and processing all the data needed for the UI.
Making a ViewModel is simple:
* Adding the Lifecycle library to your build.gradle file
* Extending the ViewModel class
* Use ViewModelProviders to associate your ViewModel with your UI controller
Then you can move all of your UI related data into your new ViewModel. If you need to customize ViewModel construction, you can create a ViewModelProvider.NewInstanceFactory. ViewModels also work great with the LiveData class to create reactive UIs!
A few words of warning: don't store Contexts in ViewModels and don't confuse ViewModels with the onSaveInstanceState method.
For more information, check out the video and links below!
Gradle dependencies → https://goo.gl/nnrvKT
ViewModels - A Simple Example (Good place to start for very basic usage) → https://goo.gl/pa2F1C
ViewModel Documentation → https://goo.gl/T3Jrzt
ViewModels - Persistence, onSaveInstanceState(), Restoring UI State and Loaders → https://goo.gl/LC1hXV
Architecture Blueprint sample with Lifecycle library
* Java → https://goo.gl/tPsEdh
* Kotlin → https://goo.gl/L3NWQH
Architecture Components samples → https://goo.gl/KCztpb
ViewModels and LiveData Patterns and Antipatterns → https://goo.gl/1t3tmL
Example of ViewModel factory in sample app → https://goo.gl/s7R86g
Architecture Components landing page → https://d.android.com/arch
Guide to app architecture → https://goo.gl/Vqtt34
Watch more Android Jetpack videos here → https://goo.gl/kw8LPv
Subscribe to the Android Developers channel here → https://goo.gl/vLYDU
#jetpack #featured
Видео Android Jetpack: ViewModel канала Android Developers
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
![Android Jetpack: Improve your app's architecture](https://i.ytimg.com/vi/7p22cSzniBM/default.jpg)
![Model View View-Model (MVVM): Getting Started](https://i.ytimg.com/vi/ijXjCtCXcN4/default.jpg)
![Shared ViewModel - Explained | Android Studio Tutorial](https://i.ytimg.com/vi/THt9QISnIMQ/default.jpg)
![](https://i.ytimg.com/vi/ZDKc1bNAwMs/default.jpg)
![Introduction to MVVM on Android - Tutorial - Learn Android Architecture Patterns](https://i.ytimg.com/vi/_T4zjIEkGOM/default.jpg)
![LiveData with Coroutines and Flow (Android Dev Summit '19)](https://i.ytimg.com/vi/B8ppnjGPAGE/default.jpg)
![Jetpack Navigation Component in One Video](https://i.ytimg.com/vi/IEO2X5OU3MY/default.jpg)
![Room + ViewModel + LiveData + RecyclerView (MVVM) Part 1 - WHAT ARE ANDROID ARCHITECTURE COMPONENTS?](https://i.ytimg.com/vi/ARpn-1FPNE4/default.jpg)
![#3.1 Android ViewModel Tutorial : Jetpack Tutorials : View Model Introduction : Android Architecture](https://i.ytimg.com/vi/j5ZouactAvk/default.jpg)
![ViewModel Explained - Android Architecture Component | Tutorial](https://i.ytimg.com/vi/orH4K6qBzvE/default.jpg)
![Android Jetpack: LiveData](https://i.ytimg.com/vi/OMcDk2_4LSk/default.jpg)
![Android Jetpack: Manage infinite lists with RecyclerView and Paging (Google I/O '18)](https://i.ytimg.com/vi/BE5bsyGGLf4/default.jpg)
![#3.2 Android ViewModel Tutorial : Jetpack Tutorials: View Model Demo: Android Architecture](https://i.ytimg.com/vi/V-fQn0z4Y_0/default.jpg)
![Hilt - Android Dependency Injection](https://i.ytimg.com/vi/B56oV3IHMxg/default.jpg)
![Single activity: Why, when, and how (Android Dev Summit '18)](https://i.ytimg.com/vi/2k8x8V77CrU/default.jpg)
![Make Your Code Clean With the SOLID Principles](https://i.ytimg.com/vi/t8VTLxMsufU/default.jpg)
![Pros and Cons of Xamarin Development](https://i.ytimg.com/vi/Yy29uRKpzhY/default.jpg)
![How to Kotlin - from the lead Kotlin language designer (Google I/O '18)](https://i.ytimg.com/vi/6P20npkvcb8/default.jpg)
![MVVM / MVI Repository Pattern with Hilt](https://i.ytimg.com/vi/8vAQrgbh6YM/default.jpg)
![Navigation Component - Android Studio Tutorial](https://i.ytimg.com/vi/DI0NIk-7cz8/default.jpg)