RUVIDEO
Поделитесь видео 🙏

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

📁 Обучение 👁️ 19 📅 01.12.2023

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 : https://github.com/pavankumart46/DataBinding-ViewModel-LiveData-Solution

Link for the Previous video : https://youtu.be/6X4ieh6rIeA

LifeCycle of a ViewModel Diagram Link : https://developer.android.com/images/topic/libraries/architecture/viewmodel-lifecycle.png

ViewModel official Documentation : https://developer.android.com/topic/libraries/architecture/viewmodel


______________________
Social Media Links
______________________
Follow Me on Social Media :

Facebook : https://fb.me/vidhvantech
Instagram : https://www.instagram.com/pavankumarr...
LinkedIn : https://www.linkedin.com/in/pavankred...
Twitter : https://twitter.com/trainerTpk
Bolg : https://pavankreddytadi.blogspot.com/

My Profile: https://tpkreddy.github.io

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Android ViewModel (JAVA) Tutorial | ViewModel Step By Step For Beginners | Android JET PACK (Part-2», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.