package kr.co.hanwha.hifive.adapter.viewholder;

import android.support.annotation.NonNull;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import kr.co.hanwha.hifive.R;
import kr.co.hanwha.hifive.base.BaseViewHolder;
import kr.co.hanwha.hifive.util.HFCommonUtil;

/**
 * Created by sanghoonkwon on 2018. 2. 22..
 */

public class MainProjectMarginListViewHolder extends BaseViewHolder {
    private TextView mTextViewEmpty;
    private int mColorRes = 0;

    public MainProjectMarginListViewHolder(@NonNull ViewGroup viewGroup) {

        super(viewGroup, R.layout.item_main_project_margin_list);

        mTextViewEmpty = (TextView) itemView.findViewById(R.id.empty_textView);
    }

    public void setColorRes(int colorRes) {
        mColorRes = colorRes;
    }

    @Override
    public void onBind(Object object, int height) {
        super.onBind(object, height);

        String message = (String) object;
        mTextViewEmpty.setText(message);


        if (mColorRes != 0) {
            itemView.setBackgroundColor(HFCommonUtil.getColor(getContext(), mColorRes));
        }

        if (height > 0) {
            LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, height);
            mTextViewEmpty.setLayoutParams(param);
        }
    }
}