From 87ba382e817fc0815fef9678784184f00d05ea49 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Thu, 30 Mar 2023 16:36:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=88=E5=BF=83=E6=84=BF=E5=8D=95=E7=9A=84?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=B8=8E=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/adapter/LiveNewWishAdapter.java | 14 +++ .../common/views/LunarWishItemViewHolder.java | 93 ++++++++++++++- .../src/main/res/layout/item_lunar_wish.xml | 110 ++++++++++++++++-- 3 files changed, 208 insertions(+), 9 deletions(-) diff --git a/common/src/main/java/com/yunbao/common/adapter/LiveNewWishAdapter.java b/common/src/main/java/com/yunbao/common/adapter/LiveNewWishAdapter.java index 56d24d792..75bff6245 100644 --- a/common/src/main/java/com/yunbao/common/adapter/LiveNewWishAdapter.java +++ b/common/src/main/java/com/yunbao/common/adapter/LiveNewWishAdapter.java @@ -95,6 +95,20 @@ public class LiveNewWishAdapter extends RecyclerView.Adapter { }); } else if (holder instanceof LunarWishItemViewHolder) { LunarWishItemViewHolder lunarWishItemViewHolder = (LunarWishItemViewHolder) holder; + lunarWishItemViewHolder.steLunarWishData(wishList.get(position), position, new LunarWishItemViewHolder.LunarWishItemListener() { + @Override + public void onDelete(int index) { + wishList.remove(index); + notifyDataSetChanged(); + } + + @Override + public void onUpdate(WishModel model, int index) { + wishList.remove(index); + wishList.add(index, model); + notifyItemChanged(index); + } + }); } else if (holder instanceof SeasonalWishItemViewHolder) { SeasonalWishItemViewHolder seasonalWishItemViewHolder = (SeasonalWishItemViewHolder) holder; } diff --git a/common/src/main/java/com/yunbao/common/views/LunarWishItemViewHolder.java b/common/src/main/java/com/yunbao/common/views/LunarWishItemViewHolder.java index 37c98a2e8..756685745 100644 --- a/common/src/main/java/com/yunbao/common/views/LunarWishItemViewHolder.java +++ b/common/src/main/java/com/yunbao/common/views/LunarWishItemViewHolder.java @@ -1,12 +1,103 @@ package com.yunbao.common.views; import android.view.View; +import android.widget.FrameLayout; +import android.widget.ImageView; +import android.widget.ProgressBar; +import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; -public class LunarWishItemViewHolder extends RecyclerView.ViewHolder { +import com.yunbao.common.R; +import com.yunbao.common.bean.WishModel; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.utils.WordsTypeUtil; +import com.yunbao.common.views.weight.ViewClicksAntiShake; + +public class LunarWishItemViewHolder extends RecyclerView.ViewHolder { + private TextView wishTab, wishlistName, wishlistProgress, wishlistNum, wishlistNum2, subtraction, addition; + private ImageView wishIcon; + private FrameLayout wishIconBg, tabBg, iconCancel; + private ProgressBar progressBar; + public LunarWishItemViewHolder(@NonNull View itemView) { super(itemView); + wishTab = itemView.findViewById(R.id.wish_tab); + wishIcon = itemView.findViewById(R.id.wish_icon); + tabBg = itemView.findViewById(R.id.tab_bg); + wishIconBg = itemView.findViewById(R.id.wish_icon_bg); + iconCancel = itemView.findViewById(R.id.icon_cancel); + wishlistName = itemView.findViewById(R.id.wishlist_name); + progressBar = itemView.findViewById(R.id.progressBar); + wishlistProgress = itemView.findViewById(R.id.wishlist_progress); + wishlistNum = itemView.findViewById(R.id.wishlist_num); + wishlistNum2 = itemView.findViewById(R.id.wishlist_num2); + subtraction = itemView.findViewById(R.id.subtraction); + addition = itemView.findViewById(R.id.addition); + } + + public void steLunarWishData(WishModel model, int index, LunarWishItemListener listener) { + if (model != null) { + itemView.findViewById(R.id.hind_layout).setVisibility(View.VISIBLE); + itemView.findViewById(R.id.wish_icon_bg).setVisibility(View.VISIBLE); + itemView.findViewById(R.id.progress_bar).setVisibility(View.VISIBLE); + iconCancel.setVisibility(View.VISIBLE); + wishTab.setVisibility(View.VISIBLE); + wishlistName.setVisibility(View.VISIBLE); + wishTab.setText(String.format(itemView.getContext().getString(R.string.wish_number), WordsTypeUtil.numberConvertToUppercase(index + 1))); + ImgLoader.display(itemView.getContext(), model.getWishlistIcon(), wishIcon); + tabBg.setBackgroundResource(R.mipmap.bg_lunar_wish); + wishIconBg.setBackgroundResource(R.mipmap.background_wish_item); + wishlistName.setText(model.getWishlistName()); + progressBar.setMax(model.wishProgress()); + progressBar.setProgress(model.wishCurrent());//当前进度 + wishlistProgress.setText(model.getWishlistProgress()); + wishlistNum.setText(String.format("/%s", model.getWishlistNum())); + wishlistNum2.setText(String.format("x%s", model.getWishlistNum())); + ViewClicksAntiShake.clicksAntiShake(iconCancel, new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + if (listener != null) { + listener.onDelete(index); + } + } + }); + ViewClicksAntiShake.clicksAntiShake(addition, new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + int number = model.wishProgress(); + model.setWishlistNum(String.valueOf(number + 1)); + if (listener != null) { + listener.onUpdate(model, index); + } + } + }); + ViewClicksAntiShake.clicksAntiShake(subtraction, new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + int number = model.wishProgress(); + model.setWishlistNum(String.valueOf(number - 1)); + if (listener != null) { + listener.onUpdate(model, index); + } + } + }); + } else { + itemView.findViewById(R.id.hind_layout).setVisibility(View.GONE); + itemView.findViewById(R.id.progress_bar).setVisibility(View.GONE); + tabBg.setBackground(null); + wishTab.setVisibility(View.GONE); + wishlistName.setVisibility(View.GONE); + iconCancel.setVisibility(View.GONE); + itemView.findViewById(R.id.wish_icon_bg).setVisibility(View.GONE); + + } + } + + public interface LunarWishItemListener { + void onDelete(int index); + + void onUpdate(WishModel model, int index); } } diff --git a/common/src/main/res/layout/item_lunar_wish.xml b/common/src/main/res/layout/item_lunar_wish.xml index 9cf89dd64..d6bf5f327 100644 --- a/common/src/main/res/layout/item_lunar_wish.xml +++ b/common/src/main/res/layout/item_lunar_wish.xml @@ -1,33 +1,44 @@ - + android:layout_marginEnd="19dp"> + + + + + + android:layout_marginTop="40dp"> + + + + + + + + + + + + + + + + + + + + \ No newline at end of file