package com.cygnusa.hyperm.adapter;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.cygnusa.hyperm.R;
import com.cygnusa.hyperm.ViewBlogActivity;

public class BlogListAdapter extends RecyclerView.Adapter<BlogListAdapter.ViewHolder> {
    Context context;

    public BlogListAdapter(Activity blogActivity) {
        context = blogActivity;
    }


    @NonNull
    @Override
    public BlogListAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.blog_list_adapter, parent, false);
        return new BlogListAdapter.ViewHolder(v);
    }

    @Override
    public void onBindViewHolder(@NonNull BlogListAdapter.ViewHolder holder, int position) {
        holder.view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                context.startActivity(new Intent(context, ViewBlogActivity.class));
            }
        });
    }

    @Override
    public int getItemCount() {
        return 1;
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        View view;
        String user_id;
        TextView txt_click_like;
        private LinearLayout llout_like_div, llout_comment_div;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);

            view = itemView;
            llout_comment_div = view.findViewById(R.id.comment_div);
            llout_like_div = view.findViewById(R.id.like_div);
        }
    }
}
