dagger

fragmentDispatchingAndroidInjector while using support fragments

血红的双手。 提交于 2019-12-01 18:23:56
I'm trying to create a simple dagger 2 application while using support v4 fragments. After I modified my application I got this strange compilation error Error:(35, 8) error: [dagger.android.AndroidInjector.inject(T)] java.util.Map<java.lang.Class<? extends android.support.v4.app.Fragment>,javax.inject.Provider<dagger.android.AndroidInjector.Factory<? extends android.support.v4.app.Fragment>>> cannot be provided without an @Provides-annotated method. java.util.Map<java.lang.Class<? extends android.support.v4.app.Fragment>,javax.inject.Provider<dagger.android.AndroidInjector.Factory<? extends

Injecting Generics in Dagger

非 Y 不嫁゛ 提交于 2019-12-01 17:19:10
Is it possible in Dagger to do something like the following: public abstract class Presenter<T extends BaseView> { @Inject T mView; public void showLoadingIndicator() { mView.showLoading(); } } (example module) public class MyModule { private MyView mView; //extends BaseView public MyModule(MyView view) { mView = view; } @Provides public BaseView provideView() { return mView; } } And then create an object graph with the module above and inject the view into the presenter? My attempts have not worked (usually get "unknown class 'T'" sort of errors). I'm not sure if my configuration is wrong or

Injecting Generics in Dagger

℡╲_俬逩灬. 提交于 2019-12-01 17:00:32
问题 Is it possible in Dagger to do something like the following: public abstract class Presenter<T extends BaseView> { @Inject T mView; public void showLoadingIndicator() { mView.showLoading(); } } (example module) public class MyModule { private MyView mView; //extends BaseView public MyModule(MyView view) { mView = view; } @Provides public BaseView provideView() { return mView; } } And then create an object graph with the module above and inject the view into the presenter? My attempts have not

日新月异的Android新技术

喜你入骨 提交于 2019-12-01 05:23:01
学习Android技术开发已经很久啦,感觉Android技术开发太快,几乎每年 都有很多新东西出现,想要覆盖所有新东西感觉也不太可能,我这里主要说一下主要的 Android 的主要新技术发展,其实了解 Android 的发展趋势,可能对Android程序开发者有帮助。 介绍下Android开发工具 Android Studio : Google 官方放弃 Eclipse 和 Android Studio 普及。AS 虽然不算新,但是对 Android Studio 这个软件的更新速度快的惊人,有大量的新功能发布。例如支持很多注解代码提示注解、Live code template、支持自动生成 Parcelable 实现等等,作为开发者,持续关注这个更新列表 Recent Changes ,一定会让你的写代码的生活更加美好。 编程“语言” Kotlin : 作为 Android 领域的 Swift,绝对让你如沐新风。抛弃沉重的 Java 语法,Kotlin 融入了很多现代编程语言的思想,作为开发者,接受新的语言,了解新语言的发展趋势,更有利于开阔你的思路和加深对语言的理解。在 Android 开发上,使用 Kotlin 并不会让你付出什么代价,为什么不来试试? 使用Kotlin进行Android开发 。 React Native : 跨平台一直是程序员的梦想

How to mock Dagger activity object graphs?

对着背影说爱祢 提交于 2019-11-30 22:46:08
I'm using Dagger in an android app to provide application and activity scope graphs. And I'm using Robolectric for unit-testing. I know that I can provide Robolectric with a substitute Application class that is configured with an application object graph that overrides the real one with mocks. But I'm stumped as to how to do the same with the activity object graphs since the standard pattern for activity object graphs is for the activities themselves to instantiate the activity-specific Dagger module they need. Any suggestions would be greatly appreciated. Please take a look to my project -

Context cannot be provided without an @Provides-annotated method, but it is?

爷,独闯天下 提交于 2019-11-30 17:48:40
I have the following simple module: @Module public class ApplicationModule { private CustomApplication customApplication; public ApplicationModule(CustomApplication customApplication) { this.customApplication = customApplication; } @Provides @Singleton CustomApplication provideCustomApplication() { return this.customApplication; } @Provides @Singleton @ForApplication Context provideApplicationContext() { return this.customApplication; } } And the respective simple component: @Singleton @Component( modules = ApplicationModule.class ) public interface ApplicationComponent { CustomApplication

How to mock Dagger activity object graphs?

江枫思渺然 提交于 2019-11-30 17:43:40
问题 I'm using Dagger in an android app to provide application and activity scope graphs. And I'm using Robolectric for unit-testing. I know that I can provide Robolectric with a substitute Application class that is configured with an application object graph that overrides the real one with mocks. But I'm stumped as to how to do the same with the activity object graphs since the standard pattern for activity object graphs is for the activities themselves to instantiate the activity-specific

DaggerAppComponent not created

南笙酒味 提交于 2019-11-30 14:36:11
问题 With dagger 2.10 I used to be able to create the app component by doing sAppComponent = DaggerAppComponent.builder() .appModule(new AppModule(this)) .sessionModule(new SessionModule()) .netModule(new NetModule()) .dataModule(new DataModule()) .build(); I was already using the AndroidInjector for Activities and everything was fine. Now I switched to 2.11 and I can't find the way to create the app component. In the google tutorial I see: DaggerYourApplicationComponent.create() .inject(this); to

Module depending on another module in Dagger

a 夏天 提交于 2019-11-30 13:18:20
I'm trying to use Dagger to do Dependency Injection on an app that I'm building, and running into trouble constructing proper DAGs when I have one package's Module depending on values provided by the Injector (presumably provided by another Module). If I have a simple module for some configurable variables (that I might want to swap out for testing environments, for example) @Module( injects = DependentModule.class, ) public class ConfigModule { @Provides @Named("ConfigOption") String provideConfigOption() { return "This Module's configurable option!"; } } and another module depends on it, e.g

DaggerAppComponent not created

心已入冬 提交于 2019-11-30 11:09:58
With dagger 2.10 I used to be able to create the app component by doing sAppComponent = DaggerAppComponent.builder() .appModule(new AppModule(this)) .sessionModule(new SessionModule()) .netModule(new NetModule()) .dataModule(new DataModule()) .build(); I was already using the AndroidInjector for Activities and everything was fine. Now I switched to 2.11 and I can't find the way to create the app component. In the google tutorial I see: DaggerYourApplicationComponent.create() .inject(this); to be added in the onCreate of the Application. In my case DaggerYourApplicationComponent =