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

import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.view.View;
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.data.model.CampaignData;

public class OKRCampaignListViewHolder extends BaseViewHolder {
    private LinearLayout mLayoutBody;
    private TextView mTextViewProject;
    private TextView mTextViewCampaign;
    private View mViewLine;

    public OKRCampaignListViewHolder(@NonNull ViewGroup viewGroup) {
        super(viewGroup, R.layout.item_okr_campaign_list);
        mLayoutBody = (LinearLayout) itemView.findViewById(R.id.body_linearLayout);
        mTextViewProject = (TextView) itemView.findViewById(R.id.project_textView);
        mTextViewCampaign = (TextView) itemView.findViewById(R.id.campaign_textView);
        mViewLine = (View) itemView.findViewById(R.id.line_view);
    }

    @Override
    public void onBind(@NonNull Object object, @NonNull final int index) {
        super.onBind(object, index);

        if (object != null && object instanceof CampaignData) {
            final CampaignData data = (CampaignData) object;

            if (TextUtils.isEmpty(data.getProject_name()) == false)
                mTextViewProject.setText(data.getProject_name());

            if (TextUtils.isEmpty(data.getCampaign_desc()) == false)
                mTextViewCampaign.setText(data.getCampaign_desc());

            mTextViewProject.setVisibility(data.isFirstItem() ? View.VISIBLE : View.GONE);
        }
    }
}