diff --git a/Habitica/res/layout/dialog_purchase_customization.xml b/Habitica/res/layout/dialog_purchase_customization.xml
index 5697da968..4389a1d9a 100644
--- a/Habitica/res/layout/dialog_purchase_customization.xml
+++ b/Habitica/res/layout/dialog_purchase_customization.xml
@@ -4,10 +4,11 @@
android:layout_height="wrap_content">
+ android:layout_gravity="center_horizontal"
+ android:scaleType="center"/>
return "skin_$identifier"
+ "shirt" -> return userSize + "_shirt_" + identifier
+ "hair" -> {
+ return if (identifier == "0") {
+ "head_0"
+ } else when (this.category) {
+ "color" -> "hair_bangs_1_$identifier"
+ "flower" -> "hair_flower_$identifier"
+ else -> "hair_" + this.category + "_" + identifier + "_" + hairColor
+ }
+ }
+ "background" -> return "background_$identifier"
+ "chair" -> return "chair_$identifier"
+ }
+ return ""
+ }
+
+ val isUsable: Boolean
+ get() = price == null || price == 0 || purchased
+
+ val path: String
+ get() {
+ var path = type
+ if (this.category != null) {
+ path = path + "." + this.category
+ }
+ path = path + "." + identifier
+ return path
+ }
+
+}
\ No newline at end of file
diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/adapter/CustomizationRecyclerViewAdapter.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/adapter/CustomizationRecyclerViewAdapter.kt
index d1603b19e..39ff6351d 100644
--- a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/adapter/CustomizationRecyclerViewAdapter.kt
+++ b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/adapter/CustomizationRecyclerViewAdapter.kt
@@ -1,6 +1,7 @@
package com.habitrpg.android.habitica.ui.adapter
import android.content.Context
+import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@@ -138,17 +139,25 @@ class CustomizationRecyclerViewAdapter : androidx.recyclerview.widget.RecyclerVi
fun bind(customization: Customization) {
this.customization = customization
- if (customization.customizationSet?.contains("timeTravel") == true) {
- DataBindingUtils.loadImage(binding.imageView, customization.getImageName(userSize, hairColor), imageFormat = "gif")
- } else {
- DataBindingUtils.loadImage(binding.imageView, customization.getImageName(userSize, hairColor))
+ DataBindingUtils.loadImage(binding.imageView, customization.getIconName(userSize, hairColor))
+
+ if (customization.type == "background") {
+ val params = (binding.imageView.layoutParams as? LinearLayout.LayoutParams)?.apply {
+ gravity = Gravity.CENTER
+ }
+ binding.imageView.layoutParams = params
}
+
if (customization.isUsable) {
binding.buyButton.visibility = View.GONE
} else {
binding.buyButton.visibility = View.VISIBLE
- binding.priceLabel.currency = "gems"
- binding.priceLabel.value = customization.price.toDouble()
+ if (customization.customizationSet?.contains("timeTravel") == true) {
+ binding.priceLabel.currency = "hourglasses"
+ } else {
+ binding.priceLabel.currency = "gems"
+ }
+ binding.priceLabel.value = customization.price?.toDouble() ?: 0.0
}
if (activeCustomization == customization.identifier) {
diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/inventory/customization/AvatarCustomizationFragment.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/inventory/customization/AvatarCustomizationFragment.kt
index 8814a81db..c4f079126 100644
--- a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/inventory/customization/AvatarCustomizationFragment.kt
+++ b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/inventory/customization/AvatarCustomizationFragment.kt
@@ -138,7 +138,7 @@ class AvatarCustomizationFragment : BaseMainFragment() {
this.updateActiveCustomization(user)
if (adapter.customizationList.size != 0) {
val ownedCustomizations = ArrayList()
- user.purchased?.customizations?.filter { it.type == this.type }?.mapTo(ownedCustomizations) { it.id }
+ user.purchased?.customizations?.filter { it.type == this.type }?.mapTo(ownedCustomizations) { it.id ?: "" }
adapter.updateOwnership(ownedCustomizations)
} else {
this.loadCustomizations()
diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/utils/CustomizationDeserializer.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/utils/CustomizationDeserializer.kt
index d1416bc31..d0177b3ae 100644
--- a/Habitica/src/main/java/com/habitrpg/android/habitica/utils/CustomizationDeserializer.kt
+++ b/Habitica/src/main/java/com/habitrpg/android/habitica/utils/CustomizationDeserializer.kt
@@ -54,7 +54,7 @@ class CustomizationDeserializer : JsonDeserializer> {
if (jsonObject.has(customization.customizationSet)) {
val nestedObject = jsonObject.get(customization.customizationSet).asJsonObject
if (nestedObject.has(customization.identifier)) {
- customizations.add(this.parseBackground(customization, customization.customizationSet, customization.identifier, nestedObject.get(customization.identifier).asJsonObject))
+ customizations.add(this.parseBackground(customization, customization.customizationSet ?: "", customization.identifier, nestedObject.get(customization.identifier).asJsonObject))
nestedObject.remove(customization.identifier)
}
}