fixed crash when setting livedata value from a background thread

This commit is contained in:
Xinto 2020-11-15 23:02:49 +04:00
parent 52bb26b3e0
commit 98f634051a
2 changed files with 1 additions and 4 deletions

View File

@ -32,15 +32,14 @@ object AppUtils: CoroutineScope by CoroutineScope(Dispatchers.IO) {
}
fun sendCloseDialog(context: Context): Job {
downloadProgress.value?.installing?.value = false
return launch {
delay(700)
downloadProgress.value?.installing?.postValue(false)
LocalBroadcastManager.getInstance(context).sendBroadcast(Intent(AppDownloadDialog.CLOSE_DIALOG))
}
}
fun sendFailure(status: Int, context: Context): Job {
downloadProgress.value?.installing?.value = false
//Delay error broadcast until activity (and fragment) get back to the screen
return launch {
delay(700)
@ -51,7 +50,6 @@ object AppUtils: CoroutineScope by CoroutineScope(Dispatchers.IO) {
}
fun sendFailure(error: MutableList<String>, context: Context): Job {
downloadProgress.value?.installing?.value = false
return launch {
delay(700)
val intent = Intent(HomeFragment.INSTALL_FAILED)

View File

@ -374,7 +374,6 @@ object PackageHelper {
}
sendFailure(installResult.out, context)
sendCloseDialog(context)
return false
}