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

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

214 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:

Stock Android vs Android One vs Android Go - Gary Explains

Read the full post: | Android now comes in lots of flavors: stock Android on devices like the Pixel 2; Android One on the Moto X4 and the new high-end Nokia phones; and Android Oreo (Go edition), on phones like the Nokia 1. How to they compare? Let's find out! Note: For clarity, we're defining stock Android as whatever Google ships on its own hardware. Download the Android Authority App: Subscribe to our YouTube channel: ---------------------------------------------------- Stay connected to Android Authority: - - - - - - Follow the Team: Josh Vergara: Joe Hindy: Lanh Nguyen: Jayce Broda: Gary Sims: Kris Carlon: Nirave Gondhia: David Imel: Bailey Stein:

Making an NFC Enabled Smart Ring with Tritium and Forged Carbon Fiber

In today's video, Patrick Adair designs a ring made out of forged carbon fiber with a groove cut into it to fit an NFC antenna. He also filled in the rest of the groove with circuit board components, glow powder, and tritium vials. The ring allows you to perform a bunch of really useful functions with your smartphone, so this is definitely one of the most functional rings that Patrick has ever made. Stay up to date with the Forged Carbon NFC Smart Ring here: This will let me keep you in the loop as I design a way to make these faster so that I can sell them for a reasonable price! Special thanks to John from Carbon 6 Rings for the forged carbon fiber used in this video! BUY A HANDMADE RING HERE: MY RING SUPPLIES WEBSITE: INSTAGRAM: FACEBOOK: You can follow Dustin (the video guy) here: Lewis is here: and here:

My Top 10 Fav Android TV Boxes of 2018

My Top 10 Fav Android TV Boxes of 2018 ➡️ Top 10 TV Box Chart: --- ✅ NVIDIA SHIELD TV (2017) 8 OREO ➡️ Amazon US: ➡️ Amazon UK: ➡️ Amazon DE: ➡️ Amazon CA: ➡️ Amazon IN: --- ✅ H96 MAX (HEXACORE) v7 ➡️ Banggood: ➡️ Gearbest: --- ✅ X99 (HEXACORE) v7 ➡️ Banggood: ➡️ Gearbest: --- ✅ XIAOMI MI BOX - 8 OREO ➡️ Bangood: ➡️ Gearbest: --- ✅ FIRE TV 4K CUBE ➡️ Amazon US: ➡️ Ebay: --- ✅ FIRE TV 4K (3RD GEN) ➡️ Amazon US: ➡️ Amazon US: --- ✅ MAGICSEE C400 + TV TUNER ➡️ Bangood: ➡️ Gearbest: --- ✅ MECOOL M8S PRO L ➡️ Banggood: ➡️ Gearbest: --- ✅ H96 MAX PLUS 64GB ➡️ Banggood: ➡️ Aliexpress: --- ✅ AMAZON FIRE TV STICK 2 ➡️ Amazon US: ➡️ Amazon US: ➡️ Amazon DE: ➡️ Amazon In: --- —————— FREE Trials: 🆓 Amazon Prime FREE Trial US: 🆓 Amazon Prime FREE Trial UK: ——————— My Social Links: 🔵 View My Channel - 🔵 Follow on Twitter - 🔵 Follow on Facebook: 🔵 View my Website: 🔵 My Official Email: ---

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: