diff options
author | Allan Wang <me@allanwang.ca> | 2021-11-23 18:29:05 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-23 18:29:05 -0800 |
commit | 120ad1520db9184ebfa00885066e06a9f976e5f6 (patch) | |
tree | 50835fa79cf15ff348be386c46cea0a05552ba74 /app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt | |
parent | e246b35323e27dd18fa48910e5ca95669b53f8b0 (diff) | |
parent | db646e23ce0047461e68be1af7021ce6171ac850 (diff) | |
download | frost-120ad1520db9184ebfa00885066e06a9f976e5f6.tar.gz frost-120ad1520db9184ebfa00885066e06a9f976e5f6.tar.bz2 frost-120ad1520db9184ebfa00885066e06a9f976e5f6.zip |
Merge pull request #1857 from AllanWang/flows
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt index b2bb1d11..6ba2c64d 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt @@ -42,7 +42,7 @@ import com.pitchedapps.frost.utils.frostUriFromFile import com.pitchedapps.frost.utils.sendFrostEmail import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job -import kotlinx.coroutines.channels.Channel +import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.launch import java.io.File @@ -71,6 +71,7 @@ fun SettingsActivity.getDebugPrefs(): KPrefAdapterBuilder.() -> Unit = { val parsers = arrayOf(NotifParser, MessageParser, SearchParser) materialDialog { + // noinspection CheckResult listItems(items = parsers.map { string(it.nameRes) }) { dialog, position, _ -> dialog.dismiss() val parser = parsers[position] @@ -133,20 +134,15 @@ fun SettingsActivity.sendDebug(url: String, html: String?) { onDismiss { job.cancel() } } - val progressChannel = Channel<Int>(10) + val progressFlow = MutableStateFlow(0) - launchMain { - for (p in progressChannel) { -// md.setProgress(p) - } - } +// progressFlow.onEach { md.setProgress(it) }.launchIn(this) launchMain { val success = downloader.loadAndZip(ZIP_NAME) { - progressChannel.offer(it) + progressFlow.tryEmit(it) } md.dismiss() - progressChannel.close() if (success) { val zipUri = frostUriFromFile( File(downloader.baseDir, "$ZIP_NAME.zip") |