fixed crash when setting livedata value from a background thread
This commit is contained in:
parent
52bb26b3e0
commit
98f634051a
|
@ -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)
|
||||
|
|
|
@ -374,7 +374,6 @@ object PackageHelper {
|
|||
}
|
||||
sendFailure(installResult.out, context)
|
||||
sendCloseDialog(context)
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue