mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-12-22 07:44:00 +01:00
Remove usage of GlobalScope
This commit is contained in:
parent
baa4b95e18
commit
257b2ef593
@ -18,8 +18,8 @@ package im.vector.app.features.crypto.keys
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import im.vector.app.features.session.coroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.matrix.android.sdk.api.MatrixCallback
|
||||
@ -33,7 +33,7 @@ class KeysExporter(private val session: Session) {
|
||||
* Export keys and return the file path with the callback
|
||||
*/
|
||||
fun export(context: Context, password: String, uri: Uri, callback: MatrixCallback<Boolean>) {
|
||||
GlobalScope.launch(Dispatchers.Main) {
|
||||
session.coroutineScope.launch(Dispatchers.Main) {
|
||||
runCatching {
|
||||
withContext(Dispatchers.IO) {
|
||||
val data = awaitCallback<ByteArray> { session.cryptoService().exportRoomKeys(password, it) }
|
||||
|
@ -20,8 +20,8 @@ import android.content.Context
|
||||
import android.net.Uri
|
||||
import im.vector.app.core.intent.getMimeTypeFromUri
|
||||
import im.vector.app.core.resources.openResource
|
||||
import im.vector.app.features.session.coroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.matrix.android.sdk.api.MatrixCallback
|
||||
@ -41,7 +41,7 @@ class KeysImporter(private val session: Session) {
|
||||
mimetype: String?,
|
||||
password: String,
|
||||
callback: MatrixCallback<ImportRoomKeysResult>) {
|
||||
GlobalScope.launch(Dispatchers.Main) {
|
||||
session.coroutineScope.launch(Dispatchers.Main) {
|
||||
runCatching {
|
||||
withContext(Dispatchers.IO) {
|
||||
val resource = openResource(context, uri, mimetype ?: getMimeTypeFromUri(context, uri))
|
||||
|
Loading…
Reference in New Issue
Block a user