|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
package com.example.leudaemialikeme.Adapter;
|
|
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
@ -8,6 +10,7 @@ import android.widget.TextView;
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
|
|
|
|
|
|
|
|
import com.example.leudaemialikeme.Activity.BlogDetailActivity;
|
|
|
|
|
import com.example.leudaemialikeme.Model.Blog;
|
|
|
|
|
import com.example.leudaemialikeme.R;
|
|
|
|
|
import com.example.leudaemialikeme.Utils.TimeUtil;
|
|
|
|
@ -17,24 +20,30 @@ import java.util.List;
|
|
|
|
|
|
|
|
|
|
public class MyBlogAdapter extends RecyclerView.Adapter<MyBlogAdapter.ViewHolder>{
|
|
|
|
|
List<Blog> blogList = new ArrayList<>();
|
|
|
|
|
Context context;
|
|
|
|
|
|
|
|
|
|
public MyBlogAdapter(List<Blog> blogList){
|
|
|
|
|
public MyBlogAdapter(List<Blog> blogList, Context context){
|
|
|
|
|
this.blogList = blogList;
|
|
|
|
|
this.context = context;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static class ViewHolder extends RecyclerView.ViewHolder{
|
|
|
|
|
private TextView text_my_blog_id;
|
|
|
|
|
private TextView text_my_blog_uid;
|
|
|
|
|
private TextView text_my_blog_title;
|
|
|
|
|
private TextView text_my_blog_content;
|
|
|
|
|
private TextView text_my_blog_browse;
|
|
|
|
|
private TextView text_my_blog_time;
|
|
|
|
|
private TextView text_my_blog_flag;
|
|
|
|
|
private TextView text_my_blog_collect;
|
|
|
|
|
|
|
|
|
|
public ViewHolder(@NonNull View itemView) {
|
|
|
|
|
super(itemView);
|
|
|
|
|
text_my_blog_id = itemView.findViewById(R.id.text_my_blog_id);
|
|
|
|
|
text_my_blog_uid = itemView.findViewById(R.id.text_my_blog_uid);
|
|
|
|
|
text_my_blog_title = itemView.findViewById(R.id.text_my_blog_title);
|
|
|
|
|
text_my_blog_content = itemView.findViewById(R.id.text_my_blog_content);
|
|
|
|
|
text_my_blog_collect = itemView.findViewById(R.id.text_my_blog_collect);
|
|
|
|
|
text_my_blog_browse = itemView.findViewById(R.id.text_my_blog_browse);
|
|
|
|
|
text_my_blog_time = itemView.findViewById(R.id.text_my_blog_time);
|
|
|
|
|
text_my_blog_flag = itemView.findViewById(R.id.text_my_blog_flag);
|
|
|
|
@ -50,6 +59,14 @@ public class MyBlogAdapter extends RecyclerView.Adapter<MyBlogAdapter.ViewHolder
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
//TODO 跳转到帖子的详情页
|
|
|
|
|
Intent intent = new Intent(context, BlogDetailActivity.class);
|
|
|
|
|
intent.putExtra("bid",holder.text_my_blog_id.getText().toString());
|
|
|
|
|
intent.putExtra("bContent", holder.text_my_blog_content.getText().toString());
|
|
|
|
|
intent.putExtra("bTitle",holder.text_my_blog_title.getText().toString());
|
|
|
|
|
intent.putExtra("bColNum",holder.text_my_blog_collect.getText().toString());
|
|
|
|
|
intent.putExtra("bViewNum",holder.text_my_blog_browse.getText().toString());
|
|
|
|
|
intent.putExtra("uid", holder.text_my_blog_uid.getText().toString());
|
|
|
|
|
context.startActivity(intent);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return holder;
|
|
|
|
@ -59,8 +76,10 @@ public class MyBlogAdapter extends RecyclerView.Adapter<MyBlogAdapter.ViewHolder
|
|
|
|
|
public void onBindViewHolder(@NonNull MyBlogAdapter.ViewHolder holder, int position) {
|
|
|
|
|
Blog blog = blogList.get(position);
|
|
|
|
|
holder.text_my_blog_id.setText(String.valueOf(blog.getBid()));
|
|
|
|
|
holder.text_my_blog_uid.setText(String.valueOf(blog.getUid()));
|
|
|
|
|
holder.text_my_blog_title.setText(blog.getBtittle());
|
|
|
|
|
holder.text_my_blog_content.setText(blog.getBcontent());
|
|
|
|
|
holder.text_my_blog_collect.setText(String.valueOf(blog.getBcollectNum()));
|
|
|
|
|
holder.text_my_blog_browse.setText(String.valueOf(blog.getBbrowse()));
|
|
|
|
|
holder.text_my_blog_time.setText(TimeUtil.timeToString(blog.getBtime()));
|
|
|
|
|
if(blog.getFlag()==1)
|
|
|
|
|