2018-06-23 22:18:08 +02:00
|
|
|
package org.moire.ultrasonic.app
|
|
|
|
|
2021-05-09 08:35:15 +02:00
|
|
|
import android.content.Context
|
2020-05-29 11:23:51 +02:00
|
|
|
import androidx.multidex.MultiDexApplication
|
2020-09-18 09:37:19 +02:00
|
|
|
import org.koin.android.ext.koin.androidContext
|
|
|
|
import org.koin.core.context.startKoin
|
|
|
|
import org.koin.core.logger.Level
|
2020-09-30 14:47:59 +02:00
|
|
|
import org.moire.ultrasonic.BuildConfig
|
2020-06-30 17:09:13 +02:00
|
|
|
import org.moire.ultrasonic.di.appPermanentStorage
|
2021-02-05 21:45:50 +01:00
|
|
|
import org.moire.ultrasonic.di.applicationModule
|
2020-06-30 17:09:13 +02:00
|
|
|
import org.moire.ultrasonic.di.baseNetworkModule
|
|
|
|
import org.moire.ultrasonic.di.mediaPlayerModule
|
|
|
|
import org.moire.ultrasonic.di.musicServiceModule
|
2020-09-30 18:17:57 +02:00
|
|
|
import org.moire.ultrasonic.log.FileLoggerTree
|
2021-02-11 21:51:27 +01:00
|
|
|
import org.moire.ultrasonic.log.TimberKoinLogger
|
2021-09-24 18:20:53 +02:00
|
|
|
import org.moire.ultrasonic.util.Settings
|
2020-09-30 14:47:59 +02:00
|
|
|
import timber.log.Timber
|
|
|
|
import timber.log.Timber.DebugTree
|
2018-06-23 22:18:08 +02:00
|
|
|
|
2021-02-25 18:40:41 +01:00
|
|
|
/**
|
|
|
|
* The Main class of the Application
|
|
|
|
*/
|
2021-05-09 08:35:15 +02:00
|
|
|
|
2020-05-29 11:23:51 +02:00
|
|
|
class UApp : MultiDexApplication() {
|
2021-05-09 08:35:15 +02:00
|
|
|
|
|
|
|
init {
|
|
|
|
instance = this
|
|
|
|
}
|
|
|
|
|
2018-06-23 22:18:08 +02:00
|
|
|
override fun onCreate() {
|
|
|
|
super.onCreate()
|
|
|
|
|
2020-09-30 14:47:59 +02:00
|
|
|
if (BuildConfig.DEBUG) {
|
|
|
|
Timber.plant(DebugTree())
|
2020-10-02 18:47:21 +02:00
|
|
|
}
|
2021-09-24 18:20:53 +02:00
|
|
|
if (Settings.debugLogToFile) {
|
2021-05-09 10:57:36 +02:00
|
|
|
FileLoggerTree.plantToTimberForest()
|
2020-09-30 14:47:59 +02:00
|
|
|
}
|
|
|
|
|
2020-09-18 09:37:19 +02:00
|
|
|
startKoin {
|
2021-02-11 21:51:27 +01:00
|
|
|
logger(TimberKoinLogger(Level.INFO))
|
2020-09-18 09:37:19 +02:00
|
|
|
// declare Android context
|
|
|
|
androidContext(this@UApp)
|
|
|
|
// declare modules to use
|
|
|
|
modules(
|
2021-02-05 21:45:50 +01:00
|
|
|
applicationModule,
|
2018-08-03 21:50:21 +02:00
|
|
|
appPermanentStorage,
|
|
|
|
baseNetworkModule,
|
2020-06-26 16:33:27 +02:00
|
|
|
musicServiceModule,
|
|
|
|
mediaPlayerModule
|
2018-08-03 21:50:21 +02:00
|
|
|
)
|
2020-09-18 09:37:19 +02:00
|
|
|
}
|
2018-06-23 22:18:08 +02:00
|
|
|
}
|
2021-05-09 08:35:15 +02:00
|
|
|
|
|
|
|
companion object {
|
|
|
|
private var instance: UApp? = null
|
|
|
|
|
|
|
|
fun applicationContext(): Context {
|
|
|
|
return instance!!.applicationContext
|
|
|
|
}
|
|
|
|
}
|
2018-06-23 22:18:08 +02:00
|
|
|
}
|