mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
Merge pull request #1538 from alejandro-rios/equip_mount_label_fix
Equip mount label fix
This commit is contained in:
commit
8611351cf0
23 changed files with 102 additions and 41 deletions
|
|
@ -1024,6 +1024,7 @@ Die Quest-Schriftrolle wird an den Quest-Besitzer zurückgegeben.</string>
|
|||
<string name="hatch_pet">Haustier schlüpfen</string>
|
||||
<string name="view_onboarding_tasks">Einstiegsaufgaben ansehen</string>
|
||||
<string name="equip">Ausrüsten</string>
|
||||
<string name="unequip">Unausrüsten</string>
|
||||
<string name="excessItemsNoneLeft">Du hast bereits alles, was Du für alle %s Haustiere benötigst. Bist Du Dir sicher, dass Du %d %ss kaufen willst\?</string>
|
||||
<string name="purchaseX">%d kaufen</string>
|
||||
<string name="excessItemsXLeft">Du brauchst nur %d %s um alle möglichen Haustiere zu schlüpfen. Bist Du Dir sicher, dass Du %d kaufen willst\?</string>
|
||||
|
|
@ -1103,4 +1104,4 @@ Die Quest-Schriftrolle wird an den Quest-Besitzer zurückgegeben.</string>
|
|||
<string name="spooky_promo_info_instructions">Zwischen 29. Oktober und 2. November kannst Du wie gewohnt ein Edelstein-Paket kaufen, Deinem Konto wird aber der Aktions-Betrag Edelsteine hinzugefügt. Mehr Edelsteine zum ausgeben, teilen oder aufsparen für spätere Neuerungen!</string>
|
||||
<string name="view_gem_bundles">Edelstein-Pakete anzeigen</string>
|
||||
<string name="fall_promo_info_prompt">Die Herbstgala ist in vollem Gange. Deshalb haben wir gedacht, dass dies der perfekte Zeitpunkt für den allerersten Edelstein-Sonderverkauf ist! Jetzt bekommst Du mit jedem Einkauf mehr Edelsteine als je zuvor.</string>
|
||||
</resources>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -1041,6 +1041,7 @@
|
|||
<string name="suggest_pet_hatch_missing_egg">You still need a %s Egg to hatch this pet</string>
|
||||
<string name="view_onboarding_tasks">View Onboarding Tasks</string>
|
||||
<string name="equip">Equip</string>
|
||||
<string name="unequip">Unequip</string>
|
||||
<string name="excessItemsNoneLeft">You already have everything you need for all %s pets. Are you sure you want to purchase %d %ss\?</string>
|
||||
<string name="purchaseX">Purchase %d</string>
|
||||
<string name="excessItemsXLeft">You only need %d %s to hatch all possible pets. Are you sure you want to purchase %d\?</string>
|
||||
|
|
|
|||
|
|
@ -905,6 +905,7 @@
|
|||
<string name="suggest_pet_hatch_missing_potion">Aún necesitas una poción %s para eclosionar esta mascota</string>
|
||||
<string name="suggest_pet_hatch_missing_egg">Aún necesitas un huevo %s para eclosionar esta mascota</string>
|
||||
<string name="equip">Equipar</string>
|
||||
<string name="unequip">Desequipar</string>
|
||||
<string name="excessItemsNoneLeft">Ya tienes todo lo que necesitas para todas las mascotas %s. ¿Estás seguro de que quieres comprar %d %ss\?</string>
|
||||
<string name="excess_items">Exceso de objetos</string>
|
||||
<string name="first_drop_title">¡Has encontrado nuevos objetos!</string>
|
||||
|
|
|
|||
|
|
@ -1046,6 +1046,7 @@
|
|||
<string name="suggest_pet_hatch_missing_egg">Vous avez besoin d\'un œuf de %s pour faire éclore ce familier</string>
|
||||
<string name="view_onboarding_tasks">Voir les tâches d’intégration</string>
|
||||
<string name="equip">Équiper</string>
|
||||
<string name="unequip">Déséquiper</string>
|
||||
<string name="excessItemsNoneLeft">Vous avez déjà tout le nécessaire pour tous les familiers %s. Voulez vous vraiment acheter %d %ss \?</string>
|
||||
<string name="purchaseX">Acheter %d</string>
|
||||
<string name="excessItemsXLeft">Vous avez seulement besoin de %d %@s pour faire éclore tous les familiers possibles. Voulez-vous vraiment acheter %d \?</string>
|
||||
|
|
|
|||
|
|
@ -1073,6 +1073,7 @@
|
|||
<string name="suggest_pet_hatch_missing_egg">Hai bisogno di un uovo %s per poter schiudere questo animale</string>
|
||||
<string name="view_onboarding_tasks">Visualizza le attività introduttive</string>
|
||||
<string name="equip">Equipaggia</string>
|
||||
<string name="unequip">Disequip</string>
|
||||
<string name="excessItemsNoneLeft">Hai già tutto il necessario per tutti gli animali %@. Sei sicuro di voler acquistare %d %ss\?</string>
|
||||
<string name="purchaseX">Acquista %d</string>
|
||||
<string name="excessItemsXLeft">Hai solo bisogno di %d %s per schiudere tutti i possibili animali. Sei sicuro di voler acquistare %d\?</string>
|
||||
|
|
@ -1098,4 +1099,4 @@
|
|||
<string name="how_it_works">Come funziona</string>
|
||||
<string name="x_to_y">%s a %s</string>
|
||||
<string name="usually_x_gems">Solitamente %d Gemme</string>
|
||||
</resources>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -1074,6 +1074,7 @@
|
|||
<string name="hatch_pet">ペットをかえす</string>
|
||||
<string name="view_onboarding_tasks">「初心者入門のタスク」を見る</string>
|
||||
<string name="equip">装備</string>
|
||||
<string name="unequip">装備解除</string>
|
||||
<string name="excessItemsNoneLeft">すでに%sペットは全て所有しています。本当に%d%ssを購入しますか?</string>
|
||||
<string name="purchaseX">%dを買う</string>
|
||||
<string name="excessItemsXLeft">今孵せるペットに必要なのは%d%sだけです。本当に%dを購入しますか?</string>
|
||||
|
|
|
|||
|
|
@ -999,6 +999,7 @@
|
|||
<string name="onboardingComplete_achievement_title">Je hebt je Onboarding Taken afgerond!</string>
|
||||
<string name="view_onboarding_tasks">Bekijk Onboarding Taken</string>
|
||||
<string name="equip">Aantrekken</string>
|
||||
<string name="unequip">Niet uitrusten</string>
|
||||
<string name="stat_description">Alle Habitica karakters hebben vier statistieken die ieder invloed hebben op aspecten van de gameplay van Habitica.
|
||||
\n
|
||||
\n**Kracht (KRA)** beïnvloedt voltreffers en verhoogt de schade toegebracht aan Quest Eindbazen. Krijgers en Dieven krijgen extra KRA van hun klasse-specifieke uitrusting.
|
||||
|
|
@ -1023,4 +1024,4 @@
|
|||
\n**Verdien Goud** door taken en kweestes af te ronden, en met sommige klassevaardigheden. Een hogere **Perceptie stat** zorgt voor een hogere goudopbrengst.
|
||||
\n
|
||||
\nAls je een abonnement neemt op Habitica, kun je Goud zelfs gebruiken om een aantal Edelstenen te kopen, gebaseerd op de tijdsduur van je abonnement.</string>
|
||||
</resources>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -1037,6 +1037,7 @@
|
|||
<string name="suggest_pet_hatch_missing_egg">Você ainda precisa de um Ovo de %s para chocar esse mascote</string>
|
||||
<string name="view_onboarding_tasks">Ver Tarefas Iniciais</string>
|
||||
<string name="equip">Equipar</string>
|
||||
<string name="unequip">Desequipar</string>
|
||||
<string name="excessItemsNoneLeft">Você já tem tudo o que precisa para todos os %s mascotes. Você tem certeza que quer comprar %d %ss\?</string>
|
||||
<string name="purchaseX">Comprar %d</string>
|
||||
<string name="excessItemsXLeft">Você só precisa %d %s para chocar todos os mascotes possíveis. Você tem certeza que quer comprar %d\?</string>
|
||||
|
|
@ -1100,4 +1101,4 @@
|
|||
<string name="how_it_works">Como funciona</string>
|
||||
<string name="x_to_y">%s a %s</string>
|
||||
<string name="usually_x_gems">Usualmente %d Gemas</string>
|
||||
</resources>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -914,6 +914,7 @@
|
|||
<string name="magic_potions">Волшебные эликсиры</string>
|
||||
<string name="view_onboarding_tasks">Посмотреть первые задания</string>
|
||||
<string name="equip">Надеть</string>
|
||||
<string name="unequip">Необорудовать</string>
|
||||
<string name="purchaseX">Купить: %d</string>
|
||||
<string name="excess_items">Лишние предметы</string>
|
||||
<string name="onboardingComplete_achievement_title">Вы выполнили свои первые задания!</string>
|
||||
|
|
@ -969,4 +970,4 @@
|
|||
<string name="inbox_messages_title">Вы получили %1$d сообщений от %2$s</string>
|
||||
<string name="delete_reminder">Удалить напоминание</string>
|
||||
<string name="remove">Удалить</string>
|
||||
</resources>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -886,6 +886,7 @@
|
|||
<string name="leave_delete_task">Ayrıl ve Görevi Sil</string>
|
||||
<string name="delete_challenge_task_title">Mücadele Görevi Silinsin mi\?</string>
|
||||
<string name="equip">Yanına Al</string>
|
||||
<string name="unequip">Boşalt</string>
|
||||
<string name="onboardingCompleteDescription">Daha fazlasını istiyorsanız Başarılar\'a göz atın ve toplamaya başlayın!</string>
|
||||
<string name="first_drop_title">Yeni eşyalar buldun!</string>
|
||||
<string name="go_to_items">Eşyalara Git</string>
|
||||
|
|
|
|||
|
|
@ -963,6 +963,7 @@
|
|||
<string name="could_not_find_user">Не можу знайти користувача</string>
|
||||
<string name="wacky">Дивні</string>
|
||||
<string name="equip">Одягнути</string>
|
||||
<string name="unequip">Неоснащення</string>
|
||||
<string name="username_confirmed">Ім\'я користувача підтверджено</string>
|
||||
<string name="username_not_confirmed">Ім\'я користувача не підтверджено</string>
|
||||
<string name="two_handed">Двуручний</string>
|
||||
|
|
|
|||
|
|
@ -1040,6 +1040,7 @@
|
|||
<string name="suggest_pet_hatch_missing_egg">Bạn còn cần một %s Trứng để ấp thú cưng này</string>
|
||||
<string name="view_onboarding_tasks">Xem Công việc Nhập môn</string>
|
||||
<string name="equip">Trang bị</string>
|
||||
<string name="unequip">Giải đáp thắc mắc</string>
|
||||
<string name="excessItemsNoneLeft">Bạn đã có mọi thứ bạn cần cho tất cả %s thú cưng. Bạn có chắc muốn mua %d %ss\?</string>
|
||||
<string name="purchaseX">Mua %d</string>
|
||||
<string name="excessItemsXLeft">Bạn chỉ cần %d %s để ấp tất cả thú cưng mà bạn có thể. Bạn có chắc muốn mua %d\?</string>
|
||||
|
|
@ -1103,4 +1104,4 @@
|
|||
<string name="spooky_promo_info_limitations">Khuyến mãi này chỉ áp dụng trong thời gian giới hạn của sự kiện. Sự kiện này bắt đầu vào ngày 29 tháng Mười lúc 8:00 AM EDT (12:00 UTC) và sẽ kết thúc vào ngày 2 tháng Mười Một vào lúc 8:00 PM EDT (00:00 UTC). Khuyến mãi chỉ áp dụng khi mua Gem cho bản thân bạn.</string>
|
||||
<string name="spooky_promo_info_instructions">Từ ngày 29 tháng 10 đến ngày 2 tháng 11, đơn giản là mua bất kỳ gói Gem nào như thường lệ và tài khoản của bạn sẽ cộng được thêm một khoảng Gem. Thêm nhiều Gem để xài, chia sẻ hay để dành cho những lần ra mắt trong tương lai!</string>
|
||||
<string name="spooky_promo_info_prompt">Chương trình giảm giá Gem trở lại và tiếp diễn đến khi kết thúc Dạ tiệc Mùa Thu! Đây là cơ hội cuối cùng để nhận nhiều Gem hơn bao giờ hết, vì thế hãy mua dự trữ khi chương trình đang diễn ra!</string>
|
||||
</resources>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -1040,6 +1040,7 @@
|
|||
<string name="suggest_pet_hatch_missing_egg">你還需要一個%s寵物蛋來孵化這個寵物任務</string>
|
||||
<string name="view_onboarding_tasks">查看新手任務</string>
|
||||
<string name="equip">裝備</string>
|
||||
<string name="unequip">取消裝備</string>
|
||||
<string name="excessItemsNoneLeft">你已經有得到所有%s寵物所需的一切物品。你確定你要買%d個%s?</string>
|
||||
<string name="purchaseX">買%d個</string>
|
||||
<string name="excessItemsXLeft">你只需要%d個%s即可孵化所有可得到的這種寵物。你確定你想要買%d個?</string>
|
||||
|
|
@ -1084,4 +1085,4 @@
|
|||
<string name="leave_delte_tasks">退出挑戰,並刪除挑戰任務</string>
|
||||
<string name="leave_keep_tasks">退出挑戰,並保留挑戰任務</string>
|
||||
<string name="challenge_leave_description">在退出挑戰之後,你可以在自己的任務列表裡保留參加挑戰時的任務,也可以刪除它們</string>
|
||||
</resources>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -1018,6 +1018,7 @@
|
|||
<string name="suggest_pet_hatch_missing_egg">你还需要一个%s宠物蛋来孵化这个宠物</string>
|
||||
<string name="view_onboarding_tasks">查看新手任务</string>
|
||||
<string name="equip">装备</string>
|
||||
<string name="unequip">取消装备</string>
|
||||
<string name="excessItemsNoneLeft">你已经有得到所有%s宠物所需的一切物品。你确定你要买%d个%s?</string>
|
||||
<string name="excessItemsXLeft">你只需要%d个%s即可孵化所有可得到的这种宠物。你确定你想要买%d个?</string>
|
||||
<string name="purchaseX">买%d个</string>
|
||||
|
|
@ -1101,4 +1102,4 @@
|
|||
<string name="how_it_works">如何工作</string>
|
||||
<string name="x_to_y">%s到%s</string>
|
||||
<string name="usually_x_gems">通常%d颗宝石</string>
|
||||
</resources>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -1061,6 +1061,7 @@
|
|||
<string name="purchaseX">Purchase %d</string>
|
||||
<string name="excessItemsNoneLeft">You already have everything you need for all %s pets. Are you sure you want to purchase %d %ss?</string>
|
||||
<string name="equip">Equip</string>
|
||||
<string name="unequip">Unequip</string>
|
||||
<string name="view_onboarding_tasks">View Onboarding Tasks</string>
|
||||
<string name="suggest_pet_hatch_missing_egg">You still need a %s Egg to hatch this pet</string>
|
||||
<string name="suggest_pet_hatch_missing_potion">You still need a %s Potion to hatch this pet</string>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import android.view.ViewGroup
|
|||
import com.habitrpg.android.habitica.models.inventory.Mount
|
||||
import com.habitrpg.android.habitica.models.inventory.StableSection
|
||||
import com.habitrpg.android.habitica.models.user.OwnedMount
|
||||
import com.habitrpg.android.habitica.models.user.User
|
||||
import com.habitrpg.android.habitica.ui.viewHolders.MountViewHolder
|
||||
import com.habitrpg.android.habitica.ui.viewHolders.SectionViewHolder
|
||||
import io.reactivex.rxjava3.core.BackpressureStrategy
|
||||
|
|
@ -14,6 +15,7 @@ class MountDetailRecyclerAdapter : androidx.recyclerview.widget.RecyclerView.Ada
|
|||
private var ownedMounts: Map<String, OwnedMount>? = null
|
||||
|
||||
private val equipEvents = PublishSubject.create<String>()
|
||||
private var user: User? = null
|
||||
|
||||
private var itemList: List<Any> = ArrayList()
|
||||
|
||||
|
|
@ -35,7 +37,7 @@ class MountDetailRecyclerAdapter : androidx.recyclerview.widget.RecyclerView.Ada
|
|||
override fun onBindViewHolder(holder: androidx.recyclerview.widget.RecyclerView.ViewHolder, position: Int) {
|
||||
when (val obj = this.itemList[position]) {
|
||||
is StableSection -> (holder as? SectionViewHolder)?.bind(obj)
|
||||
is Mount -> (holder as? MountViewHolder)?.bind(obj, ownedMounts?.get(obj.key ?: "")?.owned == true)
|
||||
is Mount -> (holder as? MountViewHolder)?.bind(obj, ownedMounts?.get(obj.key ?: "")?.owned == true, user)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -47,4 +49,9 @@ class MountDetailRecyclerAdapter : androidx.recyclerview.widget.RecyclerView.Ada
|
|||
this.ownedMounts = ownedMounts
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
fun setUser(user: User) {
|
||||
this.user = user
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.habitrpg.android.habitica.models.inventory.*
|
|||
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.models.user.User
|
||||
import com.habitrpg.android.habitica.ui.viewHolders.PetViewHolder
|
||||
import com.habitrpg.android.habitica.ui.viewHolders.SectionViewHolder
|
||||
import io.reactivex.rxjava3.core.BackpressureStrategy
|
||||
|
|
@ -17,6 +18,7 @@ class PetDetailRecyclerAdapter : androidx.recyclerview.widget.RecyclerView.Adapt
|
|||
private var ownedPets: Map<String, OwnedPet>? = null
|
||||
private var ownedMounts: Map<String, OwnedMount>? = null
|
||||
private var ownedItems: Map<String, OwnedItem>? = null
|
||||
private var user: User? = null
|
||||
private val equipEvents = PublishSubject.create<String>()
|
||||
private var ownsSaddles: Boolean = false
|
||||
|
||||
|
|
@ -27,6 +29,11 @@ class PetDetailRecyclerAdapter : androidx.recyclerview.widget.RecyclerView.Adapt
|
|||
this.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
fun setUser(user: User) {
|
||||
this.user = user
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
fun getEquipFlowable(): Flowable<String> {
|
||||
return equipEvents.toFlowable(BackpressureStrategy.DROP)
|
||||
}
|
||||
|
|
@ -69,7 +76,8 @@ class PetDetailRecyclerAdapter : androidx.recyclerview.widget.RecyclerView.Adapt
|
|||
ownsSaddles,
|
||||
ownedItems?.get(obj.animal + "-eggs") != null,
|
||||
ownedItems?.get(obj.color + "-hatchingPotions") != null,
|
||||
ownedMounts?.containsKey(obj.key) == true
|
||||
ownedMounts?.containsKey(obj.key) == true,
|
||||
user
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ import com.habitrpg.android.habitica.extensions.inflate
|
|||
import com.habitrpg.android.habitica.helpers.MainNavigationController
|
||||
import com.habitrpg.android.habitica.models.inventory.*
|
||||
import com.habitrpg.android.habitica.models.user.OwnedItem
|
||||
import com.habitrpg.android.habitica.models.user.User
|
||||
import com.habitrpg.android.habitica.models.user.OwnedMount
|
||||
import com.habitrpg.android.habitica.models.user.OwnedPet
|
||||
import com.habitrpg.android.habitica.ui.fragments.inventory.stable.StableFragmentDirections
|
||||
import com.habitrpg.android.habitica.ui.helpers.loadImage
|
||||
import com.habitrpg.android.habitica.ui.viewHolders.MountViewHolder
|
||||
|
|
@ -32,17 +32,23 @@ class StableRecyclerAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
|||
private var eggs: Map<String, Egg> = mapOf()
|
||||
var animalIngredientsRetriever: ((Animal, ((Pair<Egg?, HatchingPotion?>) -> Unit)) -> Unit)? = null
|
||||
var itemType: String? = null
|
||||
private var user: User? = null
|
||||
private val equipEvents = PublishSubject.create<String>()
|
||||
|
||||
private var existingMounts: RealmResults<Mount>? = null
|
||||
private var ownedMounts: Map<String, OwnedMount>? = null
|
||||
private var ownedItems: Map<String, OwnedItem>? = null
|
||||
private var ownsSaddles: Boolean = false
|
||||
private var itemList: List<Any> = ArrayList()
|
||||
|
||||
fun getEquipFlowable(): Flowable<String> {
|
||||
return equipEvents.toFlowable(BackpressureStrategy.DROP)
|
||||
}
|
||||
|
||||
fun setUser(user: User){
|
||||
this.user = user
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
private fun canRaiseToMount(pet: Pet): Boolean {
|
||||
for (mount in existingMounts ?: emptyList<Mount>()) {
|
||||
if (mount.key == pet.key) {
|
||||
|
|
@ -55,6 +61,7 @@ class StableRecyclerAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
|||
private fun eggCount(pet: Pet): Int {
|
||||
return ownedItems?.get(pet.animal + "-eggs")?.numberOwned ?: 0
|
||||
}
|
||||
|
||||
private fun potionCount(pet: Pet): Int {
|
||||
return ownedItems?.get(pet.color + "-hatchingPotions")?.numberOwned ?: 0
|
||||
}
|
||||
|
|
@ -75,11 +82,9 @@ class StableRecyclerAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
|||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
private var itemList: List<Any> = ArrayList()
|
||||
|
||||
fun setItemList(itemList: List<Any>) {
|
||||
this.itemList = itemList
|
||||
this.notifyDataSetChanged()
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder =
|
||||
|
|
@ -107,17 +112,20 @@ class StableRecyclerAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
|||
val isIndividualAnimal = item.type == "special" || item.type == "wacky"
|
||||
if (isIndividualAnimal) {
|
||||
if (item is Pet) {
|
||||
(holder as? PetViewHolder)?.bind(item,
|
||||
item.numberOwned,
|
||||
eggCount(item),
|
||||
potionCount(item),
|
||||
canRaiseToMount(item),
|
||||
ownsSaddles,
|
||||
ownedItems?.get(item.animal + "-eggs") != null,
|
||||
ownedItems?.get(item.color + "-hatchingPotions") != null,
|
||||
ownedMounts?.containsKey(item.key) == true)
|
||||
(holder as? PetViewHolder)?.bind(
|
||||
item = item,
|
||||
trained = item.numberOwned,
|
||||
eggCount = eggCount(item),
|
||||
potionCount = potionCount(item),
|
||||
canRaiseToMount = canRaiseToMount(item),
|
||||
ownsSaddles = ownsSaddles,
|
||||
hasUnlockedEgg = ownedItems?.get(item.animal + "-eggs") != null,
|
||||
hasUnlockedPotion = ownedItems?.get(item.color + "-hatchingPotions") != null,
|
||||
hasMount = ownedMounts?.containsKey(item.key) == true,
|
||||
user = user
|
||||
)
|
||||
} else if (item is Mount) {
|
||||
(holder as? MountViewHolder)?.bind(item, item.numberOwned > 0)
|
||||
(holder as? MountViewHolder)?.bind(item, item.numberOwned > 0, user)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
@ -153,6 +161,7 @@ class StableRecyclerAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
|||
}
|
||||
|
||||
override fun getItemCount(): Int = itemList.size
|
||||
|
||||
fun setEggs(eggs: Map<String, Egg>) {
|
||||
this.eggs = eggs
|
||||
notifyDataSetChanged()
|
||||
|
|
|
|||
|
|
@ -84,7 +84,9 @@ class MountDetailRecyclerFragment : BaseMainFragment<FragmentRecyclerviewBinding
|
|||
this.loadItems()
|
||||
|
||||
adapter?.getEquipFlowable()?.flatMap { key -> inventoryRepository.equip(user, "mount", key) }
|
||||
?.subscribe({ }, RxErrorHandler.handleEmptyError())?.let { compositeSubscription.add(it) }
|
||||
?.subscribe({
|
||||
user?.let { updatedUser -> adapter?.setUser(updatedUser) }
|
||||
}, RxErrorHandler.handleEmptyError())?.let { compositeSubscription.add(it) }
|
||||
}
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
|
|
@ -124,6 +126,7 @@ class MountDetailRecyclerFragment : BaseMainFragment<FragmentRecyclerviewBinding
|
|||
return@map mountMap
|
||||
}.doOnNext {
|
||||
adapter?.setOwnedMounts(it)
|
||||
user?.let { updatedUser -> adapter?.setUser(updatedUser) }
|
||||
}, { unsortedAnimals, ownedAnimals ->
|
||||
val items = mutableListOf<Any>()
|
||||
var lastMount: Mount? = null
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import com.habitrpg.android.habitica.ui.fragments.BaseMainFragment
|
|||
import com.habitrpg.android.habitica.ui.fragments.inventory.items.ItemRecyclerFragment
|
||||
import com.habitrpg.android.habitica.ui.helpers.MarginDecoration
|
||||
import com.habitrpg.android.habitica.ui.helpers.SafeDefaultItemAnimator
|
||||
import io.reactivex.rxjava3.core.Flowable
|
||||
import io.reactivex.rxjava3.core.Maybe
|
||||
import io.reactivex.rxjava3.kotlin.Flowables
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
|
|
@ -104,7 +103,9 @@ class PetDetailRecyclerFragment : BaseMainFragment<FragmentRecyclerviewBinding>(
|
|||
|
||||
compositeSubscription.add(adapter.getEquipFlowable()
|
||||
.flatMap { key -> inventoryRepository.equip(user, "pet", key) }
|
||||
.subscribe({ }, RxErrorHandler.handleEmptyError()))
|
||||
.subscribe({
|
||||
user?.let { updatedUser -> adapter.setUser(updatedUser) }
|
||||
}, RxErrorHandler.handleEmptyError()))
|
||||
|
||||
|
||||
view.post { setGridSpanCount(view.width) }
|
||||
|
|
@ -151,6 +152,7 @@ class PetDetailRecyclerFragment : BaseMainFragment<FragmentRecyclerviewBinding>(
|
|||
return@map petMap
|
||||
}.doOnNext {
|
||||
adapter.setOwnedPets(it)
|
||||
user?.let { updatedUser -> adapter.setUser(updatedUser) }
|
||||
}).map {
|
||||
val items = mutableListOf<Any>()
|
||||
var lastPet: Pet? = null
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ class StableRecyclerFragment : BaseFragment<FragmentRecyclerviewBinding>() {
|
|||
adapter = binding?.recyclerView?.adapter as? StableRecyclerAdapter
|
||||
if (adapter == null) {
|
||||
adapter = StableRecyclerAdapter()
|
||||
user?.let { adapter?.setUser(it) }
|
||||
adapter?.animalIngredientsRetriever = { animal, callback ->
|
||||
Maybe.zip(
|
||||
inventoryRepository.getItems(Egg::class.java, arrayOf(animal.animal)).firstElement(),
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import com.habitrpg.android.habitica.databinding.MountOverviewItemBinding
|
|||
import com.habitrpg.android.habitica.extensions.inflate
|
||||
import com.habitrpg.android.habitica.helpers.RxErrorHandler
|
||||
import com.habitrpg.android.habitica.models.inventory.Mount
|
||||
import com.habitrpg.android.habitica.models.user.User
|
||||
import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils
|
||||
import com.habitrpg.android.habitica.ui.menu.BottomSheetMenu
|
||||
import com.habitrpg.android.habitica.ui.menu.BottomSheetMenuItem
|
||||
|
|
@ -20,6 +21,7 @@ class MountViewHolder(parent: ViewGroup, private val equipEvents: PublishSubject
|
|||
private var binding: MountOverviewItemBinding = MountOverviewItemBinding.bind(itemView)
|
||||
private var owned: Boolean = false
|
||||
var animal: Mount? = null
|
||||
private var user: User? = null
|
||||
|
||||
var resources: Resources = itemView.resources
|
||||
|
||||
|
|
@ -27,9 +29,10 @@ class MountViewHolder(parent: ViewGroup, private val equipEvents: PublishSubject
|
|||
itemView.setOnClickListener(this)
|
||||
}
|
||||
|
||||
fun bind(item: Mount, owned: Boolean) {
|
||||
fun bind(item: Mount, owned: Boolean, user: User?) {
|
||||
animal = item
|
||||
this.owned = owned
|
||||
this.user = user
|
||||
binding.titleTextView.visibility = View.GONE
|
||||
binding.ownedTextView.visibility = View.GONE
|
||||
val imageName = "stable_Mount_Icon_" + item.animal + "-" + item.color
|
||||
|
|
@ -54,10 +57,13 @@ class MountViewHolder(parent: ViewGroup, private val equipEvents: PublishSubject
|
|||
}
|
||||
val menu = BottomSheetMenu(itemView.context)
|
||||
menu.setTitle(animal?.text)
|
||||
menu.addMenuItem(BottomSheetMenuItem(resources.getString(R.string.equip)))
|
||||
|
||||
val hasCurrentMount = user?.currentMount.equals(animal?.key)
|
||||
val labelId = if (hasCurrentMount) R.string.unequip else R.string.equip
|
||||
menu.addMenuItem(BottomSheetMenuItem(resources.getString(labelId)))
|
||||
menu.setSelectionRunnable {
|
||||
animal?.let { equipEvents.onNext(it.key ?: "") }
|
||||
}
|
||||
menu.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import com.habitrpg.android.habitica.events.commands.FeedCommand
|
|||
import com.habitrpg.android.habitica.extensions.inflate
|
||||
import com.habitrpg.android.habitica.helpers.RxErrorHandler
|
||||
import com.habitrpg.android.habitica.models.inventory.*
|
||||
import com.habitrpg.android.habitica.models.user.User
|
||||
import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils
|
||||
import com.habitrpg.android.habitica.ui.menu.BottomSheetMenu
|
||||
import com.habitrpg.android.habitica.ui.menu.BottomSheetMenuItem
|
||||
|
|
@ -27,6 +28,7 @@ class PetViewHolder(parent: ViewGroup, private val equipEvents: PublishSubject<S
|
|||
private var potionCount: Int = 0
|
||||
private var ownsSaddles = false
|
||||
private var animal: Pet? = null
|
||||
private var user: User? = null
|
||||
|
||||
private var binding: PetDetailItemBinding = PetDetailItemBinding.bind(itemView)
|
||||
|
||||
|
|
@ -41,15 +43,18 @@ class PetViewHolder(parent: ViewGroup, private val equipEvents: PublishSubject<S
|
|||
itemView.setOnClickListener(this)
|
||||
}
|
||||
|
||||
fun bind(item: Pet,
|
||||
trained: Int,
|
||||
eggCount: Int,
|
||||
potionCount: Int,
|
||||
canRaiseToMount: Boolean,
|
||||
ownsSaddles: Boolean,
|
||||
hasUnlockedEgg: Boolean,
|
||||
hasUnlockedPotion: Boolean,
|
||||
hasMount: Boolean) {
|
||||
fun bind(
|
||||
item: Pet,
|
||||
trained: Int,
|
||||
eggCount: Int,
|
||||
potionCount: Int,
|
||||
canRaiseToMount: Boolean,
|
||||
ownsSaddles: Boolean,
|
||||
hasUnlockedEgg: Boolean,
|
||||
hasUnlockedPotion: Boolean,
|
||||
hasMount: Boolean,
|
||||
user: User?
|
||||
) {
|
||||
this.animal = item
|
||||
isOwned = trained > 0
|
||||
binding.imageView.alpha = 1.0f
|
||||
|
|
@ -60,6 +65,7 @@ class PetViewHolder(parent: ViewGroup, private val equipEvents: PublishSubject<S
|
|||
this.hasUnlockedEgg = hasUnlockedEgg
|
||||
this.hasUnlockedPotion = hasUnlockedPotion
|
||||
this.hasMount = hasMount
|
||||
this.user = user
|
||||
binding.imageView.visibility = View.VISIBLE
|
||||
binding.itemWrapper.visibility = View.GONE
|
||||
binding.checkmarkView.visibility = View.GONE
|
||||
|
|
@ -111,7 +117,11 @@ class PetViewHolder(parent: ViewGroup, private val equipEvents: PublishSubject<S
|
|||
val context = itemView.context
|
||||
val menu = BottomSheetMenu(context)
|
||||
menu.setTitle(animal?.text)
|
||||
menu.addMenuItem(BottomSheetMenuItem(itemView.resources.getString(R.string.equip)))
|
||||
|
||||
val hasCurrentPet = user?.currentPet.equals(animal?.key)
|
||||
val labelId = if (hasCurrentPet) R.string.unequip else R.string.equip
|
||||
menu.addMenuItem(BottomSheetMenuItem(itemView.resources.getString(labelId)))
|
||||
|
||||
if (canRaiseToMount) {
|
||||
menu.addMenuItem(BottomSheetMenuItem(itemView.resources.getString(R.string.feed)))
|
||||
if (ownsSaddles) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue