package com.ttiglobal.inttilectgpchat.blog.Helper;

import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.widget.ImageView;

import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.ttiglobal.inttilectgpchat.R;
import com.ttiglobal.inttilectgpchat.blog.BlogDetails;


public class PostsViewHolder extends RecyclerView.ViewHolder {

    private View view;
    private ImageView post_image;

    public PostsViewHolder(View itemView) {
        super(itemView);
        view = itemView;
        post_image = view.findViewById(R.id.post_image);
    }

    public void showPostDetails(String imgurl, String user, String filetype, String time, String title, String details, int views, final Activity activity){

        Glide.with(activity)
                .applyDefaultRequestOptions(new RequestOptions()
                        .placeholder(R.color.com_facebook_device_auth_text)
                        .error(R.color.com_facebook_device_auth_text)
                        .diskCacheStrategy(DiskCacheStrategy.ALL))
                .load(imgurl)
                .into(post_image);


        final Intent post = new Intent(activity, BlogDetails.class);
        post.putExtra("file_url", imgurl);
       // post.putExtra("date_time", time);
        post.putExtra("user_id", user);
        post.putExtra("blog_title", title);
        post.putExtra("blog_desc", details);
        post.putExtra("file_type",filetype);
        //post.putExtra("Views", views);

        post_image.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                activity.startActivity(post);
            }
        });
    }
}
