AndroidViewModel

screenshot of AndroidViewModel

Separating data and state handling from Fragments or Activities without lots of boilerplate-code.

Overview

The AndroidViewModel library is now deprecated, but will continue to be supported by INLOOPX. It allows for separating data and state handling from Fragments or Activities without the need for excessive code. With this library, an instance of a ViewModel class is assigned to a Fragment or Activity during its creation and is kept throughout its lifecycle, even during display orientation changes. The ViewModel instance is only removed when the Fragment or Activity is completely gone. Asynchronous tasks can be executed within this ViewModel instance, and all data handling and state logic should be placed inside the ViewModel class. The Fragment or Activity serves as a "dumb" view.

Features

  • Deprecated library that served its purpose for over 3 years
  • Supports separation of data and state handling from Fragments or Activities
  • ViewModel instance is kept throughout the lifecycle of the associated Fragment or Activity
  • Asynchronous tasks can be executed within the ViewModel
  • Fragment or Activity serves as a "dumb" view
  • Support for data binding
  • Special handling for FragmentStatePagerAdapter

Summary

The AndroidViewModel library is a deprecated library that allows for separating data and state handling from Fragments or Activities without excessive code. It provides support for keeping a ViewModel instance throughout the lifecycle of the associated Fragment or Activity and executing asynchronous tasks within the ViewModel. The View serves as a "dumb" view, and data binding is supported. The library also includes special handling for FragmentStatePagerAdapter. Although deprecated, INLOOPX will continue to maintain the library for existing projects.