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.
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
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
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 😄
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
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.
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.
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" 🙈👋
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
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
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?
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 ?
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
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.
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
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
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.
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 :(
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 =)
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
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
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 😃
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?
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?
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
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 :-\
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.
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
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.
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'_
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!
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.
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.
thanks for being so considerate and 'apologising' for bad sound in the start. I hardly noticed it :)
Just amazing, I was looking for something like this a long time ago !
Greetings from Brazil
Aqui é BR!
Aqui tb é BR
Best Android explanation channel on RUclips.
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 !
this is great tutorial ! learning how to use mvvm in android app. glad that I found it early
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
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
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 😄
I've seen twice but still some interesting points to learn.
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
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.
or you can use object instead of class
@@dragossusi yes, you would keep the Singleton logic, but loose the lazyness
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.
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" 🙈👋
Tanx so much Reso coder.... I have a better understanding of Live data and MVVM now...
amaaaaaazing. teaching method. well done, awesome
great tutorial, best android tutorial quality I've seen on youtube so far
I think not using Room DB and making it fake DB made it more confusing
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
Sweet .. thanks :-)
and which font is it?
Thank you! :) Great explanation! And your voice is so nice!
13:24 you can simply use "object FakeDatabase {...}" to create a singleton
the same question
I love you!! This is just what I needed to progress!
Third video i've watched today. Amazing work!
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
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?
You are an awesome guy my friend!
Thank you very much Sir, Great tutorial ...
Best video about the argument!!!
thanks for this wonderful video - should the repo be init with the db and not the dao ? why repo is with constructor with dao?
You earned a new subscriber! Thank you so much man!
Great tutorial, many thanks
Great video!
What colour scheme/font are you using? Really like the colours?
Your tutorials are really very helpful. Thanks man.
Understandable content with easy explanation. Ty
Excellent tutor, required full tutorial explaining hitting REST API, Local Storage, Repository, ViewModel, View
Wonderful tutorial
Thanks so much, it's helpful !
Nice tutorial, hope you do LiveData + ViewModel + DataBinding on later video, and thanks!
I think that you can use the DI to create the Singleton instance for some of your classes
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 ?
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?
:)
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
It's really good tutorial for learning thanks bro
Awesome tutorial!! Thank u!
Thanks! That was really helpful to me
thx, best short tutorial
Amazing ! It's so helpful
I am completely lost in these classes and repository and fakedatabase. What's the best way to learn mvvm?
Maybe you'd benefit from my tutorial series where we build a real MVVM app for weather forecasts.
@@ResoCoder thanks I am following those and it's good so far.
@@ResoCoder What is that series ? I want to check that
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.
I suppose Quote should not be initialized on QuoteActivity cause it directly uses a model. If I'm wrong, please let me know.
How did the code recognize textview, edittext, and button's XML ids without databinding or findviewbyid in QuotesAcitvity?
It's possible using Kotlin synthetics, but the plugin (Kotlin Android Extensions) is now deprecated
Do you have tutorials for MVVM when using Firebase?
Thank you so much. Your explain is so nice and helpful for me !
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
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
Great video! Can you also make a video on Dependency injection for beginners?
Yes! I will publish it this Friday 😉
@@ResoCoder Great! Thanks a lot! Looking forward to the video
yes dagger2!!!
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
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.
Just amazing!
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??
Synthetic binding. Requires installing kotlin android extensions. Check this out: medium.com/coding-blocks/goodbye-findviewbyid-say-hello-to-synthetic-binding-in-kotlin-d3727bd8438e
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 :(
keep adding more videos.Thanks
Please create videos on testing
Thanks!! Your tutorial was realy helpful
I dont understand why at 16:58 the FakeDatabase object is no inheriting FakeDatabaseDao, but rather is creating FakeDatabaseDao as a new object?
Thanks. I've learned so much.
Thinks for your video, but I have a question: how to initialize view without invoking "findViewById" method?
Great Video (cheers)
Thanks for the tutorial. :D
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 =)
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
ViewModelProvider(this, factory)
This is so underrated. Thank you!
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
Sure! Check out my new videos. I'm doing a tutorial series where we're building a real world forecast mvvm app.
Hi, very nice and updated tutorial.
Can you add dagger2 and retrofit (web service) in this project tutorial too ?
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 😃
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 !!!
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?
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?
Using Fake database was a pretty bad idea here. Makes it so much confusing with terms QuoteDao, FakeDatabase, FakeQuoteDao
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
Thanks! Have you considered using the Room library? Even if not, watch my newest tutorial series. The last part is about creating a database.
Nice fonts in Android Studio , what`s name?
do u have mvvm tutorial with java ?
hey @6:50 , why override the toString method in kotlin data class? data class does that by default, right?
Yes it's, but for easy understanding u can override it
Very good video
Thanks you. I wait this tutorial.
can you make a video on testing
I think this volitale and sync is unneccessary because we have lazy pattern for kotlin...
is a singleton class needed for the repository even in real apps?
nice video.
I am from java background. what the hell🤯 is going on with Syntax.
I swear i had the same reaction :( I used Java more than a year ago
09:00 I can't use mutableListOf() What can ı do?
Thank you!!!
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 :-\
Why not used ROOM annotations?
very helpful. can you do the same tutorial using Java
I technically could but Kotlin is the way to go 😉
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.
your Android Studio looks like Visual Studio
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
other than this, no errors in the code showing up
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.
This line is failing > implementation "androidx.lifecycle:lifecycle-extensions:2.0.0-rc01"
Android Studio 3.2.1
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'_
nice
great!!
hello.
how to make code beautiful like this :))
What theme are you using for the android studio ide?
dracula
how do you have that dark theme of AS?
which version of android studio are you using?
I'm currently using version 3.3 Canary 6.
Thanks!
Thanks!
My android studio does not support android jetpack navigation!
Please give me suggestion
Well, if you install the latest 3.3 canary version, it will work.
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!