Fragment Constructor Injection with Hilt and Navigation Component

  Рет қаралды 16,464

CodingWithMitch

CodingWithMitch

4 жыл бұрын

The best android courses in the world: codingwithmitch.com/
Watch the HILT course here (FREE): codingwithmitch.com/courses/h...
How to do constructor injection with fragments using the new dependency injection framework built on top of Dagger2, Hilt.
I'll be using Hilt, FragmentContainerView, FragmentFactory, and Navigation Component.
Code: github.com/mitchtabian/Dagger...
Instagram: / codingwithmitch
Twitter: / mitch_tabian
.
.
#AndroidDev

Пікірлер: 72
@skaterope
@skaterope 3 жыл бұрын
Maybe the best content on youtube for Android Dev.
@akashkumardas6521
@akashkumardas6521 3 жыл бұрын
I found 3 best KZbin channel for android developers, No.1 coding with Mitch No.2 Android devs No.3 coding with flow And reso coder is deprecated
@ChrisAthanas
@ChrisAthanas 3 жыл бұрын
Philip Lackner is also quite good
@islamicinsightbysaifi
@islamicinsightbysaifi 3 жыл бұрын
4. Phillip Lackner is also very good. He always tells Advance concept of Android.
@IdaBagusTrisnaWidia
@IdaBagusTrisnaWidia 3 жыл бұрын
reso coder now focus more on flutter
@mattgraves3709
@mattgraves3709 3 жыл бұрын
@@ChrisAthanas He is Android devs changed the name. Phillip Lackner is my new favorite. Especially with that testing playlist man that is mandatory for professional work and nobody teaches it
@f4bioo
@f4bioo 2 жыл бұрын
Thank you so much Mitch, this custom Main NavHostFragment trick saved my day
@fimfomfum123
@fimfomfum123 2 жыл бұрын
Dude you literally saved me, thank you so much! Keep up with the great work
@DanielGibby
@DanielGibby 3 жыл бұрын
Very helpful again. Thanks Mitch!
@carloscontreras-kh5ct
@carloscontreras-kh5ct 4 жыл бұрын
Estaba esperando el tutorial. 👍
@iftak01
@iftak01 2 жыл бұрын
Great Series again my Canadian guy!!
@otoS97
@otoS97 2 жыл бұрын
Thank you so much my man.. This video literally got my back today.
@jaserq
@jaserq 3 жыл бұрын
You are really a good teacher with a talent
@laszloforgacs8210
@laszloforgacs8210 4 жыл бұрын
nice tutorial, comprehensible and concise explanation
@michakozak1767
@michakozak1767 3 жыл бұрын
Thanks a lot ! Great explanation
@sacchimehnat
@sacchimehnat 2 жыл бұрын
Good video. Well demonstration.
@nicoqueijo
@nicoqueijo 3 жыл бұрын
Btw you can do CTRL + ALT + L to format your code and CRTL + ALT + O to optimize imports (remove all unused imports)
@mohammadbahadori8269
@mohammadbahadori8269 2 жыл бұрын
Good job. You explained too good
@buzzminkyunghoon3856
@buzzminkyunghoon3856 4 жыл бұрын
Deja vu
@singhkamalpreet11
@singhkamalpreet11 3 жыл бұрын
Just incredible...
@blues1337
@blues1337 3 жыл бұрын
Well, wish I had realized you had a video about exactly this 8 hours ago.
@fahrican9708
@fahrican9708 3 жыл бұрын
yes, this video was good!
@bloodops3893
@bloodops3893 3 жыл бұрын
This is very interesting video :)
@vahidgarousii
@vahidgarousii 4 жыл бұрын
Thank you sir👍
@akashdeepwadhwa5828
@akashdeepwadhwa5828 3 жыл бұрын
thank you very much this one helped me on project and solved my one of annoying issues i was having constructor injection with fragments... had no idea it does not work out of the box to support constructor injection in fragments... i have basics of mvvm coroutines .. and can you help me which paid project i learn from you ..atleast i get the confidence
@m0tivati0n71
@m0tivati0n71 4 жыл бұрын
Lovely
@sourabhpal4717
@sourabhpal4717 3 жыл бұрын
Nice one. Can we use constructor injection to inject viewmodel in the same fragment?
@Murad3223
@Murad3223 3 жыл бұрын
wait, where are the videos about the rest of the app, where you build room repo and retrofit?
@DerCheckerzeigts
@DerCheckerzeigts 3 жыл бұрын
How to do this with bottom navigation?
@kravgenko2
@kravgenko2 3 жыл бұрын
Hello, how I can transfer the realization of interface class into hilt in my ViewModel. I can't use @Binds, because after creating ViewModel I should fulfil some method to calculate the required realization of this interface.
@abhisheksaxena518
@abhisheksaxena518 3 жыл бұрын
After going through some stackoverflow answers and issue trackers, if you have to setup actionbar with navcontroller then FragmentContainerView will not be able to find the associated NavController. In order to resolve this issue, simply replace it with and find the controller traditionally like navController = findNavController(R.id.default_navHost_fragment) Bug Report: issuetracker.google.com/issues/142847973
@RooshiPatidar
@RooshiPatidar 3 жыл бұрын
I love you this is amazing
@paulaalejandradiazsilva2333
@paulaalejandradiazsilva2333 4 жыл бұрын
Do you have any video of deploying Django to Elastic beanstalk? I know my question has nothing to do with this video, but I haven't found a good tutorial...
@moustafaessam1463
@moustafaessam1463 4 жыл бұрын
What if we inject the factory into a method then set the fragment factory inside it? @Inject fun setFactory(factory: CustomFactory) { supportFragmentManager.fragmentFactory = factory } Since the injection is done before the call to super.onCreate() Please correct me if I’m wrong
@harshar6897
@harshar6897 3 жыл бұрын
Is it possible to constructor inject view model like this?
@SpaceTimeBeing_
@SpaceTimeBeing_ 3 жыл бұрын
How to use viewBinding with such a fragment? Since it directly takes in the layout
@devanshu_on_youtube
@devanshu_on_youtube 3 жыл бұрын
I suggest creating an abstract base class for a view-binding fragment that uses the usual Fragment() empty constructor and inflate the view using DataBindingUtil in the onCreateView method. You can still provide the layout as a dependency in the constructor of this base class, and have full control over whether you choose to use the helpful Fragment constructor with the layooutId or use DataBindingUtil instead. Hope that helps :)
@JohnDoe-wx3zm
@JohnDoe-wx3zm 2 жыл бұрын
Mitch, is constructor injection that big of a deal? The whole FragmentFactory thing seems like a lot of boilerplate, especially when you can just field inject (I know filed injection is supposed to be bad, but does the FragmentFactory have any tangible upsides?)
@gagandeepsinghwalia4462
@gagandeepsinghwalia4462 3 жыл бұрын
According to 9:48 one factory will handle all fragments or one factory for each fragment
@LogicPhalanx
@LogicPhalanx 3 жыл бұрын
How is the injection working in your NavHostFragment if you're using the value in onAttach? onAttach comes before onCreate in the lifecycle of the Fragment. When does Hilt do injection in the Fragment lifecycle?
@codingwithmitch
@codingwithmitch 3 жыл бұрын
In on attach for fragments. Same as with dagger.
@AbdulRehman-em7rq
@AbdulRehman-em7rq Жыл бұрын
cannot be provided without an @Provides-annotated method. public abstract static class SingletonC implements VroomVroomApp_GeneratedInjector, Hi, I am facing this error in my project. Can you answer this error?
@prabhattiwari3254
@prabhattiwari3254 4 ай бұрын
why you are using fragment factory here?
@mohitbalani7956
@mohitbalani7956 4 жыл бұрын
I have not learnt dagger 2 can i directly use hilt ?
@codingwithmitch
@codingwithmitch 4 жыл бұрын
yes
@mohitbalani7956
@mohitbalani7956 4 жыл бұрын
@@codingwithmitch thanks
@mehranj73
@mehranj73 3 жыл бұрын
But it doesn't work with BottomNavController
@PeteStMartin
@PeteStMartin 2 жыл бұрын
Is there a difference between ApplicationComponent::class and SingletonComponent::class?
@vasiliychernov2123
@vasiliychernov2123 Жыл бұрын
They're the same thing, ApplicationComponent just got renamed to SingletonComponent.
@carloscontreras-kh5ct
@carloscontreras-kh5ct 4 жыл бұрын
apparently is not working login service with date 16/07/2020 05:53 pm, i am watching "powerful android apps..." course and i cannot login
@codingwithmitch
@codingwithmitch 4 жыл бұрын
email me
@DerCheckerzeigts
@DerCheckerzeigts 3 жыл бұрын
So every fragment needs it own fragmentfactory? So if I have 18 Fragments, I also need 18 fragmentfactories?
@trampflips101
@trampflips101 3 жыл бұрын
One fragment factory can be a factory for multiple different fragments, so no
@DerCheckerzeigts
@DerCheckerzeigts 3 жыл бұрын
@@trampflips101 But can I have multiple Fragmen factories?
@trampflips101
@trampflips101 3 жыл бұрын
@@DerCheckerzeigts of course :)
@DerCheckerzeigts
@DerCheckerzeigts 3 жыл бұрын
@@trampflips101 But how? I've tried using "childFragmentmanager.fragmentfactory" multiple times but that didn't work. Please tell me how to assign multiple fragmentfactories to one navhostfragment aka childFragmentmanager
@trampflips101
@trampflips101 3 жыл бұрын
@@DerCheckerzeigts oh i'm not sure about that, I thought you were asking whether you can have separate factories for separate fragments.
@oscarperry641
@oscarperry641 4 жыл бұрын
HOT
@ChrisAthanas
@ChrisAthanas 3 жыл бұрын
Engaged to 100k
@astrologykhan8125
@astrologykhan8125 3 жыл бұрын
What news say about him ???
@hashemmousavi2451
@hashemmousavi2451 2 жыл бұрын
Having Fragment with non default constructor that contains parameters is totally wrong. Because when the Activity killed by system and after coming back to the app, system can't recreate the fragment
@vasiliychernov2123
@vasiliychernov2123 Жыл бұрын
That's the reason they introduced FragmentFactory, you provide your own factory which knows how to create your Fragment with non-default constructor.
@technicalvenky8778
@technicalvenky8778 4 жыл бұрын
1st view...
@bryanneuberger5886
@bryanneuberger5886 3 жыл бұрын
engagement
@codingwithmitch
@codingwithmitch 3 жыл бұрын
nice engagement
@help-ever
@help-ever 4 жыл бұрын
Hello.
@VivekSharma-qw5ky
@VivekSharma-qw5ky 4 жыл бұрын
Thank you sir 👍
Hilt makes testing easier on Android
32:38
CodingWithMitch
Рет қаралды 16 М.
Hilt Modules, Binds and Provides (Dagger2)
18:02
CodingWithMitch
Рет қаралды 21 М.
Haha😂 Power💪 #trending #funny #viral #shorts
00:18
Reaction Station TV
Рет қаралды 15 МЛН
Каха ограбил банк
01:00
К-Media
Рет қаралды 10 МЛН
NERF WAR HEAVY: Drone Battle!
00:30
MacDannyGun
Рет қаралды 33 МЛН
Advice from a Principal Software Engineer at Amazon (Steve Huynh)
22:45
Hilt ViewModels and Dependency Injection
16:35
CodingWithMitch
Рет қаралды 30 М.
5 Fatal Coroutine Mistakes Nobody Tells You About
18:15
Philipp Lackner
Рет қаралды 85 М.
Scoping with HILT (Dagger2)
9:39
CodingWithMitch
Рет қаралды 17 М.
LiveData with Coroutines and Flow (Android Dev Summit '19)
18:44
Android Developers
Рет қаралды 110 М.
Don't throw exceptions in C#. Do this instead
18:13
Nick Chapsas
Рет қаралды 251 М.
MVVM  / MVI Repository Pattern with Hilt
1:00:24
CodingWithMitch
Рет қаралды 67 М.
Hilt - Android Dependency Injection
28:57
Android Developers
Рет қаралды 51 М.
iPhone 16 с инновационным аккумулятором
0:45
ÉЖИ АКСЁНОВ
Рет қаралды 906 М.
iPhone 12 socket cleaning #fixit
0:30
Tamar DB (mt)
Рет қаралды 56 МЛН
Хотела заскамить на Айфон!😱📱(@gertieinar)
0:21
Взрывная История
Рет қаралды 4,7 МЛН
ПОКУПКА ТЕЛЕФОНА С АВИТО?🤭
1:00
Корнеич
Рет қаралды 3,4 МЛН