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 { //送整蛊礼物更新