ViewModels : for Include Specific

Ponglang Petrung
PongPloyDev
Published in
8 min readAug 21, 2019
https://imaginearchitecture.blogspot.com/2015/08/augmented-reality-and-architecture-what.html

Introduction

The ViewModel class is designed to store and manage UI-related data in a lifecycle conscious way. The ViewModelclass allows data to survive configuration changes such as screen rotations.

Components

Architecture components are a set of Android libraries that help you structure your app in a way that is robust, testable, and maintainable.

This codelab introduces you to the following lifecycle-aware architecture components for building Android apps:

  • ViewModel — provides a way to create and retrieve objects that are bound to a specific lifecycle. A ViewModeltypically stores the state of a view's data and communicates with other components, such as data repositories or the domain layer which handles business logic. To read an introductory guide to this topic, see ViewModel.
  • LifecycleOwner/LifecycleRegistryOwner — both LifecycleOwner and LifecycleRegistryOwner are interfaces that are implemented in the AppCompatActivity and Support Fragment classes. You can subscribe other components to owner objects which implement these interfaces, to observe changes to the lifecycle of the owner. To read an introductory guide to this topic, see Handling Lifecycles.
  • LiveData — allows you to observe changes to data across multiple components of your app without creating explicit, rigid dependency paths between them. LiveData respects the complex lifecycles of your app components, including activities, fragments, services, or any LifecycleOwner defined in your app. LiveData manages observer subscriptions by pausing subscriptions to stopped LifecycleOwner objects, and cancelling subscriptions to LifecycleOwner objects that are finished. To read an introductory guide to this topic, see LiveData.

Exmaple : Android lifecycle-aware components codela Lab

Bind layout views to Architecture Components

1. ViewModels : A Simple Example

Basic Demo :

Youtube more :

Architecture Components: ViewModel

2. Android Architecture Components MVVM — Part 1

We recently started a new project in HERE Technologies that allowed us to check-out new technologies like Architecture Components and popular trends like Kotlin, an emerged first class citizen of Android. While working on the new project a familiar MVVM architecture emerged, likely inspired by Google blueprints todo app (mvvm-live), but with a stronger focus on readability/ maintainability and testability of the binding between view and view-model. We will not discuss a new pattern but more likely show how LiveData and ViewModel can be used to create a scalable application for real life requirements.

3. Android Architecture Components MVVM — Part 2

This 2nd part of the discussion on how to use the MVVM pattern with Android Architecture Components (read Part 1 first), that shows some more code of the github example and discusses how backstack behavior can work.

Link : https://proandroiddev.com/android-architecture-components-mvvm-part-2-34ea2470bd9c

.MVVM with Kotlin — Android Architecture Components, Dagger 2, Retrofit and RxAndroid

When I wrote my last article MVP Architecture with Kotlin — Dagger 2, Retrofit, RxAndroid and DataBinding I didn’t expect that much: it reached more than 3K reads, and more than 1K applauses.

Within that time, I hardly tried to switch from MVP to MVVM, meaning I tried to find an MVVM architecture which would be definitively more useful that the MVP one I used, and after improving time after time this architecture, I finally found something I’m happy with.

And because your feedbacks on first article gave me motivation, I decided to share it here.

link : https://proandroiddev.com/mvvm-with-kotlin-android-architecture-components-dagger-2-retrofit-and-rxandroid-1a4ebb38c699

Download Example code : https://github.com/gahfy/MVVMPosts?source=post_page-----1a4ebb38c699----------------------

4 MVVMPosts

Sample application with MVVM architecture

Download : https://github.com/gahfy/MVVMPosts?source=post_page-----1a4ebb38c699----------------------

5 DataBinding-MVVM

Sample application with MVVM architecture

6.MVVM-Kotlin-RecyclerView-

7. android-MVVM-DataBinding-FormExample

A demo of how to use Jetpack architecture and lifecycle component to implement a form. This includes validation and submit.

8. Basic Example of LiveData and ViewModel

9. Building an Android App using Android Architecture Components: Room, ViewModel, and LiveData

Download

10 Understanding MVVM on Android Tutorial 05 — Introduction to Reactive Programming with RxJava

