65 lines
1.9 KiB
Java
65 lines
1.9 KiB
Java
|
|
package com.qxcm.moduleutil.adapter;
|
||
|
|
|
||
|
|
import android.view.LayoutInflater;
|
||
|
|
import android.view.View;
|
||
|
|
import android.view.ViewGroup;
|
||
|
|
import android.widget.TextView;
|
||
|
|
|
||
|
|
import androidx.annotation.NonNull;
|
||
|
|
import androidx.recyclerview.widget.RecyclerView;
|
||
|
|
|
||
|
|
import com.qxcm.moduleutil.R;
|
||
|
|
import com.qxcm.moduleutil.bean.CommentBean;
|
||
|
|
|
||
|
|
import java.util.List;
|
||
|
|
|
||
|
|
public class ReplyAdapter extends RecyclerView.Adapter<ReplyAdapter.ReplyViewHolder> {
|
||
|
|
|
||
|
|
private List<CommentBean.CommentDetailsBean.Replies> replyList;
|
||
|
|
|
||
|
|
public ReplyAdapter(List<CommentBean.CommentDetailsBean.Replies> replyList) {
|
||
|
|
this.replyList = replyList;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void updateData(List<CommentBean.CommentDetailsBean.Replies> newReplyList) {
|
||
|
|
replyList.clear();
|
||
|
|
replyList.addAll(newReplyList);
|
||
|
|
notifyDataSetChanged();
|
||
|
|
}
|
||
|
|
|
||
|
|
@NonNull
|
||
|
|
@Override
|
||
|
|
public ReplyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||
|
|
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_reply, parent, false);
|
||
|
|
return new ReplyViewHolder(view);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public void onBindViewHolder(@NonNull ReplyViewHolder holder, int position) {
|
||
|
|
CommentBean.CommentDetailsBean.Replies reply = replyList.get(position);
|
||
|
|
holder.bind(reply);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public int getItemCount() {
|
||
|
|
return replyList.size();
|
||
|
|
}
|
||
|
|
|
||
|
|
static class ReplyViewHolder extends RecyclerView.ViewHolder {
|
||
|
|
private TextView tvNickname;
|
||
|
|
private TextView tvContent;
|
||
|
|
|
||
|
|
public ReplyViewHolder(@NonNull View itemView) {
|
||
|
|
super(itemView);
|
||
|
|
// tvNickname = itemView.findViewById(R.id.tv_reply_nickname);
|
||
|
|
// tvContent = itemView.findViewById(R.id.tv_reply_content);
|
||
|
|
}
|
||
|
|
|
||
|
|
public void bind(CommentBean.CommentDetailsBean.Replies reply) {
|
||
|
|
tvNickname.setText(reply.getNickname());
|
||
|
|
tvContent.setText(reply.getContent());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|