Skip to content

Commit

Permalink
fix,feat(ui): show loading dialog after confirming the schemas to enable
Browse files Browse the repository at this point in the history
  • Loading branch information
WhiredPlanck committed Jan 14, 2023
1 parent 5f33a55 commit 0943b30
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion app/src/main/java/com/osfans/trime/ui/main/Pickers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ import com.osfans.trime.data.theme.Config
import com.osfans.trime.data.theme.ThemeManager
import com.osfans.trime.ime.core.Trime
import com.osfans.trime.ui.components.CoroutineChoiceDialog
import com.osfans.trime.util.ProgressBarDialogIndeterminate
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.cancelAndJoin
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext

suspend fun Context.themePicker(
@StyleRes themeResId: Int = 0
Expand Down Expand Up @@ -91,7 +95,18 @@ fun Context.schemaPicker(
.filterIndexed { i, _ -> checked[i] }
.toTypedArray()
)
Rime.deployRime()
val loading = ProgressBarDialogIndeterminate(titleId = R.string.deploy_progress).create()
val job = launch {
delay(200L)
loading.show()
}
withContext(Dispatchers.Default) {
Rime.deployRime()
job.cancelAndJoin()
if (loading.isShowing) {
loading.dismiss()
}
}
}
}
.setNegativeButton(android.R.string.cancel, null)
Expand Down

0 comments on commit 0943b30

Please sign in to comment.