From d7d67c2a7909818d4a6743a9f73f4aa8fb08560e Mon Sep 17 00:00:00 2001 From: Reco1l Date: Tue, 17 Dec 2024 19:10:54 -0300 Subject: [PATCH] Introduce ProgressDialog --- res/layout/dialog_progress.xml | 64 ++++++++++++++++++++ src/com/reco1l/osu/ui/ProgressDialog.kt | 80 +++++++++++++++++++++++++ 2 files changed, 144 insertions(+) create mode 100644 res/layout/dialog_progress.xml create mode 100644 src/com/reco1l/osu/ui/ProgressDialog.kt diff --git a/res/layout/dialog_progress.xml b/res/layout/dialog_progress.xml new file mode 100644 index 000000000..e04febd5c --- /dev/null +++ b/res/layout/dialog_progress.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/com/reco1l/osu/ui/ProgressDialog.kt b/src/com/reco1l/osu/ui/ProgressDialog.kt new file mode 100644 index 000000000..8345beefa --- /dev/null +++ b/src/com/reco1l/osu/ui/ProgressDialog.kt @@ -0,0 +1,80 @@ +package com.reco1l.osu.ui + +import com.google.android.material.progressindicator.CircularProgressIndicator +import ru.nsu.ccfit.zuev.osuplus.R + + +class ProgressDialog : MessageDialog() { + + + override val layoutID = R.layout.dialog_progress + + + /** + * The progress of the dialog. + */ + var progress: Int = 0 + set(value) { + field = value + if (isCreated) { + findViewById(R.id.progress)!!.progress = value + } + } + + /** + * Whether the progress is indeterminate or not. + */ + var indeterminate: Boolean = false + set(value) { + field = value + if (isCreated) { + findViewById(R.id.progress)!!.isIndeterminate = value + } + } + + /** + * The maximum value of the progress. + */ + var max: Int = 0 + set(value) { + field = value + if (isCreated) { + findViewById(R.id.progress)!!.max = value + } + } + + + override fun onLoadView() { + super.onLoadView() + + max = max + progress = progress + indeterminate = indeterminate + } + + + /** + * Sets the progress of the dialog. + */ + fun setProgress(value: Int): ProgressDialog { + progress = value + return this + } + + /** + * Sets whether the progress is indeterminate or not. + */ + fun setIndeterminate(value: Boolean): ProgressDialog { + indeterminate = value + return this + } + + /** + * Sets the maximum value of the progress. + */ + fun setMax(value: Int): ProgressDialog { + max = value + return this + } + +} \ No newline at end of file