Commit ccd30fe9 authored by qq247321453's avatar qq247321453

getCardCode

parent 8a4e09d8
......@@ -129,8 +129,12 @@ public class CardLoader implements ICardSearcher {
List<Card> list = new ArrayList<>();
for (int i = 0; i < cards.size(); i++) {
Card card = cards.valueAt(i);
if (inCards != null && (!inCards.contains(card.Code) && !inCards.contains(card.Alias))) {
continue;
if (inCards != null) {
if(inCards.contains(card.Code) || (card.Alias != 0 && inCards.contains(card.Alias))){
//在范围内
} else {
continue;
}
}
if (searchInfo == null || searchInfo.isValid(card)) {
list.add(card);
......
......@@ -40,6 +40,7 @@ import cn.garymb.ygomobile.lite.R;
import cn.garymb.ygomobile.utils.FileUtils;
import cn.garymb.ygomobile.utils.IOUtils;
import cn.garymb.ygomobile.utils.NetUtils;
import ocgcore.data.Card;
import static com.bumptech.glide.Glide.with;
......@@ -235,6 +236,15 @@ public class ImageLoader implements Closeable {
}
}
public void bindImage(ImageView imageview, Card card, @NonNull Type type) {
if(card == null){
imageview.setImageResource(R.drawable.unknown);
} else {
bindImage(imageview, card.Code, null, type);
}
}
@Deprecated
public void bindImage(ImageView imageview, long code, @NonNull Type type) {
bindImage(imageview, code, null, type);
}
......
......@@ -105,7 +105,7 @@ public class CardListAdapter extends BaseRecyclerAdapterPlus<Card, ViewHolder> i
if(item == null){
return;
}
imageLoader.bindImage(holder.cardImage, item.Code, ImageLoader.Type.list);
imageLoader.bindImage(holder.cardImage, item, ImageLoader.Type.list);
holder.cardName.setText(item.Name);
if (item.isType(CardType.Monster)) {
holder.layout_atk.setVisibility(View.VISIBLE);
......@@ -171,12 +171,7 @@ public class CardListAdapter extends BaseRecyclerAdapterPlus<Card, ViewHolder> i
//卡片类型
holder.cardType.setText(CardUtils.getAllTypeString(item, mStringManager));
if (holder.codeView != null) {
int t = item.Alias - item.Code;
if (t > 10 || t < -10) {
holder.codeView.setText(String.format("%08d", item.Code));
} else {
holder.codeView.setText(String.format("%08d", item.Alias));
}
holder.codeView.setText(String.format("%08d", item.getCardCode()));
}
bindMenu(holder, position);
}
......
......@@ -103,8 +103,8 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
isDownloadCardImage = true;
ll_bar.startAnimation(AnimationUtils.loadAnimation(context, R.anim.out_from_bottom));
ll_bar.setVisibility(View.GONE);
imageLoader.bindImage(photoView, msg.arg1, null, ImageLoader.Type.origin);
imageLoader.bindImage(cardImage, msg.arg1, null, ImageLoader.Type.detail);
imageLoader.bindImage(photoView, msg.arg1, ImageLoader.Type.origin);
imageLoader.bindImage(cardImage, msg.arg1, ImageLoader.Type.detail);
break;
case TYPE_DOWNLOAD_CARD_IMAGE_ING:
tv_loading.setText(msg.arg1 + "%");
......@@ -259,19 +259,14 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
private void setCardInfo(Card cardInfo, View view) {
if (cardInfo == null) return;
mCardInfo = cardInfo;
imageLoader.bindImage(cardImage, cardInfo.Code, ImageLoader.Type.detail);
imageLoader.bindImage(cardImage, cardInfo, ImageLoader.Type.detail);
dialog = DialogUtils.getdx(context);
cardImage.setOnClickListener((v) -> {
showCardImageDetail(cardInfo.Code);
});
name.setText(cardInfo.Name);
desc.setText(cardInfo.Desc);
int t = cardInfo.Alias - cardInfo.Code;
if (t > 10 || t < -10) {
cardCode.setText(String.format("%08d", cardInfo.Code));
} else {
cardCode.setText(String.format("%08d", cardInfo.Alias));
}
cardCode.setText(String.format("%08d", cardInfo.getCardCode()));
//按是否存在于收藏夹切换显示图标
mImageFav.setSelected(CardFavorites.get().hasCard(cardInfo.Code));
......
......@@ -92,13 +92,13 @@ public class CardDetailRandom {
public static CardDetailRandom genRandomCardDetail(Context context, ImageLoader imageLoader, Card cardInfo) {
if (cardInfo == null) return null;
CardDetailRandom cardDetailRandom = new CardDetailRandom(context, cardInfo);
cardDetailRandom.bindCardImage(imageLoader, cardInfo.Code);
cardDetailRandom.bindCardImage(imageLoader, cardInfo);
sCardDetailRandom = cardDetailRandom;
return cardDetailRandom;
}
public void bindCardImage(ImageLoader imageLoader, long code) {
imageLoader.bindImage(cardImage, code, ImageLoader.Type.origin);
public void bindCardImage(ImageLoader imageLoader, Card cardInfo) {
imageLoader.bindImage(cardImage, cardInfo, ImageLoader.Type.origin);
}
public View getView() {
......
......@@ -282,13 +282,7 @@ public class CardSearchActivity extends BaseActivity implements CardLoader.CallB
mCardDetail.setOnCardClickListener(new CardDetail.DefaultOnCardClickListener() {
@Override
public void onOpenUrl(Card cardInfo) {
String uri;
int t = cardInfo.Alias - cardInfo.Code;
if (t > 10 || t < -10) {
uri = Constants.WIKI_SEARCH_URL + String.format("%08d", cardInfo.Code);
} else {
uri = Constants.WIKI_SEARCH_URL + String.format("%08d", cardInfo.Alias);
}
String uri = Constants.WIKI_SEARCH_URL + String.format("%08d", cardInfo.getCardCode());
WebActivity.open(getContext(), cardInfo.Name, uri);
}
......
......@@ -416,13 +416,7 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
mCardDetail.setOnCardClickListener(new CardDetail.OnCardClickListener() {
@Override
public void onOpenUrl(Card cardInfo) {
String uri;
int t = cardInfo.Alias - cardInfo.Code;
if (t > 10 || t < -10) {
uri = Constants.WIKI_SEARCH_URL + String.format("%08d", cardInfo.Code);
} else {
uri = Constants.WIKI_SEARCH_URL + String.format("%08d", cardInfo.Alias);
}
String uri = Constants.WIKI_SEARCH_URL + String.format("%08d", cardInfo.getCardCode());
WebActivity.open(getContext(), cardInfo.Name, uri);
}
......@@ -566,7 +560,7 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
private boolean checkLimit(Card cardInfo) {
SparseArray<Integer> mCount = mDeckAdapater.getCardCount();
LimitList limitList = mDeckAdapater.getLimitList();
int id = cardInfo.Alias > 0 ? cardInfo.Alias : cardInfo.Code;
int id = cardInfo.getCardCode();
Integer count = mCount.get(id);
if (limitList == null) {
return count != null && count <= 3;
......
......@@ -271,7 +271,7 @@ public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implement
private void addCount(Card cardInfo, DeckItemType type) {
if (cardInfo == null) return;
Integer code = cardInfo.Alias > 0 ? cardInfo.Alias : cardInfo.Code;
Integer code = cardInfo.getCardCode();
Integer i = mCount.get(code);
if (i == null) {
mCount.put(code, 1);
......@@ -316,7 +316,7 @@ public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implement
private void removeCount(Card cardInfo, DeckItemType type) {
if (cardInfo == null) return;
Integer code = cardInfo.Alias > 0 ? cardInfo.Alias : cardInfo.Code;
int code = cardInfo.getCardCode();
Integer i = mCount.get(code);
if (i == null) {
mCount.put(code, 0);
......@@ -596,7 +596,7 @@ public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implement
holder.setRightImage(null);
}
// holder.useDefault();
imageLoader.bindImage(holder.cardImage, cardInfo.Code, ImageLoader.Type.deck);
imageLoader.bindImage(holder.cardImage, cardInfo, ImageLoader.Type.deck);
} else {
holder.setCardType(0);
holder.setRightImage(null);
......
......@@ -95,7 +95,7 @@ public class CardView extends FrameLayout {
if (mCard != null && mCard.equals(cardInfo)) return;
mCard = cardInfo;
if (cardInfo != null && imageLoader != null) {
imageLoader.bindImage(mCardView, cardInfo.Code, ImageLoader.Type.deck);
imageLoader.bindImage(mCardView, cardInfo, ImageLoader.Type.deck);
} else {
mTopImage.setVisibility(View.GONE);
mCardView.setImageBitmap(null);
......
......@@ -3,6 +3,8 @@ package cn.garymb.ygomobile.ui.widget;
import android.content.Context;
import android.util.AttributeSet;
import java.net.CookieManager;
import cn.garymb.ygomobile.ui.mycard.X5WebView;
......@@ -14,5 +16,4 @@ public class WebViewPlus extends X5WebView {
public WebViewPlus(Context context, AttributeSet attrs) {
super(context, attrs);
}
}
......@@ -5,6 +5,8 @@ import android.os.Parcelable;
import androidx.annotation.NonNull;
import cn.garymb.ygomobile.Constants;
public class CardData implements Parcelable {
public CardData() {
......@@ -85,6 +87,14 @@ public class CardData implements Parcelable {
this.Category = in.readLong();
}
public int getCardCode(){
if (Alias == 0 || Math.abs(Alias - Code) <= 10) {
return Alias;
} else {
return Code;
}
}
public static final Creator<CardData> CREATOR = new Creator<CardData>() {
@Override
public CardData createFromParcel(Parcel source) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment