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

author Coding in Flow   5 мес. назад
17,011 views

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: https://www.youtube.com/playlist?list=PLrnPJCHvNZuDihTpkRs6SpZhqgBqPU118 Example code, dependencies & instructions: https://codinginflow.com/tutorials/android/room-viewmodel-livedata-recyclerview-mvvm/part-6-recyclerview-adapter ____________________ Subscribe to my channel: https://www.youtube.com/c/codinginflow?sub_confirmation=1 Want more Android tutorials? Check my playlist section: https://www.youtube.com/c/codinginflow/playlists Follow me on social media: Facebook: https://www.facebook.com/codinginflow Instagram: https://www.instagram.com/codinginflow Twitter: https://twitter.com/codinginflow Blog: https://codinginflow.com/

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 : https://github.com/ashokslsk/RxJava 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: https://pluralsight.pxf.io/c/1291657/424552/7490 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: https://youtu.be/VrP_GrgWzyo Next Video: https://youtu.be/_KwsIViPq7Q Source code files: https://bit.ly/2DMsj2g Check out my website: ➤ https://bit.ly/smartherd Donate and support us [Only if you think our courses are better than Udemy or Udacity] ➤ Patreon: https://bit.ly/patreon-donate ➤ Paypal/Payoneer: sriyank123@gmail.com ➤ UPI (only for India): smartherd@okaxis Programming courses: ➤ Ruby Programming: https://bit.ly/smyt-r ➤ Dart Programming: https://bit.ly/smyt-d ➤ Kotlin Programming: https://bit.ly/smyt-k ➤ Java Programming: https://bit.ly/smyt-j Flutter course: ➤ Flutter App Development: https://bit.ly/2Rg7EFR Android courses: ➤ Android using Kotlin: https://bit.ly/smyt-ka ➤ Android using Java: https://bit.ly/smyt-ja ➤ Android Material Design: https://bit.ly/2SMJqU6 ➤ Android Jetpack Architecture: https://bit.ly/yt-j ➤ Android Multiple Screen Support: https://bit.ly/smyt-mss ➤ Android Retrofit: https://bit.ly/2Ee6GHn More programming courses: ➤ https://bit.ly/smy-list Follow us on Facebook: https://bit.ly/smartherd-facebook Twitter: https://bit.ly/smartherd-twitter Github: https://bit.ly/smartherd-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: https://www.youtube.com/playlist?list=PLrnPJCHvNZuDihTpkRs6SpZhqgBqPU118 Official Guide to App Architecture: https://developer.android.com/jetpack/docs/guide ____________________ Subscribe to my channel: https://www.youtube.com/c/codinginflow?sub_confirmation=1 Want more Android tutorials? Check my playlist section: https://www.youtube.com/c/codinginflow/playlists Follow me on social media: Facebook: https://www.facebook.com/codinginflow Instagram: https://www.instagram.com/codinginflow Twitter: https://twitter.com/codinginflow Blog: https://codinginflow.com/

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:
https://www.youtube.com/playlist?list=PLrnPJCHvNZuDihTpkRs6SpZhqgBqPU118

Example code, dependencies & instructions:
https://codinginflow.com/tutorials/android/room-viewmodel-livedata-recyclerview-mvvm/part-5-viewmodel

____________________
Subscribe to my channel:
https://www.youtube.com/c/codinginflow?sub_confirmation=1

Want more Android tutorials? Check my playlist section:
https://www.youtube.com/c/codinginflow/playlists


Follow me on social media:

Facebook:
https://www.facebook.com/codinginflow

Instagram:
https://www.instagram.com/codinginflow

Twitter:
https://twitter.com/codinginflow

Blog:
https://codinginflow.com/

Comments for video: