Skip to content

Commit 2e89eb1

Browse files
committed
Disable character creation finish button after click
This lead to crashes when user click this button twice in short time span. Because when character save is run twice, fragment may be long gone (detached from Activity) and when we try to use Fragment.context for Toast confirmation, it's null.
1 parent cd1a78a commit 2e89eb1

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

app/src/main/java/cz/muni/fi/rpg/ui/characterCreation/CharacterCreationFragment.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package cz.muni.fi.rpg.ui.characterCreation
22

3+
import android.content.Context
34
import android.os.Bundle
45
import android.view.View
56
import android.widget.Toast
@@ -94,6 +95,9 @@ class CharacterCreationFragment(
9495
return@setOnClickListener
9596
}
9697

98+
buttonNext.isEnabled = false
99+
buttonNextProgress.visibility = View.VISIBLE
100+
97101
saveCharacter(
98102
info,
99103
statsData,

app/src/main/res/layout/fragment_character_creation.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@
6060
app:layout_constraintStart_toStartOf="parent"
6161
app:layout_constraintTop_toTopOf="parent" />
6262

63+
<ProgressBar
64+
android:id="@+id/buttonNextProgress"
65+
android:visibility="gone"
66+
app:layout_constraintEnd_toStartOf="@id/buttonNext"
67+
app:layout_constraintTop_toTopOf="@id/buttonNext"
68+
app:layout_constraintBottom_toBottomOf="@id/buttonNext"
69+
android:layout_width="20dp"
70+
android:layout_height="20dp"/>
6371
<androidx.appcompat.widget.AppCompatButton
6472
android:id="@+id/buttonNext"
6573
style="@style/Widget.MaterialComponents.Button.TextButton"

0 commit comments

Comments
 (0)