Dagger2学习成本有点高:
推荐几篇博客:
https://www.jianshu.com/p/cd2c1c9f68d4这里讲依赖注入
https://www.jianshu.com/p/3a3748260eac这里讲注解
https://blog.csdn.net/u013320868/article/details/54926578这里依赖注入实现一个butterknife
https://blog.csdn.net/mq2553299/article/details/73065745他有4篇需要看完
https://www.jianshu.com/p/22c397354997这篇需要反复看很不错
https://www.jianshu.com/p/c556b415b800这里讲dagger2和MVP模式结合很不错
代码地址:稍后
Dagger2学习笔记一:
/** * dagger2 * 1.@Inject--- * 2.@Inject * 3.@Module * 4.@Module--- * 5.@Module@Inject(OkHttpClient@Inject, * HttpActivityModule2OkHttpClient) * 6.@Provides@Inject * 7.@Component * 8.@Component * 9.@Component@Inject(modules = xxxx.class) * 10.@Componentmodulemodules = HttpActivityModule2.class * 11.@Componentvoid inject(A01SimpleActivity activity); * 12.MainActivity * 12a.MainActivityHttpActivityModulehttpActivityModule2 * 12b.ModuleModulehttpActivityModule2 * * @Inject “” * * @Module +@Providers “” * Component Activity,ProviderInjector * InjectorProviderget()ActivityActivity * * * Dagger2 * 1.DaggerXXXComponent.builder().build()XXXComponent * 2.@Componentvoid inject(XXX xxx) * 2.1@ComponentApplicationComponentApplicationBean providerAppBean(); BeanForApplicationComponent * 2.1https://blog.csdn.net/u010961631/article/details/72626134 * 3. * 4.@singleTon * 5.ComponentDagger+Component * 6.Componentvoidinject * 7.ComponentvoidComponentComponent */
Dagger2学习笔记二
/** * * 0.MainActivity.appComponent(MyApplication.appComponent)AppModule * 1.@SingleTon * 2.MainActivitymainPresenterMainPresenter * 3.MainPresenterMainPresenter(MainActivity,MainPresenter) * 3.1DaggerMainAcitivityComponent * 3.2 * this.mainPresenterProvider = MainPresenter_Factory.create(mainPresenterMembersInjector, provideLoginViewProvider); * this.mainActivityMembersInjector = MainActivity_MembersInjector.create(sharedPreferencesProvider, myApplicationProvider, mainPresenterProvider); * mainActivityMembersInjectormyApplicationProvidersharedPreferencesProvider * MainPresentermyApplicationmainPresenter * PresenterDaggerXXXComponent.builder().build().inject() * 4.TestClassPresenterpresenterPresenter“” * 4.1“”presenter * */
MVPamrs全家桶的理解
文章来源: Dagger2和MVParms的学习