Merge branch 'housekeeping/7-restructure-koin-modules' into 'develop'
#7: Restructure koin modules See merge request funkwhale/funkwhale-android!59
This commit is contained in:
commit
246e2d065b
|
@ -3,7 +3,8 @@ package audio.funkwhale.ffa
|
|||
import android.app.Application
|
||||
import android.content.Context
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import audio.funkwhale.ffa.koin.ffaModule
|
||||
import audio.funkwhale.ffa.koin.authModule
|
||||
import audio.funkwhale.ffa.koin.exoplayerModule
|
||||
import audio.funkwhale.ffa.utils.*
|
||||
import com.preference.PowerPreference
|
||||
import kotlinx.coroutines.channels.BroadcastChannel
|
||||
|
@ -31,7 +32,10 @@ class FFA : Application() {
|
|||
super.onCreate()
|
||||
|
||||
startKoin {
|
||||
modules(ffaModule(this@FFA))
|
||||
modules(
|
||||
authModule(),
|
||||
exoplayerModule(this@FFA)
|
||||
)
|
||||
}
|
||||
|
||||
defaultExceptionHandler = Thread.getDefaultUncaughtExceptionHandler()
|
||||
|
|
|
@ -8,10 +8,6 @@ import audio.funkwhale.ffa.utils.DefaultOAuth
|
|||
import audio.funkwhale.ffa.utils.OAuth
|
||||
import com.google.android.exoplayer2.database.DatabaseProvider
|
||||
import com.google.android.exoplayer2.database.ExoDatabaseProvider
|
||||
import com.google.android.exoplayer2.offline.DefaultDownloadIndex
|
||||
import com.google.android.exoplayer2.offline.DefaultDownloaderFactory
|
||||
import com.google.android.exoplayer2.offline.DownloadManager
|
||||
import com.google.android.exoplayer2.offline.DownloaderConstructorHelper
|
||||
import com.google.android.exoplayer2.upstream.cache.Cache
|
||||
import com.google.android.exoplayer2.upstream.cache.LeastRecentlyUsedCacheEvictor
|
||||
import com.google.android.exoplayer2.upstream.cache.NoOpCacheEvictor
|
||||
|
@ -20,23 +16,10 @@ import com.preference.PowerPreference
|
|||
import org.koin.core.qualifier.named
|
||||
import org.koin.dsl.module
|
||||
|
||||
fun ffaModule(context: Context) = module {
|
||||
fun exoplayerModule(context: Context) = module {
|
||||
|
||||
single<OAuth> { DefaultOAuth(get()) }
|
||||
|
||||
single { AuthorizationServiceFactory() }
|
||||
|
||||
single {
|
||||
val cacheDataSourceFactoryProvider = get<CacheDataSourceFactoryProvider>()
|
||||
DownloaderConstructorHelper(
|
||||
get(named("exoDownloadCache")), cacheDataSourceFactoryProvider.create(context)
|
||||
).run {
|
||||
DownloadManager(
|
||||
context,
|
||||
DefaultDownloadIndex(get(named("exoDatabase"))),
|
||||
DefaultDownloaderFactory(this)
|
||||
)
|
||||
}
|
||||
single<DatabaseProvider>(named("exoDatabase")) {
|
||||
ExoDatabaseProvider(context)
|
||||
}
|
||||
|
||||
single {
|
||||
|
@ -47,8 +30,6 @@ fun ffaModule(context: Context) = module {
|
|||
)
|
||||
}
|
||||
|
||||
single<DatabaseProvider>(named("exoDatabase")) { ExoDatabaseProvider(context) }
|
||||
|
||||
single<Cache>(named("exoDownloadCache")) {
|
||||
SimpleCache(
|
||||
context.cacheDir.resolve("downloads"),
|
||||
|
@ -69,3 +50,9 @@ fun ffaModule(context: Context) = module {
|
|||
|
||||
single { MediaSession(context) }
|
||||
}
|
||||
|
||||
fun authModule() = module {
|
||||
single<OAuth> { DefaultOAuth(get()) }
|
||||
|
||||
single { AuthorizationServiceFactory() }
|
||||
}
|
|
@ -13,6 +13,7 @@ import com.google.android.exoplayer2.Player
|
|||
import com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector
|
||||
|
||||
class MediaSession(private val context: Context) {
|
||||
|
||||
var active = false
|
||||
|
||||
private val playbackStateBuilder = PlaybackStateCompat.Builder().apply {
|
||||
|
|
Loading…
Reference in New Issue