mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-18 03:39:00 +00:00
Show background for purchase when selecting background item
This commit is contained in:
parent
73246fa354
commit
f89847feea
3 changed files with 24 additions and 4 deletions
|
|
@ -35,6 +35,7 @@ class AvatarView : FrameLayout {
|
|||
private var showPet = true
|
||||
private var showSleeping = true
|
||||
private var hasBackground: Boolean = false
|
||||
private var backgroundForPurchase: String? = null
|
||||
private var hasMount: Boolean = false
|
||||
private var hasPet: Boolean = false
|
||||
private val imageViewHolder = mutableListOf<ImageView>()
|
||||
|
|
@ -203,7 +204,10 @@ class AvatarView : FrameLayout {
|
|||
}
|
||||
|
||||
var backgroundName = avatar.preferences?.background
|
||||
if (showBackground && backgroundName?.isNotEmpty() == true) {
|
||||
if (backgroundForPurchase != null) {
|
||||
layerMap[LayerType.BACKGROUND] = backgroundForPurchase
|
||||
if (resetHasAttributes) hasBackground = true
|
||||
} else if (showBackground && backgroundName?.isNotEmpty() == true) {
|
||||
backgroundName = substituteOrReturn(spriteSubstitutions["backgrounds"], backgroundName)
|
||||
layerMap[LayerType.BACKGROUND] = "background_$backgroundName"
|
||||
if (resetHasAttributes) hasBackground = true
|
||||
|
|
@ -433,6 +437,22 @@ class AvatarView : FrameLayout {
|
|||
}
|
||||
}
|
||||
|
||||
fun setAvatarWithBackgroundForPurchase(avatar: Avatar, backgroundForPurchase: String?) {
|
||||
val oldUser = this.avatar
|
||||
this.avatar = avatar
|
||||
this.backgroundForPurchase = backgroundForPurchase
|
||||
|
||||
var equals = false
|
||||
if (oldUser != null) {
|
||||
val newLayerMap = getLayerMap(avatar, false)
|
||||
|
||||
equals = currentLayers == newLayerMap
|
||||
}
|
||||
if (!equals) {
|
||||
invalidate()
|
||||
}
|
||||
}
|
||||
|
||||
private fun initAvatarRectMatrix() {
|
||||
if (avatarRectF == null) {
|
||||
val srcRect = originalRect
|
||||
|
|
|
|||
|
|
@ -288,7 +288,7 @@ class PurchaseDialog(context: Context, component: UserComponent?, val item: Shop
|
|||
setLimitedTextView()
|
||||
|
||||
if (additionalContentView is PurchaseDialogBackgroundContent) {
|
||||
(additionalContentView as PurchaseDialogBackgroundContent).setAvatar(userRepository.getUnmanagedCopy(user))
|
||||
(additionalContentView as PurchaseDialogBackgroundContent).setAvatarWithBackgroundForPurchase(userRepository.getUnmanagedCopy(user), shopItem)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class PurchaseDialogBackgroundContent(context: Context) : PurchaseDialogContent(
|
|||
binding.notesTextView.text = item.notes
|
||||
}
|
||||
|
||||
fun setAvatar(avatar: Avatar) {
|
||||
binding.avatarView.setAvatar(avatar)
|
||||
fun setAvatarWithBackgroundForPurchase(avatar: Avatar, item: ShopItem) {
|
||||
binding.avatarView.setAvatarWithBackgroundForPurchase(avatar, item.imageName)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue