mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-20 20:59:00 +00:00
improve shop display
This commit is contained in:
parent
f9b867964b
commit
bcdd016690
6 changed files with 19 additions and 8 deletions
|
|
@ -157,7 +157,7 @@ public class ShopItem extends RealmObject {
|
|||
}
|
||||
|
||||
public boolean isTypeItem() {
|
||||
return "eggs".equals(purchaseType) || "hatchingPotions".equals(purchaseType) || "food".equals(purchaseType);
|
||||
return "eggs".equals(purchaseType) || "hatchingPotions".equals(purchaseType) || "food".equals(purchaseType) || "armoire".equals(purchaseType) || "potion".equals(purchaseType);
|
||||
}
|
||||
|
||||
public boolean isTypeQuest() {
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import com.habitrpg.android.habitica.models.inventory.Item;
|
|||
import com.habitrpg.android.habitica.models.shops.Shop;
|
||||
import com.habitrpg.android.habitica.models.shops.ShopCategory;
|
||||
import com.habitrpg.android.habitica.models.shops.ShopItem;
|
||||
import com.habitrpg.android.habitica.models.user.User;
|
||||
import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils;
|
||||
import com.habitrpg.android.habitica.ui.viewHolders.SectionViewHolder;
|
||||
import com.habitrpg.android.habitica.ui.viewHolders.ShopItemViewHolder;
|
||||
|
|
@ -51,6 +52,7 @@ public class ShopRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
private String shopIdentifier;
|
||||
private Map<String, Item> ownedItems = new HashMap<>();
|
||||
private String shopSpriteSuffix;
|
||||
private User user;
|
||||
|
||||
public void setShop(Shop shop, String shopSpriteSuffix) {
|
||||
this.shopSpriteSuffix = shopSpriteSuffix;
|
||||
|
|
@ -99,7 +101,7 @@ public class ShopRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
((SectionViewHolder) holder).bind(((ShopCategory) obj).getText());
|
||||
} else {
|
||||
ShopItem item = (ShopItem) items.get(position);
|
||||
((ShopItemViewHolder) holder).bind(item);
|
||||
((ShopItemViewHolder) holder).bind(item, item.canBuy(user));
|
||||
if (ownedItems.containsKey(item.getKey())) {
|
||||
((ShopItemViewHolder) holder).setItemCount(ownedItems.get(item.getKey()).getOwned());
|
||||
}
|
||||
|
|
@ -142,6 +144,11 @@ public class ShopRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
this.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
this.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
static class ShopHeaderViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final Context context;
|
||||
|
|
|
|||
|
|
@ -53,9 +53,11 @@ public class RewardsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
|
|||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
if (customRewards != null && position < customRewards.size()) {
|
||||
((RewardViewHolder)holder).bindHolder(customRewards.get(position), position);
|
||||
Task reward = customRewards.get(position);
|
||||
((RewardViewHolder)holder).bindHolder(reward, position, reward.value < user.getStats().getGp());
|
||||
} else if (inAppRewards != null) {
|
||||
((ShopItemViewHolder)holder).bind(inAppRewards.get(position-getCustomRewardCount()));
|
||||
ShopItem item = inAppRewards.get(position-getCustomRewardCount());
|
||||
((ShopItemViewHolder)holder).bind(item, item.canBuy(user));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ public class ShopFragment extends BaseFragment {
|
|||
} else {
|
||||
adapter.setShop(shop, configManager.shopSpriteSuffix());
|
||||
}
|
||||
adapter.setUser(user);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,8 @@ package com.habitrpg.android.habitica.ui.viewHolders;
|
|||
import android.content.Context;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
|
|
@ -57,7 +55,7 @@ public class ShopItemViewHolder extends RecyclerView.ViewHolder implements View.
|
|||
countDrawable = new BitmapDrawable(context.getResources(), HabiticaIconsHelper.imageOfItemIndicatorNumber());
|
||||
}
|
||||
|
||||
public void bind(ShopItem item) {
|
||||
public void bind(ShopItem item, boolean canBuy) {
|
||||
this.item = item;
|
||||
buyButton.setVisibility(View.VISIBLE);
|
||||
|
||||
|
|
@ -80,7 +78,7 @@ public class ShopItemViewHolder extends RecyclerView.ViewHolder implements View.
|
|||
itemDetailIndicator.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
priceLabel.setLocked(item.getLocked());
|
||||
priceLabel.setLocked(item.getLocked() || !canBuy);
|
||||
if (item.getLocked()) {
|
||||
itemDetailIndicator.setBackground(lockedDrawable);
|
||||
itemDetailIndicator.setVisibility(View.VISIBLE);
|
||||
|
|
|
|||
|
|
@ -89,4 +89,7 @@ public class RewardViewHolder extends BaseTaskViewHolder {
|
|||
this.buyButton.setEnabled(!taskActionsDisabled);
|
||||
}
|
||||
|
||||
public void bindHolder(Task reward, int position, boolean canBuy) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue