mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
Fix showing pin button. Fixes #1194
This commit is contained in:
parent
028f5c0d01
commit
3915eeacbf
4 changed files with 10 additions and 7 deletions
|
|
@ -10,8 +10,8 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingLeft="12dp"
|
||||
android:paddingRight="12dp"
|
||||
android:background="@color/gray_700">
|
||||
<Button
|
||||
android:id="@+id/pin_button"
|
||||
|
|
@ -20,7 +20,8 @@
|
|||
android:maxLines="1"
|
||||
android:text="@string/pin"
|
||||
android:background="@color/transparent"
|
||||
android:layout_gravity="center_vertical"/>
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="start|center_vertical"/>
|
||||
<androidx.legacy.widget.Space
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ class ShopFragment : BaseFragment() {
|
|||
compositeSubscription.add(this.inventoryRepository.getOwnedItems()
|
||||
.subscribe(Consumer { adapter?.setOwnedItems(it) }, RxErrorHandler.handleEmptyError()))
|
||||
compositeSubscription.add(this.inventoryRepository.getInAppRewards()
|
||||
.map<List<String>> { rewards -> rewards.map { it.key } }
|
||||
.map { rewards -> rewards.map { it.key } }
|
||||
.subscribe(Consumer { adapter?.setPinnedItemKeys(it) }, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ package com.habitrpg.android.habitica.ui.viewHolders
|
|||
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.facebook.drawee.view.SimpleDraweeView
|
||||
import com.habitrpg.android.habitica.HabiticaBaseApplication
|
||||
import com.habitrpg.android.habitica.R
|
||||
|
|
@ -92,7 +92,7 @@ class ShopItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), Vi
|
|||
|
||||
override fun onClick(view: View) {
|
||||
val item = item
|
||||
if (item != null) {
|
||||
if (item != null && item.isValid) {
|
||||
val dialog = PurchaseDialog(context, HabiticaBaseApplication.userComponent, item)
|
||||
dialog.shopIdentifier = shopIdentifier
|
||||
dialog.isPinned = isPinned
|
||||
|
|
|
|||
|
|
@ -122,9 +122,11 @@ class PurchaseDialog(context: Context, component: UserComponent?, val item: Shop
|
|||
field = value
|
||||
if (isPinned) {
|
||||
pinButton.setCompoundDrawablesWithIntrinsicBounds(BitmapDrawable(context.resources, HabiticaIconsHelper.imageOfUnpinItem()), null, null, null)
|
||||
pinButton.setTextColor(ContextCompat.getColor(context, R.color.red_10))
|
||||
pinButton.text = context.getText(R.string.unpin)
|
||||
} else {
|
||||
pinButton.setCompoundDrawablesWithIntrinsicBounds(BitmapDrawable(context.resources, HabiticaIconsHelper.imageOfPinItem()), null, null, null)
|
||||
pinButton.setTextColor(ContextCompat.getColor(context, R.color.brand_300))
|
||||
pinButton.text = context.getText(R.string.pin)
|
||||
}
|
||||
}
|
||||
|
|
@ -143,7 +145,6 @@ class PurchaseDialog(context: Context, component: UserComponent?, val item: Shop
|
|||
priceLabel = buyButton.findViewById(R.id.priceLabel)
|
||||
buyLabel = buyButton.findViewById(R.id.buy_label)
|
||||
pinButton.setOnClickListener { inventoryRepository.togglePinnedItem(shopItem).subscribe(Consumer { isPinned = !this.isPinned }, RxErrorHandler.handleEmptyError()) }
|
||||
pinButton.visibility = View.GONE
|
||||
|
||||
shopItem = item
|
||||
|
||||
|
|
@ -172,6 +173,7 @@ class PurchaseDialog(context: Context, component: UserComponent?, val item: Shop
|
|||
}
|
||||
}
|
||||
|
||||
buyButton.elevation = 0f;
|
||||
if (shopItem.canAfford(user)) {
|
||||
buyButton.background = context.getDrawable(R.drawable.button_background_primary)
|
||||
priceLabel.setTextColor(ContextCompat.getColor(context, R.color.white))
|
||||
|
|
|
|||
Loading…
Reference in a new issue