如何在 Dagger 2.16 中为工人类实现 Dagger?
public class SyncWorker extends Worker {
@Inject
ISettingRepository settingRepository;
@NonNull
@Override
public Result doWork() {
sync();
return Result.SUCCESS;
}
private void sync() {
}
}
我的应用组件
@Singleton
@Component(modules = {
AndroidSupportInjectionModule.class,
BaseModule.class,
ApiModule.class,
UserDatabaseModule.class,
SaleDatabaseModule.class,
AppModule.class,
ActivityBuilderModule.class
})
public interface AppComponent extends AndroidInjector<DaggerApplication> {
void inject(BaseApp app);
@Override
void inject(DaggerApplication application);
@Component.Builder
interface Builder {
@BindsInstance
Builder getApp(Application application);
AppComponent build();
}
}
如何注入settingRepository?