package com.mayi.demo.view;

import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.mayi.demo.ItemBean;
import com.mayi.demo.R;
import com.mayi.fastdevelop.base.BaseViewHolder;
import com.mayi.fastdevelop.view.OnMultiClickListener;


public class SmartRefreshLayoutVH extends BaseViewHolder<ItemBean> {

    protected TextView tv;
    private SmartRefreshLayoutVHListener layoutVHListener;

    public SmartRefreshLayoutVH(@NonNull View itemView) {
        super(itemView);
        tv = (TextView) itemView;
        tv.setTextSize(itemView.getContext().getResources().getDimensionPixelSize(R.dimen.text_size_20));
    }

    public void setLayoutVHListener(SmartRefreshLayoutVHListener layoutVHListener) {
        this.layoutVHListener = layoutVHListener;
    }

    @Override
    public void onBindView(ItemBean itemBean) {
        tv.setText(itemBean.getText());
        tv.setOnClickListener(new OnMultiClickListener() {
            @Override
            public void onMultiClick(View v) {
                if (layoutVHListener != null) {
                    layoutVHListener.onItemClick(itemBean);
                }
            }
        });
    }

    public interface SmartRefreshLayoutVHListener {

        public void onItemClick(ItemBean itemBean);

    }

}
