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