对接语圈接口,
页面基本完成,评论完成一半,需要再调试
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user