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.retrofit
api other.jacksonConverter
api other.koinCore
implementation(other.jacksonKotlin) {
exclude module: 'kotlin-reflect'
}
@ -36,7 +38,8 @@ jacoco {
ext {
// Excluding data classes
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
}
// Excluding all non-kotlin classes
// Excluding all java classes and stuff that should not be covered
ext {
jacocoExclude = [
'**/activity/**',
@ -84,7 +84,8 @@ ext {
'**/view/**',
'**/R$*.class',
'**/R.class',
'**/BuildConfig.class'
'**/BuildConfig.class',
'**/di/**'
]
}
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.SubsonicAPIVersions
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.service.CachedMusicService
import org.moire.ultrasonic.service.MusicService
@ -25,6 +26,8 @@ private const val LOG_TAG = "MusicServiceModule"
fun musicServiceModule(sp: SharedPreferences) = applicationContext {
context(MUSIC_SERVICE_CONTEXT) {
subsonicApiModule()
bean(name = "ServerInstance") {
return@bean sp.getInt(
Constants.PREFERENCES_KEY_SERVER_INSTANCE,