Commit 3f7bc660 authored by noname's avatar noname

下载卡图的刷新

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