mirror of
https://github.com/Myzel394/Alibi.git
synced 2025-06-18 23:05:26 +02:00
feat: Only show processing dialog after some time
Signed-off-by: Myzel394 <50424412+Myzel394@users.noreply.github.com>
This commit is contained in:
parent
7d83bca1fe
commit
cfea5a9143
@ -33,6 +33,8 @@ import app.myzel394.alibi.ui.utils.rememberFileSaverDialog
|
|||||||
import kotlinx.coroutines.CompletableDeferred
|
import kotlinx.coroutines.CompletableDeferred
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
|
import java.util.Timer
|
||||||
|
import kotlin.concurrent.schedule
|
||||||
import kotlin.concurrent.thread
|
import kotlin.concurrent.thread
|
||||||
|
|
||||||
typealias RecorderModel = BaseRecorderModel<
|
typealias RecorderModel = BaseRecorderModel<
|
||||||
@ -140,10 +142,13 @@ fun RecorderEventsHandler(
|
|||||||
recorder: RecorderModel,
|
recorder: RecorderModel,
|
||||||
cleanupOldFiles: Boolean = false
|
cleanupOldFiles: Boolean = false
|
||||||
): CompletableDeferred<Unit> {
|
): CompletableDeferred<Unit> {
|
||||||
isProcessing = true
|
|
||||||
|
|
||||||
val completer = CompletableDeferred<Unit>()
|
val completer = CompletableDeferred<Unit>()
|
||||||
|
|
||||||
|
// If processing takes this short, don't show the processing dialog
|
||||||
|
val timer = Timer().schedule(250L) {
|
||||||
|
isProcessing = true
|
||||||
|
}
|
||||||
|
|
||||||
thread {
|
thread {
|
||||||
runBlocking {
|
runBlocking {
|
||||||
try {
|
try {
|
||||||
@ -231,6 +236,7 @@ fun RecorderEventsHandler(
|
|||||||
if (recorder.isCurrentlyActivelyRecording) {
|
if (recorder.isCurrentlyActivelyRecording) {
|
||||||
recorder.recorderService?.unlockFiles(cleanupOldFiles)
|
recorder.recorderService?.unlockFiles(cleanupOldFiles)
|
||||||
}
|
}
|
||||||
|
timer.cancel()
|
||||||
isProcessing = false
|
isProcessing = false
|
||||||
processingProgress = null
|
processingProgress = null
|
||||||
completer.complete(Unit)
|
completer.complete(Unit)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user