Android MVVM Kotlin Tutorial - LiveData + ViewModel (Android Architecture Components)

  Рет қаралды 214,682

Reso Coder

Reso Coder

Күн бұрын

Пікірлер: 152
@DivyangM
@DivyangM 2 жыл бұрын
The BEST MVVM TUTORIAL on the planet for beginners. I wish I had a teacher like you when I was in college. Thank you, sir.
@tonyblack1981
@tonyblack1981 3 жыл бұрын
I absolutely love way you explain the purpose for everything you are doing throughout your tutorial. I'm subscribing. I don't want to speak too soon, but maybe you're the tutor I've been looking for to help me make sense of android dev. Thumbs up.
@mitchellthornton1223
@mitchellthornton1223 6 жыл бұрын
You're the best. I'd love to see you do a design pattern series. I have trouble understanding how to link everything together and the reasons behind design patterns
@ResoCoder
@ResoCoder 6 жыл бұрын
Thank you! I will make a full Android app series using MVVM pattern. I might do a comparison between different architectural patterns but I don't promise anything 😄
@ryanbennett6801
@ryanbennett6801 4 жыл бұрын
Best Android explanation channel on KZbin.
@verryondrums
@verryondrums 5 жыл бұрын
I wish I had discovered this tutorial 2 weeks ago. Would have saved me a lot of time...! Thanks anyway, really good explanations and examples !
@henriquedesouza412
@henriquedesouza412 5 жыл бұрын
Just amazing, I was looking for something like this a long time ago ! Greetings from Brazil
@G3me0S
@G3me0S 3 жыл бұрын
Aqui é BR!
@henriquefigueiredo4077
@henriquefigueiredo4077 3 жыл бұрын
Aqui tb é BR
@BinaryBenevolence
@BinaryBenevolence 2 жыл бұрын
this is great tutorial ! learning how to use mvvm in android app. glad that I found it early
@AdilKhalil
@AdilKhalil 4 жыл бұрын
thanks for being so considerate and 'apologising' for bad sound in the start. I hardly noticed it :)
@hellespont5072
@hellespont5072 4 жыл бұрын
Incredible tutorial!! Thank you so much for making this, you are an amazing teacher! I am currently making an app that handles the shopping in a retail store (for the people who physically shop or "pick" the items that are delivered to your house). I made a basic desktop version using java and MVC, but after seeing how well you put this together I am definitely going to use Kotlin and the MVVM techniques you have shown here. Much appreciated! Subscribed :D
@alextroy605
@alextroy605 4 жыл бұрын
Thank you, you are really simple explained the difference module: dao, repos, vm, vmf, and use that in Activity )) That's not simple to understand that when you are reading the manual by himself. Three time "addQuote" 🙈👋
@davidmfra
@davidmfra 6 жыл бұрын
Hey. @14:00 on your database singleton you could have used the lazy delegate, like this: val instance = lazy{ FakeDatabase()} also it's a good practice to not use this for the lock, use a private object for locking,so people cannot have access to your lock outside.
@dragossusi
@dragossusi 6 жыл бұрын
or you can use object instead of class
@davidmfra
@davidmfra 6 жыл бұрын
@@dragossusi yes, you would keep the Singleton logic, but loose the lazyness
@mohsenss8791
@mohsenss8791 5 жыл бұрын
I've seen twice but still some interesting points to learn.
@matt-g-recovers
@matt-g-recovers 3 жыл бұрын
I have used this as reference last couple years when I forget this or that. It's a great crash course and quick reference. I love the DI from scratch @27:20
@patrickstens2779
@patrickstens2779 6 жыл бұрын
Great video! What colour scheme/font are you using? Really like the colours. Edit: It's the Material UI Theme Plugin with color scheme set to Material Darker
@michaelgidron
@michaelgidron 5 жыл бұрын
Sweet .. thanks :-)
@berkc5323
@berkc5323 4 жыл бұрын
and which font is it?
@nandomkumchi4377
@nandomkumchi4377 4 жыл бұрын
Tanx so much Reso coder.... I have a better understanding of Live data and MVVM now...
@kingmarwat
@kingmarwat 3 жыл бұрын
amaaaaaazing. teaching method. well done, awesome
@dival9963
@dival9963 4 жыл бұрын
Really awesome video! It would be nice to provide an advanced implementation like this, combining mvvm with services, where data are driven from services to a database
@michalrv3066
@michalrv3066 5 жыл бұрын
great tutorial, best android tutorial quality I've seen on youtube so far
@remali26
@remali26 3 жыл бұрын
Everyone if you want to rename something press the word you want to rename and then press shift+F6 and then enter. Or press right click refactor -> rename.
@nsansa9234
@nsansa9234 2 жыл бұрын
I think not using Room DB and making it fake DB made it more confusing
@savaramkiran
@savaramkiran 6 жыл бұрын
Excellent tutor, required full tutorial explaining hitting REST API, Local Storage, Repository, ViewModel, View
@dhivabanyuwigara7406
@dhivabanyuwigara7406 5 жыл бұрын
Nice tutorial, hope you do LiveData + ViewModel + DataBinding on later video, and thanks!
@TheAiSaEr
@TheAiSaEr 6 жыл бұрын
Thank you! :) Great explanation! And your voice is so nice!
@anthonyporter7390
@anthonyporter7390 5 жыл бұрын
Third video i've watched today. Amazing work!
@asadmukhtar1
@asadmukhtar1 5 жыл бұрын
Great video! What colour scheme/font are you using? Really like the colours?
@LoldemortII
@LoldemortII 3 жыл бұрын
I love you!! This is just what I needed to progress!
@MultiBuzzTube
@MultiBuzzTube 4 жыл бұрын
thanks for this wonderful video - should the repo be init with the db and not the dao ? why repo is with constructor with dao?
@Enshaedn
@Enshaedn 5 жыл бұрын
Thank you for the video. It has helped me understand MVVM better though I still feel like I need more practice with it. Specifically related to actually connecting with a database. I was wondering if any of your other videos/tutorials explain connecting with Firestore. Would it be made via calls / queries in the Repository class or would you still have a Database class which instantiates the DB connection and makes the queries? Firestore also allows listeners for data changes so I don't understand if LiveData should be used as well or if it matters. Using Firestore also seems like Room wouldn't need to be used. Is that correct?
@moritziseke9658
@moritziseke9658 6 жыл бұрын
13:24 you can simply use "object FakeDatabase {...}" to create a singleton
@amrh4259
@amrh4259 6 жыл бұрын
the same question
@JessintaFernandes
@JessintaFernandes Жыл бұрын
Thank you very much Sir, Great tutorial ...
@cs-ope
@cs-ope Жыл бұрын
You are an awesome guy my friend!
@SabbathJoe89v2
@SabbathJoe89v2 4 жыл бұрын
Best video about the argument!!!
@navdeepbrar3526
@navdeepbrar3526 2 жыл бұрын
How did the code recognize textview, edittext, and button's XML ids without databinding or findviewbyid in QuotesAcitvity?
@adravel
@adravel 2 жыл бұрын
It's possible using Kotlin synthetics, but the plugin (Kotlin Android Extensions) is now deprecated
@ralphordanza3487
@ralphordanza3487 5 жыл бұрын
You earned a new subscriber! Thank you so much man!
@shrikantdevarmani9473
@shrikantdevarmani9473 5 жыл бұрын
Understandable content with easy explanation. Ty
@samha1513
@samha1513 6 жыл бұрын
I am completely lost in these classes and repository and fakedatabase. What's the best way to learn mvvm?
@ResoCoder
@ResoCoder 6 жыл бұрын
Maybe you'd benefit from my tutorial series where we build a real MVVM app for weather forecasts.
@samha1513
@samha1513 6 жыл бұрын
@@ResoCoder thanks I am following those and it's good so far.
@ralphGabbbbbb
@ralphGabbbbbb 5 жыл бұрын
@@ResoCoder What is that series ? I want to check that
@heavysoccer7862
@heavysoccer7862 6 жыл бұрын
Your tutorials are really very helpful. Thanks man.
@dreb.7760
@dreb.7760 2 жыл бұрын
Great tutorial, many thanks
@gerardpalma8006
@gerardpalma8006 3 жыл бұрын
I think that you can use the DI to create the Singleton instance for some of your classes
@khanhsb15
@khanhsb15 Жыл бұрын
Thanks so much, it's helpful !
@DjangoMx
@DjangoMx 5 жыл бұрын
Great video but i have a question, for each view model i have to create a viewmodel factory? because in the video you only create one for the only one viewmodel you have
@raghav_achari
@raghav_achari 4 жыл бұрын
how did he set listener to the button with just id?? i mean without findViewById().... and also accessed other ui elements with just id.. how??
@bsrafael
@bsrafael 4 жыл бұрын
Synthetic binding. Requires installing kotlin android extensions. Check this out: medium.com/coding-blocks/goodbye-findviewbyid-say-hello-to-synthetic-binding-in-kotlin-d3727bd8438e
@voicheci007
@voicheci007 6 жыл бұрын
Great video! Can you also make a video on Dependency injection for beginners?
@ResoCoder
@ResoCoder 6 жыл бұрын
Yes! I will publish it this Friday 😉
@voicheci007
@voicheci007 6 жыл бұрын
@@ResoCoder Great! Thanks a lot! Looking forward to the video
@jktan5793
@jktan5793 6 жыл бұрын
yes dagger2!!!
@adibazhar1115
@adibazhar1115 5 жыл бұрын
Hi, I familiar with android studio in Java but new in Kotlin...what is the basic things u can suggest before I start to learn about MVVM ? like coroutines, room, etc ?
@joshthiele8416
@joshthiele8416 5 жыл бұрын
Excellent video. I'm new to development, so i could be totally wrong, but shouldn't the business logic be in the ViewModel, and not in the View? :)
@Since1059
@Since1059 4 жыл бұрын
It's really good tutorial for learning thanks bro
@roasters943
@roasters943 Жыл бұрын
Wonderful tutorial
@danildv2001
@danildv2001 4 жыл бұрын
Awesome tutorial!! Thank u!
@soulduse
@soulduse 6 жыл бұрын
Thank you so much. Your explain is so nice and helpful for me !
@amrh4259
@amrh4259 6 жыл бұрын
Great tutorial, I prefer if you can draw a sample flow graph just to make it easier for you and for us too many thanks
@CiaphasCain21
@CiaphasCain21 4 жыл бұрын
Thanks! That was really helpful to me
@ezscootrr
@ezscootrr 4 жыл бұрын
Do you have tutorials for MVVM when using Firebase?
@pd6732
@pd6732 6 жыл бұрын
Thanks for the video. Have been doing android stuff for quite some time now, but never follwed any particular design patters because the apps were for personal use only. Btw. what color scheme/font are you using? Kinda reminds me of default atom colors. cheers
@ResoCoder
@ResoCoder 6 жыл бұрын
Yes, the need for patterns comes after a few finished projects :D I'm using "Material Darker" theme. It's a plugin for Android Studio. The font is Consolas.
@ashiqurrahmantahmid9634
@ashiqurrahmantahmid9634 4 жыл бұрын
Amazing ! It's so helpful
@elpirato5428
@elpirato5428 3 жыл бұрын
thx, best short tutorial
@OmerFarukUcer
@OmerFarukUcer 2 жыл бұрын
I still can't understand the topic.I try to learn MVVM architecture using in an app but still can't understand why we use this kind of different usages.I mean it's like there is no logic.How can I learn it easily?I tried my best but still can't understand the liveData or MVVM architechture :(
@jollibeecheese
@jollibeecheese 4 жыл бұрын
I suppose Quote should not be initialized on QuoteActivity cause it directly uses a model. If I'm wrong, please let me know.
@VinayKumar-mb3ge
@VinayKumar-mb3ge 5 жыл бұрын
keep adding more videos.Thanks
@mohsenss8791
@mohsenss8791 5 жыл бұрын
Thanks. I've learned so much.
@LordOfTheBing
@LordOfTheBing 4 жыл бұрын
23:10 if your QuoteViewModel is only passing along the repos's method, it is an useless intermediate. In this case, you can work on the repo directly instead of adding complexity for the sake of it.
@md.naimurrahman2466
@md.naimurrahman2466 2 жыл бұрын
Just amazing!
@EL-cb1nu
@EL-cb1nu 4 жыл бұрын
I dont understand why at 16:58 the FakeDatabase object is no inheriting FakeDatabaseDao, but rather is creating FakeDatabaseDao as a new object?
@CiaphasCain21
@CiaphasCain21 4 жыл бұрын
Thanks!! Your tutorial was realy helpful
@jktan5793
@jktan5793 6 жыл бұрын
Hi, very nice and updated tutorial. Can you add dagger2 and retrofit (web service) in this project tutorial too ?
@ResoCoder
@ResoCoder 6 жыл бұрын
Thanks. I will publish a tutorial on MVVM and Kodein which is a dependency injection framework built for Kotlin. I'm also currently preparing a whole tutorial series where we'll be using Retrofit2, Room and more. Stay tuned 😃
@jktan5793
@jktan5793 6 жыл бұрын
Thank you so much. Love the way you teaching, and also your sound is really clear and good =) Can't wait for them haha. Thank you once again !!!
@mohsenss8791
@mohsenss8791 5 жыл бұрын
In case of a chat app that we have two models, if we have just one repository which gives data to all view models, it does not make sense. Because all the functions we have in the repository is accessible in any view models. For example, we can get a list of groups in user viewmodel. So what can we do for this problem?
@mankesh_mishra
@mankesh_mishra 4 жыл бұрын
Great Video (cheers) Thanks for the tutorial. :D
@ziweiguo7821
@ziweiguo7821 6 жыл бұрын
Thinks for your video, but I have a question: how to initialize view without invoking "findViewById" method?
@fabrizziocht
@fabrizziocht 6 жыл бұрын
When I have many entities, should I create a repository for each one? For example, if I have the Post and Blog entities, each with its own DAO, I could implement a repository for each one, but in a real application I may need both at the same time in a synchronizeAll () method. How can I solve this?
@cwssoftware3588
@cwssoftware3588 5 жыл бұрын
Please create videos on testing
@abdulhakeemmahmood5463
@abdulhakeemmahmood5463 6 жыл бұрын
hey @6:50 , why override the toString method in kotlin data class? data class does that by default, right?
@advancedprogramming62
@advancedprogramming62 5 жыл бұрын
Yes it's, but for easy understanding u can override it
@blackkingblackjack3325
@blackkingblackjack3325 2 жыл бұрын
I encounter an unsresolved reference issue in the QuotesActivity when I reference the textView or editText, any idea why? I get unrseolved reference and variable expected
@blackkingblackjack3325
@blackkingblackjack3325 2 жыл бұрын
other than this, no errors in the code showing up
@voicheci007
@voicheci007 6 жыл бұрын
Hi Matej! Can you do another tutorial like this but with a real DAO (Room library) and a real web service you can call? This is a bit confusing. Thank you for understanding
@ResoCoder
@ResoCoder 6 жыл бұрын
Sure! Check out my new videos. I'm doing a tutorial series where we're building a real world forecast mvvm app.
@kamala132
@kamala132 6 жыл бұрын
Amazing tutorial mate, thanks a lot for it! Could you please explain how do I plug a real db in this pattern? I m using normal sqlite with Anko library
@ResoCoder
@ResoCoder 6 жыл бұрын
Thanks! Have you considered using the Room library? Even if not, watch my newest tutorial series. The last part is about creating a database.
@OurPastSecrets
@OurPastSecrets 5 жыл бұрын
I'm confused at the distinction of DAO and Repository - I always thought of them as the same thing. Your implementation of Respository just calls the DAO.getQuotes() or DAO.addQuote() so why the extra layer
@MateusMeurer
@MateusMeurer 3 жыл бұрын
Oh fuck me twice, seriously? I know the good practices are here to better our lives but damn, he already have like 4 packages and 6 classes and I'm halfway through the tutorial and this is a simple quote app. Thank you for the tutorial btw very clear =)
@dogukangoktas693
@dogukangoktas693 3 жыл бұрын
09:00 I can't use mutableListOf() What can ı do?
@sanaebadi97
@sanaebadi97 5 жыл бұрын
do u have mvvm tutorial with java ?
@sadzolot2
@sadzolot2 5 жыл бұрын
Nice fonts in Android Studio , what`s name?
@pembatamang8233
@pembatamang8233 5 жыл бұрын
is a singleton class needed for the repository even in real apps?
@nkheart4
@nkheart4 5 жыл бұрын
If who want to run the code but don't want to write by your self. This is the code that I write from this tutorial. Some command I change it to the latest Kotlin version. github.com/heart/Android-MVVM-Kotlin
@tigranbabajanyan842
@tigranbabajanyan842 5 жыл бұрын
Why not used ROOM annotations?
@krishnachinya
@krishnachinya 6 жыл бұрын
very helpful. can you do the same tutorial using Java
@ResoCoder
@ResoCoder 6 жыл бұрын
I technically could but Kotlin is the way to go 😉
@krishnachinya
@krishnachinya 6 жыл бұрын
Yeah, but most companies don't switch to kotlin from java. its rework and there is not much advantage in switching in terms of performance or support. at the end of the day both codes are converted into bytecode.
@ProjectNullTheGame
@ProjectNullTheGame 6 жыл бұрын
I think this volitale and sync is unneccessary because we have lazy pattern for kotlin...
@pembatamang8233
@pembatamang8233 5 жыл бұрын
your Android Studio looks like Visual Studio
@bricktop5403
@bricktop5403 17 күн бұрын
Using Fake database was a pretty bad idea here. Makes it so much confusing with terms QuoteDao, FakeDatabase, FakeQuoteDao
@holofox66
@holofox66 6 жыл бұрын
Thanks you. I wait this tutorial.
@cwssoftware3588
@cwssoftware3588 5 жыл бұрын
can you make a video on testing
@ProGaming-kb9io
@ProGaming-kb9io 3 жыл бұрын
ViewModelProvider(this, factory)
@joshuasingleton9297
@joshuasingleton9297 3 жыл бұрын
This is so underrated. Thank you!
@tubebility
@tubebility 6 жыл бұрын
This line is failing > implementation "androidx.lifecycle:lifecycle-extensions:2.0.0-rc01" Android Studio 3.2.1
@tubebility
@tubebility 6 жыл бұрын
After researching the components website, I learn that you now have to specify the viewmodel and livedata extensions separately. _implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.0.0'_ _implementation 'androidx.lifecycle:lifecycle-livedata:2.0.0'_
@TikTokTrendsCompilation
@TikTokTrendsCompilation 6 жыл бұрын
how do you have that dark theme of AS?
@MinhTran-xn3kk
@MinhTran-xn3kk 5 жыл бұрын
hello. how to make code beautiful like this :))
@shaikhaaves6645
@shaikhaaves6645 6 жыл бұрын
which version of android studio are you using?
@ResoCoder
@ResoCoder 6 жыл бұрын
I'm currently using version 3.3 Canary 6.
@shaikhaaves6645
@shaikhaaves6645 6 жыл бұрын
Thanks!
@shaikhaaves6645
@shaikhaaves6645 6 жыл бұрын
Thanks! My android studio does not support android jetpack navigation! Please give me suggestion
@ResoCoder
@ResoCoder 6 жыл бұрын
Well, if you install the latest 3.3 canary version, it will work.
@shaikhaaves6645
@shaikhaaves6645 6 жыл бұрын
Thanks for your suggestion, i just did it and it actually worked! Thanks! Can you please make a video on Repository + Navigation + Retrofit + ViewModel + RecyclerView!!!!! Please do make one!
@eesaaphilips9271
@eesaaphilips9271 6 жыл бұрын
What theme are you using for the android studio ide?
@kaustubhtrivedi5403
@kaustubhtrivedi5403 6 жыл бұрын
dracula
@tejasjani2544
@tejasjani2544 3 жыл бұрын
nice video. I am from java background. what the hell🤯 is going on with Syntax.
@hamzamateen7827
@hamzamateen7827 3 жыл бұрын
I swear i had the same reaction :( I used Java more than a year ago
@ProjectNullTheGame
@ProjectNullTheGame 6 жыл бұрын
where is the code?
@АкимДанилов-к2е
@АкимДанилов-к2е 4 жыл бұрын
Thank you!!!
@agung.k
@agung.k 5 жыл бұрын
What if FakeDatabase class is not declared as a "class", but as an "object" instead?
@advancedprogramming62
@advancedprogramming62 5 жыл бұрын
Just try, it's not possible
@witoldsienski1709
@witoldsienski1709 6 жыл бұрын
Very good video
@this-is-bioman
@this-is-bioman 3 жыл бұрын
The actual content of wiring-up the view with the model begins at 30:00. I find the FakeQuoteDao is overengineered not only for this example but in general. There should be only a repository exposing an interface so that you can exchange the repository. The way you did it creates unnecessary repetitions where you end up with three (!) methods named getQuotes. This tutorial is also too long. Mixing dependency injection and all the factories etc here makes it difficult to follow. The focus should have been just to wire-up the model with the view which could have been done in less than 8 minutes :-\
@dentor2005
@dentor2005 4 жыл бұрын
Memory LEAK. As for me it's not a good idea to receive LiveData from repository directly (through ViewModel) to Layout / Activvity / Fragment. Because you don't know how much time it will take to the DataBase to execute your query. It should be asynchronous task. That's why you should wait in ViewModel the answer from the Repository DB and then using switchMap replace the answer (LiveData ) from Repository to LiveData that is intended for your Layout. Summary: Get data from DB to ViewModel and if Activity / Fragment AND put the answer to the new LiveData that will be received in Activity / Frament. Why? Because user can run some task that needs DB data (REST API for example), and without waiting for the end of execution exit from Application or switched to another Activity / Fragment.
Perfect Pitch Challenge? Easy! 🎤😎| Free Fire Official
00:13
Garena Free Fire Global
Рет қаралды 93 МЛН
HELP!!!
00:46
Natan por Aí
Рет қаралды 71 МЛН
How To Choose Mac N Cheese Date Night.. 🧀
00:58
Jojo Sim
Рет қаралды 82 МЛН
MVVM в Android на практике
41:32
Тимофей Коваленко
Рет қаралды 49 М.
Why Unreal Engine 5.5 is a BIG Deal
12:11
Unreal Sensei
Рет қаралды 581 М.
you need to build a RUST desktop app!!
27:21
Travis Media
Рет қаралды 328 М.
Model View View-Model (MVVM): Getting Started
29:12
CodingWithMitch
Рет қаралды 399 М.
ViewModels & Configuration Changes - Android Basics 2023
18:46
Philipp Lackner
Рет қаралды 131 М.
Kotlin Coroutine (High-quality Course)
2:07:37
Smartherd
Рет қаралды 105 М.
LiveData Explained - Android Architecture Component | Tutorial
12:12