MVVM / MVI Repository Pattern with Hilt

  Переглядів 67,286

CodingWithMitch

CodingWithMitch

3 роки тому

The best android courses in the world: codingwithmitch.com/
Watch the HILT course here (FREE): codingwithmitch.com/courses/h...
A very simple example using MVVM / MVI, Repository Pattern, Hilt dependency injection, Network layer with Retrofit, Caching layer with Room, Coroutines.
This is a complete example so you can see the big picture when it comes to using Hilt and android architecture.
Code: github.com/mitchtabian/Dagger...
Instagram: / codingwithmitch
Twitter: / mitch_tabian
.
.
#AndroidDev

КОМЕНТАРІ: 178
@TheAnilmaddala
@TheAnilmaddala 3 роки тому
This is so useful! and I keep coming back to this. So I created myself a breakdown :) 0:00 Project Setup 3:35 Remote Model creation and Retrofit Setup 12:00 EntityMapper 16:00 Room Setup and Local cache model creation 25:00 Dependency Injection - App + Retrofit 32:05 Dependency Injection - Room 35:00 DataState 38:00 MainRepository creation 43:20 MainViewModel 46:00 MVI 51:30 MainActivity
@AKAzadanine
@AKAzadanine Рік тому
Thanks
@zhanyshmasirov4611
@zhanyshmasirov4611 2 роки тому
thank you Matthew(Mitch) , actually english isn't my mother tongue , I'm actually viewing Russian Android developers Channel in youtube , but they're not explaing on begining of project , they're explaining from already done projects and its very heavy to understand if not begin explanation from begining , i'm beginner but I've undertand everything! thank once again. because you've explained from begining in project
@sheenfabile9460
@sheenfabile9460 3 роки тому
This is what im looking for! MVI using flow. Will get membership to support your tutorial. Thank you!
@dahlola
@dahlola 3 роки тому
Nice tutorial! For anyone wondering, "dao" stands for Data Access Object. So in the context of an database it handles the access to the data.
@vrajeshhirani
@vrajeshhirani 3 роки тому
Have been browsing quite a few tutorials on MVI & Clean Architecture and yours is definitely the one that I enjoyed watching. Your way of teaching is really good and I appreciate your hard work behind this. Thank you so much.
@lbars
@lbars 3 роки тому
Yes, exactly what I needed. All architecture concepts at the same video. Thank you CodingWithMitch ❤
@bro_chenzox
@bro_chenzox 3 роки тому
The most excellent explanation format (a whole hour) - everything from scratch and in order, as in real life, despite the fact that the volume can twitch the eye, but if you do not rush and think about each embedded topic with understanding, it turns out incredibly cool and understandable!!
@codingwithmitch
@codingwithmitch 3 роки тому
"despite the fact that the volume can twitch the eye" Like the volume of the content or the volume of my audio?
@bro_chenzox
@bro_chenzox 3 роки тому
@@codingwithmitch Comparing to other Hilt related videos content))
@amateur_gamer101
@amateur_gamer101 Рік тому
I could literally kiss you for this tutorial 😭😭 its so easy to understand. You just got a new follower.
@foivosstamopoulos9709
@foivosstamopoulos9709 3 роки тому
PERFECT tutorial! So much knowledge combined. Thank you once again
@edvardgrei1257
@edvardgrei1257 3 роки тому
Thank you Mitch. It really opened my eyes. Going to take your paid course for sure. Good Job
@vishwaraghavendra8332
@vishwaraghavendra8332 3 роки тому
Omg!! Finally.. Was waiting for this tutorial
@cdmunoz
@cdmunoz 3 роки тому
Awesome job! Thanks for sharing it with all the community
@hosseinmirzazadeh290
@hosseinmirzazadeh290 3 роки тому
You're doing a great job with these tutorials.
@arulwastaken
@arulwastaken 3 роки тому
Thank you mitch for wonderful explanation. im working on android almost 2 year with java now i can understand kotline with best approach by watching all your tutorials. I'll suggest your channel and blod and site to colleague.
@maksonic_official
@maksonic_official 3 роки тому
powerful work! Thanks so much for this video, I will definitely go to your site to see the lessons!
@superjkmax88
@superjkmax88 3 роки тому
This is an awesome video Mitch! I wish credit cards were available in my country so I could buy a membership on your site. I’ve been reading the courses’ source code on github and failing to understand some concepts fully, this video helped me immensely!
@lovemashup7975
@lovemashup7975 2 роки тому
It is definitely the most useful demo I have ever seen. Thanks Mitch for your contribution, it helps a lot :)
@dineshkhedkar8721
@dineshkhedkar8721 3 роки тому
Thanks!!! Everything on one plate. Great Work
@SerarEstaifan
@SerarEstaifan 3 роки тому
The best ever! Thank you sir 🙏🏻
@mattgraves3709
@mattgraves3709 2 роки тому
I enjoyed this implementation example. Thanks Mitch
@Irshu
@Irshu 3 роки тому
thanks Mitch, finally a terrific tutorial!
@nitinnegi9343
@nitinnegi9343 3 роки тому
Awesome.. "YOU NAILED IT"
@jimpauloovejera2599
@jimpauloovejera2599 3 роки тому
This thing is a gold mine! Thanks for the free stuff!
@gabvideos237
@gabvideos237 3 роки тому
Thank you for this tutorial! Intuitive & Very useful !
@wisnusuryawardhana7891
@wisnusuryawardhana7891 3 роки тому
THANKS MITCH!!!
@bahaaka828
@bahaaka828 3 роки тому
i really liked it. make more of these kind of videos 1 hour contains the summary of 8 hours course
@georgepereiramarques1445
@georgepereiramarques1445 3 роки тому
Thanks man, such a nice tutorial! Congrats!
@user-cf5ks8cv8l
@user-cf5ks8cv8l 3 роки тому
Thanks for clear and useful example!
@jamilxt
@jamilxt 3 роки тому
That's what I was looking for. Thank you. ^_^
@aravind_us
@aravind_us 2 роки тому
No words to say....it's awesome tutorial....😍😍😍
@ofirkosto
@ofirkosto 2 роки тому
Awesome video !! Thank you Mitch you are doing a great work you should be proud of yourself!
@jaloliddinabdullaev2310
@jaloliddinabdullaev2310 Рік тому
Best tutorial for MVI on youtube, thanks
@codingwithmitch
@codingwithmitch Рік тому
Ya man no worries
@jackli1924
@jackli1924 Рік тому
Thank you Mitch,a wonderful video! Your tech is so excellent and your explaination is so consice and awesome!
@nrsingh7203
@nrsingh7203 3 роки тому
wooooh!! Hats off to you man[Amazing explanation of android components]... I wish I can hit more likes...
@ozgurtas4508
@ozgurtas4508 3 роки тому
thanks mitch, very good tutorial
@malpv
@malpv Рік тому
Nice tutorial! Thanks! Saludos desde Chile!
@alvaroisea2259
@alvaroisea2259 3 роки тому
Big fan of your tutorials man !, I'm even giving a thumbs up without even watching the whole video sometimes
@codingwithmitch
@codingwithmitch 3 роки тому
that's what I like to hear
@mytubekt
@mytubekt 2 роки тому
Very helpful video. Thanks!
@girishak9404
@girishak9404 3 роки тому
Wow that's fantastic video. Thanks Mike.
@codingwithmitch
@codingwithmitch 3 роки тому
*Mitch*
@girishak9404
@girishak9404 3 роки тому
CodingWithMitch Yes Mitch 😂
@SourabhSNath
@SourabhSNath 3 роки тому
Perfect tutorial!
@adamgardner1986
@adamgardner1986 3 роки тому
Awesome video and thank you. Very helpful. Now to figure out how to test that ViewModel and Flow.
@xxluciferinxx
@xxluciferinxx 3 роки тому
thanks for this amazing video! leared a lot from this video.
@gulabpatel7477
@gulabpatel7477 3 роки тому
1000 plus salute man. Your explanation methods are so easy. I don't even know and experience In kotlin still I can understand all the things very clear manners
@fahtulrahman8231
@fahtulrahman8231 3 роки тому
Still The best teacher for android dev i've ever seen hehe
@alitonoliveira1700
@alitonoliveira1700 3 роки тому
Awesome and fast like a bullet :)
@bjugdbjk
@bjugdbjk 3 роки тому
The best vid to know about modern android development using kotlin,livedata,viewmodel, Hilt and MVi architecture, if the same thing if we want to do with Java and traditional ways..it gonna be 4hrs long r even more...u r awesome Mitch.
@lbars
@lbars 3 роки тому
and probably 2 hour for debugging things 😂
@pejmanazad5852
@pejmanazad5852 3 роки тому
My brain is burning. 🔥
@Firespirit233
@Firespirit233 3 роки тому
why? this is quite easy, and mitch is explaining it very well and simple
@foreverrafs
@foreverrafs 3 роки тому
oh my God this is so good.
@abhisheksaxena518
@abhisheksaxena518 3 роки тому
Amazing tutorial!!
@mrsoommy9162
@mrsoommy9162 3 роки тому
Great tutorial! Thanks a lot
@muhammadsalman4389
@muhammadsalman4389 3 роки тому
Thanks for MVI ❤️
@lazaroyesid
@lazaroyesid 2 роки тому
Thanks!! well explained !
@polarisnation201
@polarisnation201 2 роки тому
This video is what i need. Thanks you
@aliakkawi4759
@aliakkawi4759 3 роки тому
Awesome tutorial, thanks a lot
@aalap03
@aalap03 3 роки тому
Superb explanation keep going. Just at 54:55 you can use progressbar.isVisible = isDisplayed to avoid checking if condition and let that view extension method take care of it. :)
@suren6413
@suren6413 2 роки тому
Am an average developer only. But I have learned a lot by your tutorials. Thanks you a lot Mitch
@bhuvneshvarma7843
@bhuvneshvarma7843 3 роки тому
Very good quality code!👏👏👏
@azamatmahkamov263
@azamatmahkamov263 3 роки тому
Nice tutorial, very neat. I have one question though, if MVI has State mapper in viewModel, does it mean, we can build very large one viewmodel for the whole application?
@ryujin5400
@ryujin5400 3 роки тому
Thanks , This is Awesome
@ChrisAthanas
@ChrisAthanas 3 роки тому
Gettin close to 100k!!!
@muhammadhumzakhan9888
@muhammadhumzakhan9888 3 роки тому
Hats off to you 🤝
@alexandretrew3737
@alexandretrew3737 3 роки тому
F***ing great!, super helpful !
@vahidhoseini1723
@vahidhoseini1723 3 роки тому
great, good job mitch.
@MariusDuna
@MariusDuna 2 роки тому
Regarding with creating models, you can find JSON to KT data class Android Studio extension. You just paste there the JSON and data classes are created for you automatically
@gunjotsingh3638
@gunjotsingh3638 2 роки тому
Huge Help !! 🙌🏻
@charlien759
@charlien759 3 роки тому
Good video, however with new projects Gson isn't the ideal choice, Jake Wharton says to use kotlinx.serialization, Moshi or Jackson. Moshi is basically Gson V3 in all but name.
@edwin846
@edwin846 3 роки тому
Nice video! Keep it up! One question that I have is what is the reason of using dependency injection when Kotlin object can be called from anywhere of the code. For example, the Retrofit module you created in the video can be called directly in the MainRepository class without any DI dependencies. Thanks
@gillesjack9619
@gillesjack9619 3 роки тому
Thanks Mitch. That was great. Do you have the same kind of video with a Room database containing 2 tables joined by a SQL inner join (external key in one of the table). If not, take it as a suggestion because all tutorials I have seen so far only use single SQL table example. I wonder how to use SQL INNER JOIN query in room and integrate it in a MVVM project.
@pgaurav72
@pgaurav72 3 роки тому
Hilt is awsome!
@mahmoudramadan8407
@mahmoudramadan8407 3 роки тому
I love it , well done
@applombaa6278
@applombaa6278 2 роки тому
This is something amazing
@M-MZ
@M-MZ 3 роки тому
Great stuff! Thanks
@wah_yar_tiwari
@wah_yar_tiwari 2 роки тому
Thank you💯
@benjaminmorales9276
@benjaminmorales9276 3 роки тому
Hi Mitch, I really appreciate this session, you explained a lot of concepts in an incredible way. Thanks for that!. I would like to ask you if could you create or design a Base Use Case with this approach. I think use Flow makes the things more efficient but, I tried and I could't create a Base Use Case. Could you please show us a way?
@Serg13975
@Serg13975 3 роки тому
Great Tutorial. What should I do if I need to pass a blog as an argument to the viewmodel in case I want to insert it . How can I incorporate it to the MainStateEvent?
@hnim2292
@hnim2292 3 роки тому
Hi Mitch, thanks for this example. I have a question, why class DataState and not DataState, what the "out" does?
@codingwithmitch
@codingwithmitch 3 роки тому
kotlinlang.org/docs/reference/generics.html
@akthamahmed2171
@akthamahmed2171 2 роки тому
Awsome 👌 thanks you 🧡
@lional4898
@lional4898 3 роки тому
Great Job!
@LetrixAR
@LetrixAR 3 роки тому
This was really useful, thanks. P.S: Add chapters to the video please!
@antoniokomangyudistira4150
@antoniokomangyudistira4150 3 роки тому
Thank you
@shwetankbhardwaj3190
@shwetankbhardwaj3190 3 роки тому
Can you please explain more about Entity mapper. Like, how to map an entity to a global model if we have multiple hierarchies of objects
@bjugdbjk
@bjugdbjk 3 роки тому
Think in a way like moving data from one class to another class, with the same fields available.
@aliakkawi4759
@aliakkawi4759 3 роки тому
Hello Mitch and thanks for the tutorial. In the RetrofitModule we hard coded the BaseUrl, is it possible to make the BaseUrl dynamic? do we need to create a new RetrofitModule if we have requests with a different BaseUrl? Thanks.
@codingwithmitch
@codingwithmitch 3 роки тому
Ya with retrofit you must
@aliakkawi4759
@aliakkawi4759 3 роки тому
@@codingwithmitch Thanks a lot!
@federicocreti4699
@federicocreti4699 3 роки тому
Hello Man, I have a question. I never used before MVI pattern. I want to ask: I have a login screen (a fragment) which uses OAuth2 authentication. I used a viewmodel behind this fragment. I created a sealed state class in the ViewModel, in order to manage the state between the fragment and viewmodel. Is correct set the state both from viewmodel and fragment? I mean, there are some states which are managed from the fragment, so I have to set the state from the fragment, and other states which has to be managed from the viewmodel (and through livedate I update/inform the fragment). Is this approach correct? Or the states should be set just from Fragment? Then I have some states for example: data class ValidLoginStateEvent(val sessionClient: SessionClient) : LoginStateEvent() data class NavigateToUserListEvent(val sessionClient: SessionClient) : LoginStateEvent() ValidLoginStateEvent is set by Fragment. In the ViewModel I have this: when (loginStateEvent) { . . is LoginStateEvent.ValidLoginStateEvent -> { bytenerRepository.setSessionClient(loginStateEvent.sessionClient) setLoginStateEvent(LoginStateEvent.NavigateToUserListEvent(loginStateEvent.sessionClient)) } is LoginStateEvent.NavigateToUserListEvent -> { _state.value = loginStateEvent } . . } Is this approach correct?
@arcticmax20
@arcticmax20 3 роки тому
Thank you :D
@GabrielNovakovskiNunes
@GabrielNovakovskiNunes 2 роки тому
Awesome!
@arindomghosh3144
@arindomghosh3144 3 роки тому
It is supper awesome
@AhsanAli-vz6mg
@AhsanAli-vz6mg 3 роки тому
Superb
@bradyaiello6830
@bradyaiello6830 3 роки тому
Only "pk" needs the @SerializedName, because it's the only field whose name differs from the JSON response. You also don't need @ColumnInfo unless the field name differs from the column name in your table.
@codingwithmitch
@codingwithmitch 3 роки тому
Just habit
@AnasTariqKhan
@AnasTariqKhan 3 роки тому
Hey Mitch, first of all, a very helpful tutorial, Just a question, what's the use of caching here? because if the network API fails then we're not retrieving from cache?
@codingwithmitch
@codingwithmitch 3 роки тому
Just a simple example. Obviously there should be more detailed error handling
@ankitdubey9560
@ankitdubey9560 3 роки тому
Should we observe to database directly in viewmodel, and also call the API. Atleast everytime the loader will not be displayed if data is already in db. However caching functionality is not clear to me.
@ismailkassim6325
@ismailkassim6325 3 роки тому
Can you do a video on safe args with fragment.
@niazsagor
@niazsagor 2 роки тому
awesome
@DartLuke
@DartLuke 2 роки тому
25:44 ApplicationComponent was renamed to SingletonComponent
@rajnikantpandey709
@rajnikantpandey709 3 роки тому
Hi , at 44:47 min , you said that "i'm not adding @Inject at the constructor of MainRepository , i will provide this in module" but why cann't you do there only by putting the @Inject annotation , why do we need to create a seprate module for that and while i'm trying to put @Inject annotation in constructor itself , its throwing me error.
@jobz7270
@jobz7270 3 роки тому
This excellent, Could you please provide video of Hilt Wth SharedPreference
@myyoutubeorel
@myyoutubeorel 3 роки тому
Been waiting for an MVI video! Thanks alot:) Quick question Is it legit to use firebase as my backend for an app that will have quite a big user base? I read many different opinions, and I am not sure.. Thanks in advance:)
@codingwithmitch
@codingwithmitch 3 роки тому
Sure why not
@veejaygrateja6988
@veejaygrateja6988 2 роки тому
54:02 How did you get a reference from text (TextView)?
@alexandresantos8232
@alexandresantos8232 3 роки тому
I have a question, how do we do this if you're using more complex data classes, for example imagin if "Blog" had another class inside, how would we deal with the data relations?
@techno-trickster636
@techno-trickster636 3 роки тому
) how hilt know what retrofit instance to provide when we have more than 1 retrofit builder with different base URL
@minaisaac507
@minaisaac507 3 роки тому
thanks alot for your sincere effort, ...but I have a question : why do you provide MainRepository through Module while you own it's class so you can easily provide it through constructor injection...shouldn't we use constructor injection whenever possible?
@codingwithmitch
@codingwithmitch 3 роки тому
Ya you could have. I don't know that it matters which you use.
@satnamsingh-qh2si
@satnamsingh-qh2si 2 роки тому
🙌🏻
MVVM vs. MVI - Understand the Difference Once and for All
18:40
Philipp Lackner
Переглядів 18 тис.
Все про Dagger Hilt в Android Studio + Kotlin
52:11
Neco Ru
Переглядів 9 тис.
Повістки у Києві: «Яке право вони мають забирати всіх мужиків?» #війна #мобілізація #військові
00:41
Слідство.Інфо | Розслідування, репортажі, викриття
Переглядів 455 тис.
Repository Pattern
11:08
Coding Concepts
Переглядів 65 тис.
ViewModels & Configuration Changes - Android Basics 2023
18:46
Philipp Lackner
Переглядів 89 тис.
The Ultimate guide to MVI in Android
29:52
Land of coding
Переглядів 7 тис.
Hilt Dependency Injection (Kotlin Beginner Example)
21:20
CodingWithMitch
Переглядів 41 тис.
Make Your Code Clean With the SOLID Principles
18:24
Philipp Lackner
Переглядів 92 тис.
Нужен ли робот пылесос?
0:54
Катя и Лайфхаки
Переглядів 642 тис.
Самая редкая видеокарта от SONY
13:51
Nitroxsenys
Переглядів 52 тис.
Как открыть дверь в Jaecoo J8? Удобно?🤔😊
0:27
Суворкин Сергей
Переглядів 596 тис.
Which Phone Unlock Code Will You Choose? 🤔️
0:12
Game9bit
Переглядів 2,8 млн