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.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import java.util.Timer
|
||||
import kotlin.concurrent.schedule
|
||||
import kotlin.concurrent.thread
|
||||
|
||||
typealias RecorderModel = BaseRecorderModel<
|
||||
@ -140,10 +142,13 @@ fun RecorderEventsHandler(
|
||||
recorder: RecorderModel,
|
||||
cleanupOldFiles: Boolean = false
|
||||
): CompletableDeferred<Unit> {
|
||||
isProcessing = true
|
||||
|
||||
val completer = CompletableDeferred<Unit>()
|
||||
|
||||
// If processing takes this short, don't show the processing dialog
|
||||
val timer = Timer().schedule(250L) {
|
||||
isProcessing = true
|
||||
}
|
||||
|
||||
thread {
|
||||
runBlocking {
|
||||
try {
|
||||
@ -231,6 +236,7 @@ fun RecorderEventsHandler(
|
||||
if (recorder.isCurrentlyActivelyRecording) {
|
||||
recorder.recorderService?.unlockFiles(cleanupOldFiles)
|
||||
}
|
||||
timer.cancel()
|
||||
isProcessing = false
|
||||
processingProgress = null
|
||||
completer.complete(Unit)
|
||||
|
Loading…
x
Reference in New Issue
Block a user