mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-22 13:48:55 +00:00
Improve using saddle. Fixes #937
This commit is contained in:
parent
19a2f787dd
commit
74bceccaf4
9 changed files with 40 additions and 22 deletions
BIN
Habitica/res/drawable-hdpi/pet_checkmark.png
Normal file
BIN
Habitica/res/drawable-hdpi/pet_checkmark.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 564 B |
BIN
Habitica/res/drawable-mdpi/pet_checkmark.png
Normal file
BIN
Habitica/res/drawable-mdpi/pet_checkmark.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 379 B |
BIN
Habitica/res/drawable-xhdpi/pet_checkmark.png
Normal file
BIN
Habitica/res/drawable-xhdpi/pet_checkmark.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 716 B |
BIN
Habitica/res/drawable-xxhdpi/pet_checkmark.png
Normal file
BIN
Habitica/res/drawable-xxhdpi/pet_checkmark.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
|
|
@ -60,10 +60,8 @@
|
|||
</RelativeLayout>
|
||||
<ImageView
|
||||
android:id="@+id/checkmark_view"
|
||||
android:layout_width="22dp"
|
||||
android:layout_height="16dp"
|
||||
android:src="@drawable/ic_check"
|
||||
android:tint="@color/brand_300"
|
||||
android:tintMode="src_in"
|
||||
android:layout_width="12dp"
|
||||
android:layout_height="10dp"
|
||||
android:src="@drawable/pet_checkmark"
|
||||
android:layout_gravity="center" />
|
||||
</LinearLayout>
|
||||
|
|
@ -1064,4 +1064,5 @@
|
|||
<string name="unhatched_pet">Unhatched Pet</string>
|
||||
<string name="magic_potions">Magic Potions</string>
|
||||
<string name="magic_potion">Magic Potion</string>
|
||||
<string name="use_saddle">Use Saddle</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -7,11 +7,9 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.TextView
|
||||
import com.facebook.drawee.view.SimpleDraweeView
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.events.commands.FeedCommand
|
||||
import com.habitrpg.android.habitica.extensions.addCloseButton
|
||||
import com.habitrpg.android.habitica.extensions.inflate
|
||||
import com.habitrpg.android.habitica.helpers.RxErrorHandler
|
||||
import com.habitrpg.android.habitica.models.inventory.*
|
||||
|
|
@ -22,7 +20,6 @@ import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils
|
|||
import com.habitrpg.android.habitica.ui.helpers.bindView
|
||||
import com.habitrpg.android.habitica.ui.menu.BottomSheetMenu
|
||||
import com.habitrpg.android.habitica.ui.menu.BottomSheetMenuItem
|
||||
import com.habitrpg.android.habitica.ui.views.dialogs.HabiticaAlertDialog
|
||||
import com.habitrpg.android.habitica.ui.views.dialogs.PetSuggestHatchDialog
|
||||
import io.reactivex.BackpressureStrategy
|
||||
import io.reactivex.Flowable
|
||||
|
|
@ -44,6 +41,7 @@ class PetDetailRecyclerAdapter(data: OrderedRealmCollection<Pet>?, autoUpdate: B
|
|||
private var ownedMounts: Map<String, OwnedMount>? = null
|
||||
private var ownedItems: Map<String, OwnedItem>? = null
|
||||
private val equipEvents = PublishSubject.create<String>()
|
||||
private var ownsSaddles: Boolean = false
|
||||
|
||||
fun getEquipFlowable(): Flowable<String> {
|
||||
return equipEvents.toFlowable(BackpressureStrategy.DROP)
|
||||
|
|
@ -78,6 +76,12 @@ class PetDetailRecyclerAdapter(data: OrderedRealmCollection<Pet>?, autoUpdate: B
|
|||
|
||||
fun setOwnedItems(ownedItems: Map<String, OwnedItem>) {
|
||||
this.ownedItems = ownedItems
|
||||
ownsSaddles = ownedItems.containsKey("Saddle-food")
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
fun setOwnsSaddles(ownsSaddles: Boolean) {
|
||||
this.ownsSaddles = ownsSaddles
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
|
|
@ -133,6 +137,8 @@ class PetDetailRecyclerAdapter(data: OrderedRealmCollection<Pet>?, autoUpdate: B
|
|||
imageView.visibility = View.VISIBLE
|
||||
itemWrapper.visibility = View.GONE
|
||||
checkMarkView.visibility = View.GONE
|
||||
availableWrapper.visibility = View.GONE
|
||||
|
||||
val imageName = "social_Pet-$itemType-${item.color}"
|
||||
itemView.setBackgroundResource(R.drawable.layout_rounded_bg_gray_700)
|
||||
if (this.ownedPet?.trained ?: 0 > 0) {
|
||||
|
|
@ -142,7 +148,6 @@ class PetDetailRecyclerAdapter(data: OrderedRealmCollection<Pet>?, autoUpdate: B
|
|||
} else {
|
||||
this.trainedProgressbar.visibility = View.GONE
|
||||
}
|
||||
availableWrapper.visibility = View.GONE
|
||||
} else {
|
||||
this.trainedProgressbar.visibility = View.GONE
|
||||
this.imageView.alpha = 0.1f
|
||||
|
|
@ -154,10 +159,6 @@ class PetDetailRecyclerAdapter(data: OrderedRealmCollection<Pet>?, autoUpdate: B
|
|||
itemView.setBackgroundResource(R.drawable.layout_rounded_bg_gray_700_brand_border)
|
||||
DataBindingUtils.loadImage(eggView, "Pet_Egg_${item.animal}")
|
||||
DataBindingUtils.loadImage(hatchingPotionView, "Pet_HatchingPotion_${item.color}")
|
||||
} else {
|
||||
availableWrapper.visibility = View.VISIBLE
|
||||
eggAvailableView.alpha = if (hasEgg) 1.0f else 0.2f
|
||||
potionAvailableView.alpha = if (hasPotion) 1.0f else 0.2f
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -188,16 +189,30 @@ class PetDetailRecyclerAdapter(data: OrderedRealmCollection<Pet>?, autoUpdate: B
|
|||
menu.addMenuItem(BottomSheetMenuItem(itemView.resources.getString(R.string.equip)))
|
||||
if (canRaiseToMount) {
|
||||
menu.addMenuItem(BottomSheetMenuItem(itemView.resources.getString(R.string.feed)))
|
||||
if (ownsSaddles) {
|
||||
menu.addMenuItem(BottomSheetMenuItem(itemView.resources.getString(R.string.use_saddle)))
|
||||
}
|
||||
}
|
||||
menu.setSelectionRunnable { index ->
|
||||
if (index == 0) {
|
||||
animal?.let {
|
||||
equipEvents.onNext(it.key)
|
||||
when (index) {
|
||||
0 -> {
|
||||
animal?.let {
|
||||
equipEvents.onNext(it.key)
|
||||
}
|
||||
}
|
||||
1 -> {
|
||||
val event = FeedCommand()
|
||||
event.usingPet = animal
|
||||
EventBus.getDefault().post(event)
|
||||
}
|
||||
2 -> {
|
||||
val event = FeedCommand()
|
||||
event.usingPet = animal
|
||||
val saddle = Food()
|
||||
saddle.key = "Saddle"
|
||||
event.usingFood = saddle
|
||||
EventBus.getDefault().post(event)
|
||||
}
|
||||
} else if (index == 1) {
|
||||
val event = FeedCommand()
|
||||
event.usingPet = animal
|
||||
EventBus.getDefault().post(event)
|
||||
}
|
||||
}
|
||||
menu.show()
|
||||
|
|
|
|||
|
|
@ -220,7 +220,12 @@ class ItemRecyclerFragment : BaseFragment(), androidx.swiperefreshlayout.widget.
|
|||
compositeSubscription.add(inventoryRepository.getOwnedItems(type)
|
||||
.doOnNext { items ->
|
||||
if (items.size > 0) {
|
||||
adapter?.updateData(items)
|
||||
val filteredItems = if (isFeeding) {
|
||||
items.where().notEqualTo("key", "Saddle").findAll()
|
||||
} else {
|
||||
items
|
||||
}
|
||||
adapter?.updateData(filteredItems)
|
||||
}
|
||||
}
|
||||
.map { items -> items.mapNotNull { it.key } }
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import com.habitrpg.android.habitica.models.inventory.HatchingPotion
|
|||
import com.habitrpg.android.habitica.models.inventory.Mount
|
||||
import com.habitrpg.android.habitica.models.inventory.Pet
|
||||
import com.habitrpg.android.habitica.models.user.Items
|
||||
import com.habitrpg.android.habitica.models.user.OwnedItem
|
||||
import com.habitrpg.android.habitica.models.user.OwnedMount
|
||||
import com.habitrpg.android.habitica.models.user.OwnedPet
|
||||
import com.habitrpg.android.habitica.ui.adapter.inventory.PetDetailRecyclerAdapter
|
||||
|
|
|
|||
Loading…
Reference in a new issue