Commit 3f7bc660 authored by noname's avatar noname

下载卡图的刷新

parent 09eb188d
package cn.garymb.ygomobile.ui.adapters;
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import com.tubb.smrv.SwipeHorizontalMenuLayout;
import org.greenrobot.eventbus.EventBus;
......@@ -63,6 +66,14 @@ public class CardListAdapter extends BaseRecyclerAdapterPlus<Card, ViewHolder> i
return false;
}
public void notifyItemChanged(Card card) {
for (int i = 0; i < getItemCount(); i++) {
if (getCard(i).Code == card.Code) {
notifyItemChanged(i);
}
}
}
public void hideMenu(View view) {
if (view == null) {
view = mShowMenuView;
......@@ -88,6 +99,7 @@ public class CardListAdapter extends BaseRecyclerAdapterPlus<Card, ViewHolder> i
}
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = inflate(R.layout.item_search_card_swipe, parent, false);
......@@ -100,8 +112,8 @@ public class CardListAdapter extends BaseRecyclerAdapterPlus<Card, ViewHolder> i
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
Card item = getItem(position);
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
Card item = getCard(position);
if(item == null){
return;
}
......
......@@ -107,6 +107,9 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
ll_bar.setVisibility(View.GONE);
imageLoader.bindImage(photoView, msg.arg1, ImageLoader.Type.origin);
imageLoader.bindImage(cardImage, msg.arg1, ImageLoader.Type.middle);
if(mListener != null){
mListener.onImageUpdate(mCardInfo);
}
break;
case TYPE_DOWNLOAD_CARD_IMAGE_ING:
tv_loading.setText(msg.arg1 + "%");
......@@ -128,32 +131,32 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
public CardDetail(BaseActivity context, ImageLoader imageLoader, StringManager stringManager) {
super(context.getLayoutInflater().inflate(R.layout.dialog_cardinfo, null));
mContext = context;
cardImage = bind(R.id.card_image);
cardImage = findViewById(R.id.card_image);
this.imageLoader = imageLoader;
mStringManager = stringManager;
name = bind(R.id.text_name);
desc = bind(R.id.text_desc);
close = bind(R.id.btn_close);
cardCode = bind(R.id.card_code);
level = bind(R.id.card_level);
linkArrow = bind(R.id.detail_link_arrows);
type = bind(R.id.card_type);
View faq = bind(R.id.btn_faq);
cardAtk = bind(R.id.card_atk);
cardDef = bind(R.id.card_def);
atkdefView = bind(R.id.layout_atkdef2);
mImageFav = bind(R.id.image_fav);
monsterLayout = bind(R.id.layout_monster);
layoutDetailPScale = bind(R.id.detail_p_scale);
detailCardScale = bind(R.id.detail_cardscale);
race = bind(R.id.card_race);
setName = bind(R.id.card_setname);
addMain = bind(R.id.btn_add_main);
addSide = bind(R.id.btn_add_side);
otView = bind(R.id.card_ot);
attrView = bind(R.id.card_attribute);
lbSetCode = bind(R.id.label_setcode);
name = findViewById(R.id.text_name);
desc = findViewById(R.id.text_desc);
close = findViewById(R.id.btn_close);
cardCode = findViewById(R.id.card_code);
level = findViewById(R.id.card_level);
linkArrow = findViewById(R.id.detail_link_arrows);
type = findViewById(R.id.card_type);
View faq = findViewById(R.id.btn_faq);
cardAtk = findViewById(R.id.card_atk);
cardDef = findViewById(R.id.card_def);
atkdefView = findViewById(R.id.layout_atkdef2);
mImageFav = findViewById(R.id.image_fav);
monsterLayout = findViewById(R.id.layout_monster);
layoutDetailPScale = findViewById(R.id.detail_p_scale);
detailCardScale = findViewById(R.id.detail_cardscale);
race = findViewById(R.id.card_race);
setName = findViewById(R.id.card_setname);
addMain = findViewById(R.id.btn_add_main);
addSide = findViewById(R.id.btn_add_side);
otView = findViewById(R.id.card_ot);
attrView = findViewById(R.id.card_attribute);
lbSetCode = findViewById(R.id.label_setcode);
cardManager = DataManager.get().getCardManager();
close.setOnClickListener((v) -> {
if (mListener != null) {
......@@ -187,10 +190,10 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
mListener.onOpenUrl(cardInfo);
}
});
bind(R.id.lastone).setOnClickListener((v) -> {
findViewById(R.id.lastone).setOnClickListener((v) -> {
onPreCard();
});
bind(R.id.nextone).setOnClickListener((v) -> {
findViewById(R.id.nextone).setOnClickListener((v) -> {
onNextCard();
});
mImageFav.setOnClickListener((v) -> {
......@@ -532,9 +535,6 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
}
}
private <T extends View> T bind(int id) {
return (T) findViewById(id);
}
public interface OnFavoriteChangedListener {
void onFavoriteChange(Card card, boolean favorite);
......@@ -547,6 +547,10 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
void onAddSideCard(Card cardInfo);
void onImageUpdate(Card cardInfo);
void onClose();
}
......@@ -563,6 +567,11 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
public void onClose() {
}
@Override
public void onImageUpdate(Card cardInfo) {
}
@Override
public void onAddSideCard(Card cardInfo) {
......
......@@ -291,6 +291,11 @@ public class CardSearchActivity extends BaseActivity implements CardLoader.CallB
WebActivity.openFAQ(getContext(), cardInfo);
}
@Override
public void onImageUpdate(Card cardInfo) {
mCardListAdapter.notifyItemChanged(cardInfo);
}
@Override
public void onClose() {
mDialog.dismiss();
......
......@@ -38,7 +38,6 @@ import com.feihua.dialogutils.util.DialogUtils;
import com.nightonke.boommenu.BoomButtons.BoomButton;
import com.nightonke.boommenu.BoomButtons.TextOutsideCircleButton;
import com.nightonke.boommenu.BoomMenuButton;
import com.ourygo.assistant.service.DuelAssistantService;
import com.ourygo.assistant.util.DuelAssistantManagement;
import org.greenrobot.eventbus.EventBus;
......@@ -420,6 +419,12 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
WebActivity.openFAQ(getContext(), cardInfo);
}
@Override
public void onImageUpdate(Card cardInfo) {
mDeckAdapater.notifyItemChanged(cardInfo);
mCardListAdapter.notifyItemChanged(cardInfo);
}
@Override
public void onClose() {
mDialog.dismiss();
......
......@@ -190,7 +190,7 @@ public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implement
}
@Override
public Card getCard(int posotion) {
public @Nullable Card getCard(int posotion) {
int count = mMainCount;
int index = 0;
if (posotion < count) {
......@@ -478,6 +478,16 @@ public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implement
mItems.add(deckItem);
}
public void notifyItemChanged(Card card){
for (int i = 0; i < getItemCount(); i++) {
DeckItem item = getItem(i);
Card c = item.getCardInfo();
if (c != null && c.Code == card.Code) {
notifyItemChanged(i);
}
}
}
public void addItem(int pos, DeckItem deckItem) {
if (deckItem.getCardInfo() != null) {
if (pos >= DeckItem.MainStart && pos <= DeckItem.MainEnd) {
......
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