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

import android.content.Context;
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.model.TaskListViewHolderData;
import kr.co.hanwha.hifive.base.BaseViewHolder;

/**
 * Created by aaron on 2018. 8. 30.
 */

public class SettingMyHomeTodoHeaderViewHolder extends BaseViewHolder {
    private Context mContext;
    private TextView mTextViewTitle;
    private TextView mTextViewCount;
    private TextView mTextViewEmpty;

    public SettingMyHomeTodoHeaderViewHolder(@NonNull ViewGroup viewGroup) {

        super(viewGroup, R.layout.item_setting_my_home_todo_header);

        mContext = viewGroup.getContext();
        mTextViewTitle = (TextView) itemView.findViewById(R.id.title_textView);
        mTextViewCount = (TextView) itemView.findViewById(R.id.count_textView);
        mTextViewEmpty = (TextView) itemView.findViewById(R.id.empty_textView);
    }

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

        if (object == null) return;

        TaskListViewHolderData data = (TaskListViewHolderData) object;
        mTextViewTitle.setText(data.getTitle());
        mTextViewCount.setText(Integer.toString(count));
        if (count > 0) {
//            mTextViewCount.setVisibility(View.VISIBLE);
            mTextViewEmpty.setVisibility(View.GONE);
        } else {
//            mTextViewCount.setVisibility(View.GONE);
            String emptyMessage = "";
            switch (data.getType()) {
                case TODAY_HEADER:
                    emptyMessage = mContext.getResources().getString(R.string.setting_my_home_todo_empty_today);
                    break;
                case TASK_HEADER:
                    emptyMessage = mContext.getResources().getString(R.string.setting_my_home_todo_empty_todo);
                    break;
                case TASK_CLOSED_HEADER:
                    emptyMessage = mContext.getResources().getString(R.string.setting_my_home_todo_empty_complete);
                    break;
            }
            mTextViewEmpty.setText(emptyMessage);
            mTextViewEmpty.setVisibility(View.VISIBLE);
        }
    }
}
