Room + ViewModel + LiveData + RecyclerView (MVVM) Part 5 - VIEWMODEL - Android Studio Tutorial

author Coding in Flow   5 мес. назад

426 Like   0 Dislike

Room + ViewModel + LiveData + RecyclerView (MVVM) Part 6 - RECYCLERVIEW + ADAPTER - Android Tutorial

In part 6 of the Architecture Components tutorial, we will set up a RecyclerView to display the entries from our database table in our activity. For this we first prepare the XML layout for the single CardView rows and then create a RecyclerView.Adapter, where we add a ViewHolder as an inner class and implement onCreateViewHolder, onBindViewHolder and getItemCount to inflate it and populate it with data. To update the ArrayList in the onChanged callback of our LiveData, we add another public method to the adapter where we pass the new List and call notifyDataSetChanged. Watch the whole playlist: Example code, dependencies & instructions: ____________________ Subscribe to my channel: Want more Android tutorials? Check my playlist section: Follow me on social media: Facebook: Instagram: Twitter: Blog:

RxJava Introduction

Hello World, In this episode, we will be learning about ReactiveX java and how to get started working on android with RxJava. We will consume a GitHub gist API and display the files character length and file name in Textview. Hope you all will like the way I do this. Github link for this episode is given below: Link : I would like to extend my sincere thanks to technical crew my pals Intro- Video/Audio credits: Creative contribution on videography and technical co-ordination: Amogh KV (Canon T5i) Brilliant video recording. Canon T6S : Pavan R Deshpande Audio : Thirumalesh P

#4.6 Android Room Update Operation: Room Database Tutorial | Android Jetpack Tutorial

Access 7000+ courses for 60 days FREE: Android architecture components tutorial. In this video, you will learn how to update data in Room database. You will see the demo application in detail with the entire set up starting from the entity, DAO, database, and activity. Previous Video: Next Video: Source code files: Check out my website: ➤ Donate and support us [Only if you think our courses are better than Udemy or Udacity] ➤ Patreon: ➤ Paypal/Payoneer: ➤ UPI (only for India): smartherd@okaxis Programming courses: ➤ Ruby Programming: ➤ Dart Programming: ➤ Kotlin Programming: ➤ Java Programming: Flutter course: ➤ Flutter App Development: Android courses: ➤ Android using Kotlin: ➤ Android using Java: ➤ Android Material Design: ➤ Android Jetpack Architecture: ➤ Android Multiple Screen Support: ➤ Android Retrofit: More programming courses: ➤ Follow us on Facebook: Twitter: Github: ---- Thank you for your love and support ----

Room + ViewModel + LiveData + RecyclerView (MVVM) Part 1 - WHAT ARE ANDROID ARCHITECTURE COMPONENTS?

In this video series we will build a note taking app, using the Android Architecture Component libraries (Room, ViewModel, LiveData and LifeCycle), a RecyclerView and Java. The data will be stored in an SQLite database and supports insert, read, update and delete operations. For this we will follow the official recommendations from the "Guide to App Architecture" (link below). In part 1 we will learn what the Architecture Components are, how they work and why we need them. We will learn about the problems that arise from the Activity and Fragment lifecycle, configuration changes and bloated, tightly coupled classes and how ViewModel and LiveData can help us with that. ViewModels store and manage UI related data, they survive configuration changes and can be used seemlessly by the newly created activity. LiveData is an observable dataholder and it is life-cycle aware, which means it automatically starts and stops updating the UI-controller at the right times in it's lifecycle. For the backend of our app we will use the "Room Persistence Library", which works as a wrapper around SQLite and helps us reduce boilerplate code by making extensive use of Annotations. Instead of creating an SQLiteOpenHelper, we simply turn Java classes into "entities" to create tables, and use "Data Access Objects" (DAO) to query these tables and make operations on them. Room also provides compile time verification for SQL statements, so we run into fewer runtime exceptions, caused by typos and invalid queries. We will also use a "Repository" class that works as another abstraction layer between the ViewModel and the underlying data model. Together, this whole structure constitues an "MVVM" (Model-View-ViewModel) architecture, which follows the single responsibility and separation of concerns principles. Watch the whole playlist: Official Guide to App Architecture: ____________________ Subscribe to my channel: Want more Android tutorials? Check my playlist section: Follow me on social media: Facebook: Instagram: Twitter: Blog:

In part 5 of the Architecture Components tutorial, we will create our Viewmodel class.
The ViewModel works as a gateway between the UI controller and the repository. It stores and processes data for the activity/fragment and it doesn't get destoyed on configuration changes, so it doesn't lose it's variable state for example when the device is rotated.
By extending AndroidViewModel, we get a handle to the application context, which we then use to instantiate our RoomDatabase.
In our activity we let the system provide us the correct ViewModel instance by calling ViewModelProviders.of, where we pass the Activity or Fragment this ViewModel's lifecycle should be scoped to. When our Activity/Fragment is then destroyed, the ViewModel will go through it's onCleared method and get removed from the memory.
In our activitie's onCreate method, we retrieve the LiveData that is stored in our ViewModel and call observe on it, where we pass a LifecycleOwner and an Observer. In the onChange callback we get an update on our data whenever something in the corresponding database table changes. The LiveData will automatically start and stop sending updates to our activity at the right time in it's lifecycle and clean up any unused references.

Watch the whole playlist:

Example code, dependencies & instructions:

Subscribe to my channel:

Want more Android tutorials? Check my playlist section:

Follow me on social media:





Comments for video: