From cd8b58a0ec3ca3d96ece07baf819c942edd69096 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=99=E5=89=8D=E5=8D=AB?= <2298122580@qq.com> Date: Thu, 13 Jun 2024 09:55:15 +0800 Subject: [PATCH] =?UTF-8?q?6.7.0=E7=94=A8=E6=88=B7=E7=AB=AF=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=EF=BC=9A=E6=9B=B4=E6=94=B9=E6=95=B0=E6=8D=AE=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yunbao/common/adapter/BaseAdapter.java | 77 +++++++++++++++++++ .../yunbao/common/bean/PrankProgressBean.java | 6 +- .../yunbao/live/views/LiveRoomViewHolder.java | 3 + 3 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 common/src/main/java/com/yunbao/common/adapter/BaseAdapter.java diff --git a/common/src/main/java/com/yunbao/common/adapter/BaseAdapter.java b/common/src/main/java/com/yunbao/common/adapter/BaseAdapter.java new file mode 100644 index 000000000..d77d3c901 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/adapter/BaseAdapter.java @@ -0,0 +1,77 @@ +package com.yunbao.common.adapter; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import androidx.recyclerview.widget.RecyclerView; +import java.util.HashMap; +import java.util.List; + +public abstract class BaseAdapter extends RecyclerView.Adapter { + private Context context; + public List data; + + public BaseAdapter(Context context, List data) { + this.context = context; + this.data = data; + } + + @Override + public BaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View view = LayoutInflater.from(context).inflate(getItemLayoutId(), parent, false); + return new BaseViewHolder(view); + } + + @Override + public void onBindViewHolder(BaseAdapter.BaseViewHolder holder, int position) { + T t = data.get(position); + bindData(holder, t); + } + + @Override + public int getItemCount() { + return data == null ? 0 : data.size(); + } + + public abstract void bindData(BaseViewHolder holder, T t); + + public abstract int getItemLayoutId(); + + class BaseViewHolder extends RecyclerView.ViewHolder { + + private HashMap views; + + public BaseViewHolder(View itemView) { + super(itemView); + views = new HashMap<>(); + } + + public View getView(int id) { + View view = views.get(id); + if (view == null) { + view = itemView.findViewById(id); + views.put(id, view); + if (onItemClickListener != null){ + view.setOnClickListener(v -> { + onItemClickListener.onItemClick(getAdapterPosition()); + onItemClickListener.onItemChildClick(v, getAdapterPosition()); + }); + } + } + return view; + } + } + + private OnItemClickListener onItemClickListener; + + private void setOnItemClickListener(OnItemClickListener onItemClickListener){ + this.onItemClickListener = onItemClickListener; + } + + public interface OnItemClickListener{ + default void onItemClick(int position){} + + default void onItemChildClick(View view,int position){} + } +} \ No newline at end of file diff --git a/common/src/main/java/com/yunbao/common/bean/PrankProgressBean.java b/common/src/main/java/com/yunbao/common/bean/PrankProgressBean.java index 83c3af541..77790c5bc 100644 --- a/common/src/main/java/com/yunbao/common/bean/PrankProgressBean.java +++ b/common/src/main/java/com/yunbao/common/bean/PrankProgressBean.java @@ -9,7 +9,7 @@ public class PrankProgressBean extends BaseModel { private int prank_turntable_status;// 转盘整蛊状态 0=关闭 1=开启 private int prank_type;// 整蛊类型 1.礼物整蛊 2.连击整蛊 private List prank_list;// 整蛊进度 - private JsonElement completed_list;// 待完成的整蛊 + private List completed_list;// 待完成的整蛊 public PrankProgressBean(){ } @@ -147,11 +147,11 @@ public class PrankProgressBean extends BaseModel { this.prank_list = prank_list; } - public JsonElement getCompleted_list() { + public List getCompleted_list() { return completed_list; } - public void setCompleted_list(JsonElement completed_list) { + public void setCompleted_list(List completed_list) { this.completed_list = completed_list; } diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java index ef75dcde3..b98a3d43e 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -197,6 +197,7 @@ import com.yunbao.live.presenter.LiveLightAnimPresenter; import com.yunbao.live.utils.LiveRoomVoteManager; import com.yunbao.live.utils.LiveTextRender; import com.yunbao.live.utils.LoadDian9TuUtil; +import com.yunbao.live.utils.ZeusKt; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; @@ -1770,6 +1771,8 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } if (Integer.parseInt(ctString.getString("prank_turntable_status")) == 0){ prank_group_turntable_icon.setVisibility(View.GONE); + }else { + ZeusKt.visible(prank_group_turntable_icon); } }else { //送整蛊礼物更新