I'm new to hilt and dagger and I don't know if what I'm doing is wrong or if its not working for a different reason so please bear with me.
I want to inject a class that depends on another class into a view holder class.
The view holder extends BaseViewHolder, the class I want to inject into it is an image helper class which depends on glide.
I have a module that provides glide
@Module
@InstallIn(ApplicationComponent.class)
public class GlideModule {
@Provides
public static RequestManager provideGlideRequestManager(@ApplicationContext Context context) {
return Glide.with(context);
}
}
This module is used else where in my app so I know it works.
I've annotated the image helpers constructor with @Inject and I'm trying to field inject glide into this class like this
@Inject
public RequestManager glide;
@Inject
public ImageHelper() {
}
and then in my view holder I've annotated the image helper with @Inject
@Inject
public ImageHelper imageHelper;
public SentenceViewHolder(View view, ItemTouchListener onItemTouchListener, OnStartDragListener mDragStartListener) {
super(view);
this.v = view;
findViewIds(onItemTouchListener, mDragStartListener);
}
inside my findViewIds method I try to access the image helper but its null,
So I tried building a module for it with no joy
@Module
@InstallIn(ActivityComponent.class)
public class ImageHelperModule {
@Singleton
@Provides
public ImageHelper provideImageHelper() {
return new ImageHelper();
}
}
any help is appreciated