Skip to content

Commit 43fc127

Browse files
author
MFlisar
committed
fixed progress dialog demo
1 parent cb0352d commit 43fc127

File tree

2 files changed

+9
-26
lines changed

2 files changed

+9
-26
lines changed

.idea/deploymentTargetDropDown.xml

Lines changed: 0 additions & 17 deletions
This file was deleted.

app/src/main/java/com/michaelflisar/dialogs/MainActivity.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ class MainActivity : AppCompatActivity() {
593593
adapter.add(
594594
HeaderItem("PROGRESS DEMOS"),
595595
DemoItem("Progress demo", "Show a progress dialog for 5s (indeterminate mode)") {
596-
DialogProgress(
596+
val dlg = DialogProgress(
597597
500,
598598
title = "Loading (Indeterminate)".asText(),
599599
text = "Data is loading...".asText(),
@@ -602,7 +602,7 @@ class MainActivity : AppCompatActivity() {
602602
horizontal = true,
603603
indeterminate = true
604604
)
605-
.showInCorrectMode(this, it)
605+
dlg.showInCorrectMode(this, it)
606606

607607
// simple unsafe method to immitate some background process that runs 5 seconds and updates the progress every second...
608608
var c = 0
@@ -611,14 +611,14 @@ class MainActivity : AppCompatActivity() {
611611
delay(1000L)
612612
c++
613613
withContext(Dispatchers.Main) {
614-
DialogProgress.update(50, "Time left: ${5 - c}s".asText())
614+
DialogProgress.update(dlg.id, "Time left: ${5 - c}s".asText())
615615
}
616616
}
617-
DialogProgress.dismiss(50)
617+
DialogProgress.dismiss(dlg.id)
618618
}
619619
},
620620
DemoItem("Progress demo", "Show a progress dialog for 5s (with progress state)") {
621-
DialogProgress(
621+
val dlg = DialogProgress(
622622
501,
623623
title = "Loading (Progress)".asText(),
624624
text = "Data is loading...".asText(),
@@ -627,7 +627,7 @@ class MainActivity : AppCompatActivity() {
627627
horizontal = true,
628628
indeterminate = false
629629
)
630-
.showInCorrectMode(this, it)
630+
dlg.showInCorrectMode(this, it)
631631

632632
// simple unsafe method to immitate some background process that runs 5 seconds and updates the progress every second...
633633
var c = 0
@@ -636,11 +636,11 @@ class MainActivity : AppCompatActivity() {
636636
delay(50L)
637637
c++
638638
withContext(Dispatchers.Main) {
639-
DialogProgress.update(51, "${c}%".asText())
640-
DialogProgress.updateProgress(51, c)
639+
DialogProgress.update(dlg.id, "${c}%".asText())
640+
DialogProgress.updateProgress(dlg.id, c)
641641
}
642642
}
643-
DialogProgress.dismiss(51)
643+
DialogProgress.dismiss(dlg.id)
644644
}
645645
}
646646
)

0 commit comments

Comments
 (0)