This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val retrofit = Retrofit.Builder() | |
| .baseUrl("https://api.gdax.com/") | |
| .addConverterFactory(MoshiMigrationConverter(MoshiConverterFactory.create())) | |
| .addConverterFactory(GsonConverterFactory.create()) | |
| .build() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MoshiMigrationConverter(private val moshiConverterFactory: MoshiConverterFactory) | |
| : Converter.Factory() { | |
| override fun responseBodyConverter( | |
| type: Type, | |
| annotations: Array<Annotation>, | |
| retrofit: Retrofit): Converter<ResponseBody, *>? { | |
| for (annotation in annotations) { | |
| if (annotation.annotationClass == Moshi::class) { | |
| return moshiConverterFactory.responseBodyConverter(type, annotations, retrofit) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Target(AnnotationTarget.FUNCTION) | |
| @Retention(RUNTIME) | |
| annotation class Moshi | |
| interface GdaxApi { | |
| @GET("products") fun products(): Single<List<Product>> | |
| @Moshi @GET("products") fun productsMoshi(): Single<List<Product>> | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Provides fun cache() = LruCache() // LruCache is bound | |
| @Provides fun cache(): Cache = LruCache() // Cache is bound |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Component(modules = [AppModule::class, NetworkModule::class]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Inject lateinit var foo: Set<@JvmSuppressWildcards Foo> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Qualifier | |
| @Retention(RetentionPolicy.RUNTIME) | |
| @Target(AnnotationTarget.FIELD, AnnotationTarget.FUNCTION, AnnotationTarget.VALUE_PARAMETER) | |
| annotation class AppContext |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Module abstract class AppModule { | |
| @Binds abstract fun context(app: Application): Context | |
| @Module companion object { | |
| // Static @Provides | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Module object NetworkModule { | |
| @Provides @JvmStatic fun httpClient() = OkHttpClient.Builder().build() | |
| } |