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

author Coding in Flow   2 мес. назад
6,233 views

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

Stock Android vs Android One vs Android Go - Gary Explains

Read the full post: http://andauth.co/nONWWc | 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: https://andauth.co/aa-app Subscribe to our YouTube channel: https://andauth.co/subscribe ---------------------------------------------------- Stay connected to Android Authority: - http://www.androidauthority.com - http://facebook.com/androidauthority/ - http://twitter.com/androidauth/ - http://instagram.com/androidauthority/ - https://snapchat.com/add/androidauth - http://google.com/+androidauthority Follow the Team: Josh Vergara: https://twitter.com/jvtechtea Joe Hindy: https://twitter.com/ThatJoeHindy Lanh Nguyen: https://twitter.com/LanhNguyenFilms Jayce Broda: https://twitter.com/jaycebroda Gary Sims: https://twitter.com/garysims Kris Carlon: https://twitter.com/kriscarlon Nirave Gondhia: https://twitter.com/nirave David Imel: https://twitter.com/durvidimel Bailey Stein: https://twitter.com/baileystein1

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: http://forgedcarbonnfc.com/signup 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: https://patrickadairdesigns.com/ MY RING SUPPLIES WEBSITE: https://patrickadairsupplies.com/ INSTAGRAM: https://goo.gl/Awvokb FACEBOOK: https://goo.gl/9R3TTX You can follow Dustin (the video guy) here: https://goo.gl/f1P9Rk Lewis is here: https://goo.gl/AigT6H and here: https://www.instagram.com/lewiswf/

My Top 10 Fav Android TV Boxes of 2018

My Top 10 Fav Android TV Boxes of 2018 ➡️ Top 10 TV Box Chart: http://bit.ly/2Od1rgr --- ✅ NVIDIA SHIELD TV (2017) 8 OREO ➡️ Amazon US: https://amzn.to/2JPrVBG ➡️ Amazon UK: https://amzn.to/2JymcB8 ➡️ Amazon DE: https://amzn.to/2yjhe2E ➡️ Amazon CA: https://amzn.to/2ylUMpI ➡️ Amazon IN: https://amzn.to/2OM344t --- ✅ H96 MAX (HEXACORE) v7 ➡️ Banggood: https://goo.gl/HWViwB ➡️ Gearbest: http://bit.ly/2yn2MtG --- ✅ X99 (HEXACORE) v7 ➡️ Banggood: http://bit.ly/2qVl4uS ➡️ Gearbest: http://bit.ly/2tiHNSX --- ✅ XIAOMI MI BOX - 8 OREO ➡️ Bangood: https://goo.gl/W1ehRz ➡️ Gearbest: http://bit.ly/2I6fNHs --- ✅ FIRE TV 4K CUBE ➡️ Amazon US: https://amzn.to/2vdip2V ➡️ Ebay: https://ebay.to/2LMQYag --- ✅ FIRE TV 4K (3RD GEN) ➡️ Amazon US: https://amzn.to/2uXyxHS ➡️ Amazon US: https://amzn.to/2v1blZr --- ✅ MAGICSEE C400 + TV TUNER ➡️ Bangood: http://bit.ly/2MwC20j ➡️ Gearbest: http://bit.ly/2MwX8vO --- ✅ MECOOL M8S PRO L ➡️ Banggood: https://goo.gl/DmWAUc ➡️ Gearbest: http://bit.ly/2MIZnZo --- ✅ H96 MAX PLUS 64GB ➡️ Banggood: http://bit.ly/2MIZRNJ ➡️ Aliexpress: http://bit.ly/2ODVPIn --- ✅ AMAZON FIRE TV STICK 2 ➡️ Amazon US: http://amzn.to/2A10XCr ➡️ Amazon US: http://amzn.to/2i0wk95 ➡️ Amazon DE: https://amzn.to/2y2Bx4T ➡️ Amazon In: https://amzn.to/2y2ByWv --- —————— FREE Trials: 🆓 Amazon Prime FREE Trial US: http://amzn.to/2nD6SIs 🆓 Amazon Prime FREE Trial UK: http://amzn.to/2n4GovS ——————— My Social Links: 🔵 View My Channel - http://youtube.com/ChigzTechReviews 🔵 Follow on Twitter - http://twitter.com/ChigzTechReview 🔵 Follow on Facebook: http://facebook.com/ChigzTechReviews 🔵 View my Website: http://ChigzTech.com 🔵 My Official Email: chigz@chigztech.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: