Create coroutine application scope
This commit is contained in:
parent
0719dc53f2
commit
21228c23b2
2 changed files with 9 additions and 3 deletions
|
|
@ -3,14 +3,19 @@ package io.element.android.x
|
|||
import android.app.Application
|
||||
import com.airbnb.mvrx.Mavericks
|
||||
import io.element.android.x.matrix.MatrixInstance
|
||||
import kotlinx.coroutines.CoroutineName
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.plus
|
||||
import timber.log.Timber
|
||||
|
||||
class ElementXApplication : Application() {
|
||||
|
||||
private val applicationScope = MainScope() + CoroutineName("ElementX Scope")
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
Timber.plant(Timber.DebugTree())
|
||||
MatrixInstance.init(this)
|
||||
MatrixInstance.init(this, applicationScope)
|
||||
Mavericks.initialize(this)
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ package io.element.android.x.matrix
|
|||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
|
||||
|
||||
|
|
@ -9,8 +10,8 @@ object MatrixInstance {
|
|||
@SuppressLint("StaticFieldLeak")
|
||||
private lateinit var instance: Matrix
|
||||
|
||||
fun init(context: Context) {
|
||||
instance = Matrix(GlobalScope, context)
|
||||
fun init(context: Context, coroutineScope: CoroutineScope) {
|
||||
instance = Matrix(coroutineScope, context)
|
||||
}
|
||||
|
||||
fun getInstance(): Matrix {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue