dagger

andorid jar/库源码解析

て烟熏妆下的殇ゞ 提交于 2020-04-24 12:48:26
前言   本篇作为开篇,会大体上说明,需要解读源码的,类库,或者jar。 序   原本,类库和jar的系列准备写到逆向系列课程的,但是那个东西,在写了两篇,就没有后续了,现在也不知道从哪里开始了, 只能等后期想好了,再开篇单独写吧。 目录:   EventBus、Dagger、okhttp、retrofit、butterknife、zxing、Bolts、RxJava   org.apache.commons.codec、org.apache.commons.lang、org.apache.commons.io   io.netty、io.fabric、cat.ereza、javax、msgpack、zip4j   com.davemorrissey.labs、com.daimajia.easing、com.arcsoft.livebroadcast、pl.droidsonroids.gif 厂牌库:   XXX 工具库:    来源: oschina 链接: https://my.oschina.net/u/4265622/blog/3685595

AndroidX下使用Activity和Fragment的变化

∥☆過路亽.° 提交于 2020-04-13 11:42:10
【今日推荐】:为什么一到面试就懵逼!>>> 过去的一段时间,AndroidX 软件包下的 Activity/Fragmet 的 API 发生了很多变化。让我们看看它们是如何提升Android 的开发效率以及如何适应当下流行的编程规则和模式。 本文中描述的所有功能现在都可以在稳定的 AndroidX 软件包中使用,它们在去年均已发布或移至稳定版本。 在构造器中传入布局 ID 从 AndroidX AppCompat 1.1.0 和 Fragment 1.1.0 ( 译者注:AppCompat 包含 Fragment,且 Fragment 包含 Activity,详情见【整理】Jetpack 主要组件的依赖及传递关系 )开始,您可以使用将 layoutId 作为参数的构造函数: class MyActivity : AppCompatActivity(R.layout.my_activity) class MyFragmentActivity: FragmentActivity(R.layout.my_fragment_activity) class MyFragment : Fragment(R.layout.my_fragment) 这种方法可以减少 Activity/Fragment 中方法重写的数量,并使类更具可读性。无需在Activity 中重写 onCreate()

Dagger 2 cannot access Retrofit

天大地大妈咪最大 提交于 2020-04-08 09:05:21
问题 I'm trying to provide an instance of Retrofit to my Repository using Dagger 2 (with Android module). Buy I'm facing the error: Error:cannot access Retrofit Other instances like Picasso was injected with success, I just have problems with Retrofit. My Module @Module class NetworkModule { @Provides @Singleton fun providesRetrofit(): Retrofit { return Retrofit.Builder() .addConverterFactory(GsonConverterFactory.create()) .baseUrl(URL_BASE) .build() } @Provides @Singleton fun providesPicasso

Dagger 2 cannot access Retrofit

a 夏天 提交于 2020-04-08 09:03:56
问题 I'm trying to provide an instance of Retrofit to my Repository using Dagger 2 (with Android module). Buy I'm facing the error: Error:cannot access Retrofit Other instances like Picasso was injected with success, I just have problems with Retrofit. My Module @Module class NetworkModule { @Provides @Singleton fun providesRetrofit(): Retrofit { return Retrofit.Builder() .addConverterFactory(GsonConverterFactory.create()) .baseUrl(URL_BASE) .build() } @Provides @Singleton fun providesPicasso

Dagger: What if I *WANT* a new instance every time?

a 夏天 提交于 2020-03-22 05:50:52
问题 Interesting how difficult this answer is to find. I've been using Dagger - Android for a while now and have my entire dependency graph set up. I'm using scopes, qualifiers, all that good stuff. I'm not a Dagger newbie anymore, but suffice to say I've been using it in a pretty standard way in my Android setup and everything has been going great. For the first time, I'm realizing that I'd like to request new instances of a certain class in my graph myself, manually, and I want it to be a new

Dagger: What if I *WANT* a new instance every time?

六眼飞鱼酱① 提交于 2020-03-22 05:50:12
问题 Interesting how difficult this answer is to find. I've been using Dagger - Android for a while now and have my entire dependency graph set up. I'm using scopes, qualifiers, all that good stuff. I'm not a Dagger newbie anymore, but suffice to say I've been using it in a pretty standard way in my Android setup and everything has been going great. For the first time, I'm realizing that I'd like to request new instances of a certain class in my graph myself, manually, and I want it to be a new

Do we really need viewModelFactories and viewmodelProviders when using Dagger?

橙三吉。 提交于 2020-03-05 03:11:08
问题 So I was working on some sample MVVM project using Dagger. I have a viewmodel factory that goes like this: class DaggerViewModelFactory @Inject constructor(private val viewModelsMap: Map<Class<out ViewModel>, @JvmSuppressWildcards Provider<ViewModel>>) : ViewModelProvider.Factory { override fun <T : ViewModel> create(modelClass: Class<T>): T { val creator = viewModelsMap[modelClass] ?: viewModelsMap.asIterable().firstOrNull { modelClass.isAssignableFrom(it.key) }?.value ?: throw

Inject ViewModel using Dagger 2 + Kotlin + ViewModel

假如想象 提交于 2020-02-27 04:36:45
问题 class SlideshowViewModel : ViewModel() { @Inject lateinit var mediaItemRepository : MediaItemRepository fun init() { What goes here? } So I'm trying to learn Dagger2 so I can make my apps more testable. Problem is, I've already integrated Kotlin and am working on the Android Architectural components. I understand that constructor injection is preferable but this isn't possible with ViewModel . Instead, I can use lateinit in order to inject but I'm at a loss to figure out how to inject. Do I

How to read hostname from meta-data when providing Retrofit in DI Modules?

萝らか妹 提交于 2020-01-25 08:22:48
问题 I am using Dagger 2 + Retrofit to implement my interfaces which sends/receives data to/from my web service I am referring Philippe BOISNEY's AppModule.java as below private static String BASE_URL = "https://api.github.com/"; @Provides Gson provideGson() { return new GsonBuilder().create(); } @Provides Retrofit provideRetrofit(Gson gson) { Retrofit retrofit = new Retrofit.Builder() .addConverterFactory(GsonConverterFactory.create(gson)) .baseUrl(BASE_URL) .build(); return retrofit; } However I