Android ViewModel (JAVA) Tutorial | ViewModel Step By Step For Beginners | Android JET PACK (Part-2)

  Рет қаралды 8,571

VIDHVAN

VIDHVAN

Күн бұрын

ViewModel is a part of Android Jet Pack Components, 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.The Android framework manages the lifecycles of UI controllers, such as activities and fragments. The framework may decide to destroy or re-create a UI controller in response to certain user actions or device events that are completely out of your control. If the system destroys or re-creates a UI controller, any transient UI-related data you store in them is lost. For example, your app may include a list of users in one of its activities. When the activity is re-created for a configuration change, the new activity has to re-fetch the list of users. For simple data, the activity can use the onSaveInstanceState() method and restore its data from the bundle in onCreate(), but this approach is only suitable for small amounts of data that can be serialized then deserialized, not for potentially large amounts of data like a list of users or bitmaps. Another problem is that UI controllers frequently need to make asynchronous calls that may take some time to return. The UI controller needs to manage these calls and ensure the system cleans them up after it's destroyed to avoid potential memory leaks. This management requires a lot of maintenance, and in the case where the object is re-created for a configuration change, it's a waste of resources since the object may have to reissue calls it has already made. UI controllers such as activities and fragments are primarily intended to display UI data, react to user actions, or handle operating system communication, such as permission requests. Requiring UI controllers to also be responsible for loading data from a database or network adds bloat to the class. Assigning excessive responsibility to UI controllers can result in a single class that tries to handle all of an app's work by itself, instead of delegating work to other classes. Assigning excessive responsibility to the UI controllers in this way also makes testing a lot harder. It's easier and more efficient to separate out view data ownership from UI controller logic.
Let's Learn it with a simple example in the video.
Download the Starter Code from Here : github.com/pav...
Link for the Previous video : • Android DataBinding Tu...
LifeCycle of a ViewModel Diagram Link : developer.andr...
ViewModel official Documentation : developer.andr...
______________________
Social Media Links
______________________
Follow Me on Social Media :
Facebook : vidhvantech
Instagram : / pavankumarr. .
LinkedIn : / pavankred. .
Twitter : / trainertpk
Bolg : pavankreddytad...
My Profile: tpkreddy.githu...

Пікірлер: 16
@fajar2742
@fajar2742 2 жыл бұрын
And again indian guy saved the world ! So easy to understand!
@metaryfosberg9827
@metaryfosberg9827 Жыл бұрын
Oh god I try to find a video explain about view model by using Java. You are the best that I ever seen ! Thank you very much bro.
@VIDHVAN_official
@VIDHVAN_official Жыл бұрын
Thank you 👍😊
@skjahirhossain5084
@skjahirhossain5084 4 жыл бұрын
I am very much confused by the viewmodel. Because I am not professional Android developer. Everything I learn from various KZbin channel. I found this way more easy to understand. Thanks bro
@humaneBicycle
@humaneBicycle 2 жыл бұрын
probably the first time ill paste a yt link in my notes. thanks a lot
@bansipatel91
@bansipatel91 Жыл бұрын
Super work. Satisfied. Thank you!
@pattapagalakrishna7482
@pattapagalakrishna7482 4 жыл бұрын
Nice Explanation it s very useful
@mikelantzelo
@mikelantzelo 4 жыл бұрын
The easiest explaination for VM!! Thank you!!!
@devianusha7019
@devianusha7019 4 жыл бұрын
Understood 👍
@harisai3580
@harisai3580 3 жыл бұрын
Thank You so much anna !! Subsribing rightaway
@VIDHVAN_official
@VIDHVAN_official 2 жыл бұрын
Welcome 👍
@garyjohnston2777
@garyjohnston2777 2 жыл бұрын
I tried the gradle stuff and legit wreaked all my work and my app would not run so I had to start from scratch... wow
@aravindraj8294
@aravindraj8294 3 жыл бұрын
Super explanation please also make telugu version vedios
@VIDHVAN_official
@VIDHVAN_official 3 жыл бұрын
sure
@salar7245
@salar7245 3 жыл бұрын
Profi.
@mohitkumarsoni1847
@mohitkumarsoni1847 Жыл бұрын
Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$3 found in modules kotlin-stdlib-1.8.10 i am receiving following error.... please help me if you read this comment🙏🙏
Model View View-Model (MVVM): Getting Started
29:12
CodingWithMitch
Рет қаралды 399 М.
Think Fast, Talk Smart: Communication Techniques
58:20
Stanford Graduate School of Business
Рет қаралды 44 МЛН
ViewModels & Configuration Changes - Android Basics 2023
18:46
Philipp Lackner
Рет қаралды 145 М.
Introduction to Android
8:05
VIDHVAN
Рет қаралды 314
Android MVVM | ViewModel + LiveData | And example app
28:19
Catalin tech
Рет қаралды 19 М.