mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-18 11:49:01 +00:00
Don’t automatically dismiss purchase dialog if insufficient currency
This commit is contained in:
parent
3a4b0e3925
commit
46324bb0eb
2 changed files with 9 additions and 7 deletions
|
|
@ -168,11 +168,11 @@ open class HabiticaAlertDialog(context: Context) : AlertDialog(context, R.style.
|
|||
button.text = string
|
||||
button.minWidth = 147.dpToPx(context)
|
||||
button.setScaledPadding(context, 20, 0, 20, 0)
|
||||
return addButton(button, function) as Button
|
||||
return addButton(button, true, function) as Button
|
||||
}
|
||||
|
||||
|
||||
fun addButton(buttonView: View, function: ((HabiticaAlertDialog, Int) -> Unit)? = null): View {
|
||||
fun addButton(buttonView: View, autoDismiss: Boolean = true, function: ((HabiticaAlertDialog, Int) -> Unit)? = null): View {
|
||||
val weakThis = WeakReference<HabiticaAlertDialog>(this)
|
||||
val buttonIndex = buttonsWrapper.childCount
|
||||
buttonView.setOnClickListener {
|
||||
|
|
@ -180,7 +180,9 @@ open class HabiticaAlertDialog(context: Context) : AlertDialog(context, R.style.
|
|||
if (function != null) {
|
||||
function(it1, buttonIndex)
|
||||
}
|
||||
dismiss()
|
||||
if (autoDismiss) {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
configureButtonLayoutParams(buttonView)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import android.content.Context
|
|||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Button
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
|
|
@ -55,7 +54,7 @@ class PurchaseDialog(context: Context, component: UserComponent?, val item: Shop
|
|||
}
|
||||
private val currencyView: CurrencyViews by bindView(customHeader, R.id.currencyView)
|
||||
private val limitedTextView: TextView by bindView(customHeader, R.id.limitedTextView)
|
||||
private val buyButton: ViewGroup
|
||||
private val buyButton: View
|
||||
private val priceLabel: CurrencyView
|
||||
private val buyLabel: TextView
|
||||
private val pinButton: Button by bindView(customHeader, R.id.pin_button)
|
||||
|
|
@ -142,9 +141,9 @@ class PurchaseDialog(context: Context, component: UserComponent?, val item: Shop
|
|||
setCustomHeaderView(customHeader)
|
||||
|
||||
addCloseButton()
|
||||
buyButton = addButton(layoutInflater.inflate(R.layout.dialog_purchase_shopitem_button, null)) { _, _ ->
|
||||
buyButton = addButton(layoutInflater.inflate(R.layout.dialog_purchase_shopitem_button, null), autoDismiss = false) { _, _ ->
|
||||
onBuyButtonClicked()
|
||||
} as ViewGroup
|
||||
}
|
||||
priceLabel = buyButton.findViewById(R.id.priceLabel)
|
||||
buyLabel = buyButton.findViewById(R.id.buy_label)
|
||||
pinButton.setOnClickListener { inventoryRepository.togglePinnedItem(shopItem).subscribe(Consumer { isPinned = !this.isPinned }, RxErrorHandler.handleEmptyError()) }
|
||||
|
|
@ -276,6 +275,7 @@ class PurchaseDialog(context: Context, component: UserComponent?, val item: Shop
|
|||
"hourglasses" == shopItem.currency -> InsufficientHourglassesDialog(context)
|
||||
else -> null
|
||||
}?.show()
|
||||
return
|
||||
}
|
||||
}
|
||||
dismiss()
|
||||
|
|
|
|||
Loading…
Reference in a new issue