MVVM / MVI Repository Pattern with Hilt

  Рет қаралды 67,631

CodingWithMitch

CodingWithMitch

Күн бұрын

The best android courses in the world: codingwithmitc...
Watch the HILT course here (FREE): codingwithmitc...
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/mit...
Instagram: / codingwithmitch
Twitter: / mitch_tabian
.
.
#AndroidDev

Пікірлер: 180
@TheAnilmaddala
@TheAnilmaddala 4 жыл бұрын
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 2 жыл бұрын
Thanks
@sheenfabile9460
@sheenfabile9460 4 жыл бұрын
This is what im looking for! MVI using flow. Will get membership to support your tutorial. Thank you!
@aabhishek4911
@aabhishek4911 4 жыл бұрын
Bye bye viewmodelproviderfactory or whatever was your name
@abrahammathew8658
@abrahammathew8658 3 жыл бұрын
ApplicationComponent is GONE Now everyone can use SingletonComponent
@shwetankbhardwaj3190
@shwetankbhardwaj3190 4 жыл бұрын
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.
@johnnyshoesofthetwo7374
@johnnyshoesofthetwo7374 3 жыл бұрын
why do you launch inside viewModelScope twice? no explanation?
@charlien759
@charlien759 4 жыл бұрын
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.
@DartLuke
@DartLuke 3 жыл бұрын
25:44 ApplicationComponent was renamed to SingletonComponent
@bradyaiello6830
@bradyaiello6830 4 жыл бұрын
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 4 жыл бұрын
Just habit
@mytubekt
@mytubekt 3 жыл бұрын
Very helpful video. Thanks!
@superjkmax88
@superjkmax88 4 жыл бұрын
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!
@jamilxt
@jamilxt 4 жыл бұрын
That's what I was looking for. Thank you. ^_^
@alitonoliveira1700
@alitonoliveira1700 4 жыл бұрын
Awesome and fast like a bullet :)
@wisnusuryawardhana7891
@wisnusuryawardhana7891 4 жыл бұрын
THANKS MITCH!!!
@lbars
@lbars 3 жыл бұрын
Yes, exactly what I needed. All architecture concepts at the same video. Thank you CodingWithMitch ❤
@dahlola
@dahlola 4 жыл бұрын
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.
@edvardgrei1257
@edvardgrei1257 4 жыл бұрын
Thank you Mitch. It really opened my eyes. Going to take your paid course for sure. Good Job
@maksonic_official
@maksonic_official 4 жыл бұрын
powerful work! Thanks so much for this video, I will definitely go to your site to see the lessons!
@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))
3 жыл бұрын
@@bro_chenzox do you still carry that air-compressed gun around?
@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
@isaacsufyan
@isaacsufyan 3 жыл бұрын
Why you are using the Blog model you can also use BlogNetworkEntity data class, because both are models and the same variable. We can also get value from BlogNetworkData Model class, why you create separate blog model, Network Wrapper, think its increasing complexity
@kagankuscu
@kagankuscu 3 жыл бұрын
Hello Everyone, I have a question if anyone knows it, please share with me. Normally ViewModel when takes an argument it needs ViewModel.Factory but I could not see in this app. Question is When we use DI don't we need to use ViewModel.Factory?
@jackli1924
@jackli1924 Жыл бұрын
Thank you Mitch,a wonderful video! Your tech is so excellent and your explaination is so consice and awesome!
@msontrent9936
@msontrent9936 4 ай бұрын
Really good tutorial. Far more useful than learning it in a classroom. Thanks for taking the time.
@minaisaac4529
@minaisaac4529 3 жыл бұрын
that's great...but you are always talking about "suspend" function as if it is responsible for the asynchronous work ...but actually -or what I think - it is only about Stop/Resume actions...also there is no point in using @ColumnInfo in room while the properties are the same letters of the column name besides why do you provide the main repo through a module while you can do this simply through constructor injection?
@BradleyEdwardAnderso
@BradleyEdwardAnderso 3 жыл бұрын
@6:24 you say build.gradle "project" file, but I had to use the "module" build.gradle file.
@christopherelias8022
@christopherelias8022 3 жыл бұрын
Hello, I'm not so sure if this is MVI. It is probably is a very simplified version of It, but I don't know if I could call this MVI. There are no intent to actions, action to result processor, reducers, or even a good definition of the state model. If you use a sealed class for your state model representation, what happens when you resume your activity after an error? or return to a fragment after being saved on the stack. But on the other hand, you are very clear with the things you explain. For those who wan't to know what am I talking about check out this MVI talk: kzbin.info/www/bejne/homliZZ-hsp3gqc "Not everything that shines is gold" -
@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
@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.
@appsdeveloper4024
@appsdeveloper4024 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!
@foivosstamopoulos9709
@foivosstamopoulos9709 3 жыл бұрын
PERFECT tutorial! So much knowledge combined. Thank you once again
@erinwolf1563
@erinwolf1563 2 жыл бұрын
Mitch why didnt u just annotate the constructor of the Repository with @inject.. why did u provide it in a Module ?
@arulwastaken
@arulwastaken 4 жыл бұрын
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.
@marzaise
@marzaise 3 жыл бұрын
Nice explanation!! but the way you put empty lines in the very bottom of your code gives me OCD 😂
@amateur_gamer101
@amateur_gamer101 2 жыл бұрын
I could literally kiss you for this tutorial 😭😭 its so easy to understand. You just got a new follower.
@vishwaraghavendra8332
@vishwaraghavendra8332 4 жыл бұрын
Omg!! Finally.. Was waiting for this tutorial
@codingwithsam4992
@codingwithsam4992 2 жыл бұрын
Everything successfully went over my head😅
@bahaaka828
@bahaaka828 4 жыл бұрын
i really liked it. make more of these kind of videos 1 hour contains the summary of 8 hours course
@piyush288
@piyush288 Жыл бұрын
in this approach, what if internet connection is off and we run this application.???
@cdmunoz
@cdmunoz 4 жыл бұрын
Awesome job! Thanks for sharing it with all the community
@ozgurtas4508
@ozgurtas4508 4 жыл бұрын
thanks mitch, very good tutorial
@AnasTariqKhan
@AnasTariqKhan 4 жыл бұрын
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 4 жыл бұрын
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.
@MariusDuna
@MariusDuna 2 жыл бұрын
ApplicationComponent is deprecated - > SingletonComponent
@aravind_us
@aravind_us 2 жыл бұрын
No words to say....it's awesome tutorial....😍😍😍
@olufemiezekiel7105
@olufemiezekiel7105 2 жыл бұрын
Just to add, the ApplicationComponent has been deprecated/changed to SingletonComponent. So instead of @InstallIn(ApplicationComponent::class) use @InstallIn(SingletonComponent::class) Nice work @CodingWithMitch
@veejaygrateja6988
@veejaygrateja6988 2 жыл бұрын
54:02 How did you get a reference from text (TextView)?
@codingwithsam4992
@codingwithsam4992 2 жыл бұрын
Please correct the sorting of video in the playlist
@malpv
@malpv 2 жыл бұрын
Nice tutorial! Thanks! Saludos desde Chile!
@achmadrizkinurfauzie8466
@achmadrizkinurfauzie8466 Жыл бұрын
is this data saved and show in emulator/device when no connection ?
@Irshu
@Irshu 3 жыл бұрын
thanks Mitch, finally a terrific tutorial!
@myyoutubeorel
@myyoutubeorel 4 жыл бұрын
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 4 жыл бұрын
Sure why not
@tasc4404
@tasc4404 2 жыл бұрын
Yea it is a nice tutorial, but caching is not working :(
@alexandretrew3737
@alexandretrew3737 4 жыл бұрын
F***ing great!, super helpful !
@gamesforu6619
@gamesforu6619 3 жыл бұрын
Is a data class in MVI architecture patten?
@satnamsingh-qh2si
@satnamsingh-qh2si 3 жыл бұрын
why there is mapper and all stuf?
@pejmanazad5852
@pejmanazad5852 4 жыл бұрын
My brain is burning. 🔥
@Firespirit233
@Firespirit233 3 жыл бұрын
why? this is quite easy, and mitch is explaining it very well and simple
@gamesforu6619
@gamesforu6619 3 жыл бұрын
What do you mean of MVI pattern?
@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 😂
@polarisnation201
@polarisnation201 3 жыл бұрын
This video is what i need. Thanks you
@RiccardoGabellone
@RiccardoGabellone 2 жыл бұрын
Hi sir! Great job 💪🏻 Could I ask you a tutorial on how to pre-populate a Room db using Hilt, by using callback which write local json data inside db? I am having more than one issue on it 😅 thanks in advance!!
@rsajdok
@rsajdok 4 жыл бұрын
Maybe someone explain me. Why MainViewModel.kt was not created as module by "ActivityRetainedComponent" ?
@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?
@nitinnegi9343
@nitinnegi9343 4 жыл бұрын
Awesome.. "YOU NAILED IT"
@u2gilles
@u2gilles 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.
@nrsingh7203
@nrsingh7203 4 жыл бұрын
wooooh!! Hats off to you man[Amazing explanation of android components]... I wish I can hit more likes...
@girishak9404
@girishak9404 4 жыл бұрын
Wow that's fantastic video. Thanks Mike.
@codingwithmitch
@codingwithmitch 4 жыл бұрын
*Mitch*
@girishak9404
@girishak9404 4 жыл бұрын
CodingWithMitch Yes Mitch 😂
@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?
@ofirkosto
@ofirkosto 2 жыл бұрын
Awesome video !! Thank you Mitch you are doing a great work you should be proud of yourself!
@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. :)
@blattwald7650
@blattwald7650 3 жыл бұрын
Wow, the first time I really appreciate that youtube has a playspeed configuration - Speeding up the playspeed to x1.5 - you're way too slow.
@akthamahmed2171
@akthamahmed2171 3 жыл бұрын
Awsome 👌 thanks you 🧡
@adamgardner1986
@adamgardner1986 3 жыл бұрын
Awesome video and thank you. Very helpful. Now to figure out how to test that ViewModel and Flow.
@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
@lazaroyesid
@lazaroyesid 3 жыл бұрын
Thanks!! well explained !
@edwin846
@edwin846 4 жыл бұрын
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
@datanautastv3188
@datanautastv3188 4 жыл бұрын
I actually fucking love you
@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?
@azamatmahkamov263
@azamatmahkamov263 4 жыл бұрын
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?
@suren6413
@suren6413 3 жыл бұрын
Am an average developer only. But I have learned a lot by your tutorials. Thanks you a lot Mitch
@jobz7270
@jobz7270 4 жыл бұрын
This excellent, Could you please provide video of Hilt Wth SharedPreference
@SerarEstaifan
@SerarEstaifan 4 жыл бұрын
The best ever! Thank you sir 🙏🏻
@applombaa6278
@applombaa6278 3 жыл бұрын
This is something amazing
@tmpname2838
@tmpname2838 3 жыл бұрын
Great tutorial I learned a ton, though this tutorial did feel like a speed run. youre going way too fast from one thing to the next, by the time I realize Im falling a bit behind in my coding youre already on a new class and I need to rewind a bit to catch up
@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
@starlite5097
@starlite5097 3 жыл бұрын
Can you please explain at 49:57 what the .onEach and .launchIn do exactly? Thanks.
@benjaminmorales9276
@benjaminmorales9276 4 жыл бұрын
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?
@bryanneuberger5886
@bryanneuberger5886 3 жыл бұрын
engage
@codingwithmitch
@codingwithmitch 3 жыл бұрын
what a great engagement
@matt-g-recovers
@matt-g-recovers 3 жыл бұрын
I enjoyed this implementation example. Thanks Mitch
@pgaurav72
@pgaurav72 4 жыл бұрын
Hilt is awsome!
@muhammadsalman4389
@muhammadsalman4389 4 жыл бұрын
Thanks for MVI ❤️
@LetrixAR
@LetrixAR 3 жыл бұрын
This was really useful, thanks. P.S: Add chapters to the video please!
@arindomghosh3144
@arindomghosh3144 3 жыл бұрын
It is supper awesome
@lovemashup7975
@lovemashup7975 3 жыл бұрын
It is definitely the most useful demo I have ever seen. Thanks Mitch for your contribution, it helps a lot :)
@jaloliddinabdullaev2310
@jaloliddinabdullaev2310 Жыл бұрын
Best tutorial for MVI on youtube, thanks
@codingwithmitch
@codingwithmitch Жыл бұрын
Ya man no worries
@antoniokomangyudistira4150
@antoniokomangyudistira4150 4 жыл бұрын
Thank you
@vrajeshhirani
@vrajeshhirani 4 жыл бұрын
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.
@gunjotsingh3638
@gunjotsingh3638 2 жыл бұрын
Huge Help !! 🙌🏻
@muhammadhumzakhan9888
@muhammadhumzakhan9888 3 жыл бұрын
Hats off to you 🤝
@SpaceTimeBeing_
@SpaceTimeBeing_ 4 жыл бұрын
Perfect tutorial!
@xxluciferinxx
@xxluciferinxx 4 жыл бұрын
thanks for this amazing video! leared a lot from this video.
Hilt Dependency Injection (Kotlin Beginner Example)
21:20
CodingWithMitch
Рет қаралды 42 М.
6 Design Patterns Every Android Developer Must Know
14:16
Philipp Lackner
Рет қаралды 81 М.
哈莉奎因怎么变骷髅了#小丑 #shorts
00:19
好人小丑
Рет қаралды 54 МЛН
哈哈大家为了进去也是想尽办法!#火影忍者 #佐助 #家庭
00:33
РОДИТЕЛИ НА ШКОЛЬНОМ ПРАЗДНИКЕ
01:00
SIDELNIKOVVV
Рет қаралды 1,8 МЛН
Help Me Celebrate! 😍🙏
00:35
Alan Chikin Chow
Рет қаралды 51 МЛН
Model View View-Model (MVVM): Getting Started
29:12
CodingWithMitch
Рет қаралды 398 М.
Make Your Code Clean With the SOLID Principles
18:24
Philipp Lackner
Рет қаралды 99 М.
Advice from a Principal Software Engineer at Amazon (Steve Huynh)
22:45
DO NOT do this in a Software Engineering Interview
7:59
CodingWithMitch
Рет қаралды 9 М.
Kotlin Singleton Example with MVVM and Coroutines
36:24
CodingWithMitch
Рет қаралды 56 М.
Dagger-Hilt in Detail - Full Course
25:42
Philipp Lackner
Рет қаралды 82 М.
Hilt - Android Dependency Injection
28:57
Android Developers
Рет қаралды 51 М.
Getting Started with HILT (Dagger2)
10:10
CodingWithMitch
Рет қаралды 44 М.
哈莉奎因怎么变骷髅了#小丑 #shorts
00:19
好人小丑
Рет қаралды 54 МЛН