fix bulk stat allocation

This commit is contained in:
Phillip Thelen 2024-06-07 11:10:22 +02:00
parent 012a8fe24f
commit 7d445cc75e
3 changed files with 10 additions and 3 deletions

View file

@ -133,3 +133,4 @@
-keepattributes Signature
-keep class kotlin.coroutines.Continuation
-dontwarn com.habitrpg.android.habitica.extensions.ViewGroupExt

View file

@ -44,7 +44,6 @@ class BulkAllocateStatsDialog(context: Context, private val userRepository: User
init {
setView(binding.root)
this.setButton(BUTTON_POSITIVE, context.getString(R.string.save)) { _, _ ->
saveChanges()
}
this.setButton(BUTTON_NEUTRAL, context.getString(R.string.action_cancel)) { _, _ ->
this.dismiss()
@ -54,7 +53,7 @@ class BulkAllocateStatsDialog(context: Context, private val userRepository: User
private fun saveChanges() {
getButton(BUTTON_POSITIVE).isEnabled = false
lifecycleScope.launchCatching {
userRepository.bulkAllocatePoints(
val result = userRepository.bulkAllocatePoints(
binding.strengthSliderView.currentValue,
binding.intelligenceSliderView.currentValue,
binding.constitutionSliderView.currentValue,
@ -96,6 +95,13 @@ class BulkAllocateStatsDialog(context: Context, private val userRepository: User
}
}
override fun onAttachedToWindow() {
super.onAttachedToWindow()
getButton(BUTTON_POSITIVE).setOnClickListener {
saveChanges()
}
}
private fun checkRedistribution(excludedSlider: StatsSliderView) {
val diff = allocatedPoints - pointsToAllocate
if (diff > 0) {

View file

@ -1,2 +1,2 @@
NAME=4.3.7
CODE=7891
CODE=7911