Move subsonic api client to it's own DI module.

Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
Yahor Berdnikau 2018-06-23 22:49:46 +02:00
parent 8dc9534327
commit f007418298
4 changed files with 20 additions and 3 deletions

View File

@ -13,6 +13,8 @@ dependencies {
api other.kotlinStdlib api other.kotlinStdlib
api other.retrofit api other.retrofit
api other.jacksonConverter api other.jacksonConverter
api other.koinCore
implementation(other.jacksonKotlin) { implementation(other.jacksonKotlin) {
exclude module: 'kotlin-reflect' exclude module: 'kotlin-reflect'
} }
@ -36,7 +38,8 @@ jacoco {
ext { ext {
// Excluding data classes // Excluding data classes
jacocoExclude = [ jacocoExclude = [
'**/models/**' '**/models/**',
'**/di/**'
] ]
} }

View File

@ -0,0 +1,10 @@
package org.moire.ultrasonic.api.subsonic.di
import org.koin.dsl.context.Context
import org.moire.ultrasonic.api.subsonic.SubsonicAPIClient
const val SUBSONIC_API_CLIENT_CONTEXT = "SubsonicApiClientContext"
fun Context.subsonicApiModule() = context(SUBSONIC_API_CLIENT_CONTEXT) {
bean { return@bean SubsonicAPIClient(get()) }
}

View File

@ -70,7 +70,7 @@ dependencies {
testImplementation testing.kluent testImplementation testing.kluent
} }
// Excluding all non-kotlin classes // Excluding all java classes and stuff that should not be covered
ext { ext {
jacocoExclude = [ jacocoExclude = [
'**/activity/**', '**/activity/**',
@ -84,7 +84,8 @@ ext {
'**/view/**', '**/view/**',
'**/R$*.class', '**/R$*.class',
'**/R.class', '**/R.class',
'**/BuildConfig.class' '**/BuildConfig.class',
'**/di/**'
] ]
} }
jacocoAndroidUnitTestReport { jacocoAndroidUnitTestReport {

View File

@ -8,6 +8,7 @@ import org.moire.ultrasonic.BuildConfig
import org.moire.ultrasonic.api.subsonic.SubsonicAPIClient import org.moire.ultrasonic.api.subsonic.SubsonicAPIClient
import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
import org.moire.ultrasonic.api.subsonic.SubsonicClientConfiguration import org.moire.ultrasonic.api.subsonic.SubsonicClientConfiguration
import org.moire.ultrasonic.api.subsonic.di.subsonicApiModule
import org.moire.ultrasonic.cache.PermanentFileStorage import org.moire.ultrasonic.cache.PermanentFileStorage
import org.moire.ultrasonic.service.CachedMusicService import org.moire.ultrasonic.service.CachedMusicService
import org.moire.ultrasonic.service.MusicService import org.moire.ultrasonic.service.MusicService
@ -25,6 +26,8 @@ private const val LOG_TAG = "MusicServiceModule"
fun musicServiceModule(sp: SharedPreferences) = applicationContext { fun musicServiceModule(sp: SharedPreferences) = applicationContext {
context(MUSIC_SERVICE_CONTEXT) { context(MUSIC_SERVICE_CONTEXT) {
subsonicApiModule()
bean(name = "ServerInstance") { bean(name = "ServerInstance") {
return@bean sp.getInt( return@bean sp.getInt(
Constants.PREFERENCES_KEY_SERVER_INSTANCE, Constants.PREFERENCES_KEY_SERVER_INSTANCE,