package com.datarecovery.master.module.imgrecover;

import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LiveData;
import androidx.recyclerview.widget.RecyclerView;

import com.datarecovery.master.databinding.ItemImgRecoverTitleBinding;

public class ImageTitleAdapter extends RecyclerView.Adapter<ImageTitleAdapter.ViewHolder> {


    private final LiveData<String> countLiveData;
    private final LifecycleOwner lifecycleOwner;

    public ImageTitleAdapter(LifecycleOwner lifecycleOwner, LiveData<String> countLiveData) {
        this.lifecycleOwner = lifecycleOwner;
        this.countLiveData = countLiveData;
    }

    @NonNull
    @Override
    public ImageTitleAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());
        ItemImgRecoverTitleBinding binding = ItemImgRecoverTitleBinding.inflate(layoutInflater, parent, false);
        return new ImageTitleAdapter.ViewHolder(binding);
    }

    @Override
    public void onBindViewHolder(@NonNull ImageTitleAdapter.ViewHolder holder, int position) {

    }

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

    public class ViewHolder extends RecyclerView.ViewHolder {

        public ViewHolder(@NonNull ItemImgRecoverTitleBinding binding) {
            super(binding.getRoot());
            binding.setLifecycleOwner(lifecycleOwner);
            binding.setTitle(countLiveData);
        }


    }
}
