mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-21 05:09:00 +00:00
Enable pinning of background shop items
# Conflicts: # Habitica/src/main/java/com/habitrpg/android/habitica/models/shops/ShopItem.kt
This commit is contained in:
parent
ec20a0fc52
commit
dce7cbc450
5 changed files with 28 additions and 3 deletions
|
|
@ -22,8 +22,8 @@
|
|||
android:paddingEnd="8dp">
|
||||
<ImageView
|
||||
android:id="@+id/pin_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="@dimen/shopitem_status_size"
|
||||
android:layout_height="@dimen/shopitem_status_size"
|
||||
android:layout_marginEnd="6dp"/>
|
||||
<TextView
|
||||
android:id="@+id/pin_text"
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ class UserRepositoryImpl(
|
|||
}
|
||||
|
||||
override fun unlockPath(customization: Customization): Flowable<UnlockResponse> {
|
||||
return unlockPath(customization.path, customization.price ?: 0)
|
||||
return unlockPath(customization.unlockPath, customization.price ?: 0)
|
||||
}
|
||||
|
||||
override fun runCron() {
|
||||
|
|
|
|||
|
|
@ -78,6 +78,18 @@ open class Customization : RealmObject(), BaseObject {
|
|||
}
|
||||
|
||||
val path: String
|
||||
get() {
|
||||
var path = if (type == "background") "backgrounds" else type
|
||||
if (this.customizationSet != null) {
|
||||
path = path + "." + this.customizationSet
|
||||
} else if (this.category != null) {
|
||||
path = path + "." + this.category
|
||||
}
|
||||
path = "$path.$identifier"
|
||||
return path
|
||||
}
|
||||
|
||||
val unlockPath: String
|
||||
get() {
|
||||
var path = type
|
||||
if (this.category != null) {
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ class CustomizationRecyclerViewAdapter() : androidx.recyclerview.widget.Recycler
|
|||
}
|
||||
|
||||
var ownedCustomizations: List<String> = listOf()
|
||||
private var pinnedItemKeys: List<String> = ArrayList()
|
||||
|
||||
private val selectCustomizationEvents = PublishSubject.create<Customization>()
|
||||
|
||||
|
|
@ -143,6 +144,11 @@ class CustomizationRecyclerViewAdapter() : androidx.recyclerview.widget.Recycler
|
|||
return selectCustomizationEvents.toFlowable(BackpressureStrategy.DROP)
|
||||
}
|
||||
|
||||
fun setPinnedItemKeys(pinnedItemKeys: List<String>) {
|
||||
this.pinnedItemKeys = pinnedItemKeys
|
||||
if (customizationList.size > 0) this.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
internal inner class CustomizationViewHolder(itemView: View) : androidx.recyclerview.widget.RecyclerView.ViewHolder(itemView), View.OnClickListener {
|
||||
|
||||
private val binding = CustomizationGridItemBinding.bind(itemView)
|
||||
|
|
@ -194,6 +200,7 @@ class CustomizationRecyclerViewAdapter() : androidx.recyclerview.widget.Recycler
|
|||
} else {
|
||||
customization?.let {
|
||||
val dialog = PurchaseDialog(itemView.context, HabiticaBaseApplication.userComponent, ShopItem.fromCustomization(it, userSize, hairColor))
|
||||
if (it.type == "background") dialog.isPinned = pinnedItemKeys.contains(ShopItem.fromCustomization(it, userSize, hairColor).key)
|
||||
dialog.show()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,6 +87,12 @@ class AvatarCustomizationFragment :
|
|||
.subscribe({ }, RxErrorHandler.handleEmptyError())
|
||||
)
|
||||
|
||||
compositeSubscription.add(
|
||||
this.inventoryRepository.getInAppRewards()
|
||||
.map { rewards -> rewards.map { it.key } }
|
||||
.subscribe({ adapter.setPinnedItemKeys(it) }, RxErrorHandler.handleEmptyError())
|
||||
)
|
||||
|
||||
return super.onCreateView(inflater, container, savedInstanceState)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue