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

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

import kr.co.hanwha.hifive.R;
import kr.co.hanwha.hifive.adapter.contract.TaskDetailListContract;
import kr.co.hanwha.hifive.base.BaseViewHolder;

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

public class CommentHeaderViewHolder extends BaseViewHolder {
    private TextView mTextViewCount;
    private TextView mTextViewMore;
    private View mViewUnderline;

    private TaskDetailListContract.OnTaskDetailListener mOnTaskDetailListener;

    public CommentHeaderViewHolder(@NonNull ViewGroup viewGroup,
                                   @NonNull TaskDetailListContract.OnTaskDetailListener onTaskDetailListener) {
        super(viewGroup, R.layout.item_comment_header);

        mTextViewCount = (TextView) itemView.findViewById(R.id.count_textView);
        mTextViewMore = (TextView) itemView.findViewById(R.id.more_textView);

        mViewUnderline = (View) itemView.findViewById(R.id.underline_view);

        this.mOnTaskDetailListener = onTaskDetailListener;
    }

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

        boolean isMore = (boolean) object;

        int count = index;
        mTextViewCount.setText(Integer.toString(count));

        mTextViewMore.setVisibility(isMore ? View.VISIBLE : View.GONE);

        mTextViewMore.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mOnTaskDetailListener != null)
                    mOnTaskDetailListener.onMessageMoreClicked();
            }
        });
    }

}