11 Understanding MVVM on Android Tutorial 06 — Refactoring our code with RxJava

12 .Android Architecture starring Kotlin Coroutines, Jetpack (MVVM, Room, Paging), Retrofit and Dagger 2

Over years Android architecture evolved to support complex, robust, production-quality apps on any scale. It is great to see how Google recommendations are aligned with Android community needs and choices. In the last years Google has promoted Kotlin as first class citizen, introduced Guide to app architecture starring uncle’s Bob Clean Architecture concept with MVVM presentation pattern. We have been given out of box architecture puzzles packed into Architecture Components and Android Jetpack. Retrofit, RxJava and Dagger have been taken into official tutorials.

13. [Android] MVVM & 안드로이드 아키텍쳐 컴포넌트 시작하기

Use Android Data Binding

1. Refactoring RecyclerView adapter to data binding

2. How to bind a list of items to a RecyclerView with Android Data Binding

3. Android RecyclerView with Data Binding Library

You have followed the group:

https://android-arsenal.com

http://www.tellmehow.co/

ใครสนใจ มา join line ได้ครับ รับจำนวนจำกัด ใครปัญหา ชอบแชร์ มีเรื่องอะไรใหม่ๆ สามารถ join เข้าได้เลยครับ 😁

หากสนใจ ก็สามารถ join ได้ที่นี้เลยครับ . หรือ scan qrcode . ไปได้เลย

[Android Github Dev] คุณได้รับคำเชิญให้เข้าร่วมสแควร์ของ LINE
https://line.me/ti/g2/UVVDK6Z5EE
Android Developer

Thank you for joining: https://www.facebook.com/groups/883546485084033/?fref=ts I created a group of Android Developers Android and Kotlin Droidcon Github library. If you have any questions, you can ask. You can join in the App Telegram. https://t.me/joinchat/IhB5KQ0aXC7ckNgjRaBaCw Now join Android Developers And Kotlin Droidcon Github Library Community Telegram App to help each other. Joining Link:

เข้าร่วม Group Line: เข้าร่วมกลุ่ม

: กล่องจดหมายเพื่อส่งอีเมล pongku71@gmail.com

Android Open Source Projects [inclusion] [SUM] [Join user groups] There is a problem with Android projects and want to give answers. What's new or want to update the robot continuously. Can join. Line: po56789 or inbox on the page, come to join, please just !!!!
Thank you

แฟนเพจ PongPloy Zone AppDev

Link : https://www.facebook.com/PPAndroid-Github-Dev-Zone-170227463027435/notifications/

Language learning application APP .

EN

Practice writing, reading, Kai-ABC, this application. Designed to be easy to use, uncomplicated, with illustrations and sound for train children to read according to Thai-English consonants clearly.Practice writing all 44 Thai consonants from chicken to hawk and 26 English consonants since A-Z makes it easy to learn and remember.This application is suitable for Thai students. And foreigners studying Thai languageAnd in the future, may add more games to children

Thai :

ฝึกเขียน อ่าน ก ไก่-ABC แอพพลิเคชั่นนี้ ออกแบบมาให้ใช้งานง่าย ไม่ซับซ้อน โดยมีภาพประกอบพร้อมเสียงสำหรับฝึก ให้เด็กๆ ท่องตาม อ่านเสียงพยัญชนะ ไทย — อังกฤษ ได้ชัดเจน ฝึกเขียนพยัญชนะไทยทั้ง 44 ตัว ตั้งแต่ ก ไก่ จนถึง ฮ นกฮูก และ พยัญชนะภาษาอังกฤษทั้ง 26 ตัว ตั้งแต่ A-Z ทำให้ง่ายต่อการเรียนรู้และจดจำแอพพลิเคชั่นนี้เหมาะสำหรับเด็กนักเรียนไทย และชาวต่างชาติที่ศึกษาภาษาไทยและต่อไปในอนาคต อาจจะเพิ่ม เกม ให้เด็กมาสนใจมากขึ้น

Download : App link : https://play.google.com/store/apps/details?id=com.pongploydev.education.mediaapp

--

--