Improve stable display

This commit is contained in:
Phillip Thelen 2019-04-25 11:43:40 +02:00
parent 94b70d739c
commit 21f52e89e9
4 changed files with 16 additions and 3 deletions

View file

@ -340,7 +340,7 @@
<string name="sectiondrop">Standard</string>
<string name="sectionpremium">Magic Potion</string>
<string name="sectionquest">Quest</string>
<string name="sectionspecial">Rare</string>
<string name="sectionspecial">Special</string>
<string name="sectionwacky">Wacky</string>
<string name="world_quest">World Quest</string>
<string name="inn_description">Need a break? Check into Daniels Inn to pause some of Habiticas more difficult game mechanics:\n\n
@ -894,4 +894,5 @@
<string name="guild_description">Guild Description</string>
<string name="invite_to_guild">Invite to Guild</string>
<string name="join_guild">Join Guild</string>
<string name="garden">Garden</string>
</resources>

View file

@ -96,7 +96,11 @@ class PetDetailRecyclerAdapter(data: OrderedRealmCollection<Pet>?, autoUpdate: B
fun bind(item: Pet, ownedPet: OwnedPet?) {
this.animal = item
this.ownedPet = ownedPet
this.titleView.text = item.color
if (item.color == "Veggie") {
this.titleView.text = context?.getString(R.string.garden)
} else {
this.titleView.text = item.color
}
this.imageView.alpha = 1.0f
val imageName = "Pet-$itemType-${item.color}"
if (this.ownedPet?.trained ?: 0 > 0) {

View file

@ -87,7 +87,7 @@ class StableRecyclerAdapter : androidx.recyclerview.widget.RecyclerView.Adapter<
"Mount_Icon_" + item.key
}
this.ownedTextView.text = animal?.numberOwned?.toString()
ownedTextView.visibility = if (animal?.numberOwned == 0) View.GONE else View.VISIBLE
ownedTextView.visibility = if (animal?.numberOwned == 0 || animal?.type == "special") View.GONE else View.VISIBLE
imageView.background = null
DataBindingUtils.loadImage(imageName) {
val drawable = BitmapDrawable(context?.resources, if (item.numberOwned > 0) it else it.extractAlpha())

View file

@ -69,6 +69,10 @@ class ContentDeserializer : JsonDeserializer<ContentResult> {
pet.key = petObj.getAsString("key")
pet.text = petObj.getAsString("text")
pet.type = petObj.getAsString("type")
if (pet.type == "special") {
pet.animal = pet.key.split("-")[0]
pet.color = pet.key.split("-")[1]
}
if (pet.type == "premium") {
pet.premium = true
}
@ -84,6 +88,10 @@ class ContentDeserializer : JsonDeserializer<ContentResult> {
mount.color = mountObj.getAsString("potion")
mount.key = mountObj.getAsString("key")
mount.type = mountObj.getAsString("type")
if (mount.type == "special") {
mount.animal = mount.key.split("-")[0]
mount.color = mount.key.split("-")[1]
}
if (mount.type == "premium") {
mount.premium = true
}