package com.tofly.ghrq_route.common.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.appcompat.widget.AppCompatTextView;
import androidx.recyclerview.widget.RecyclerView;

import com.lcp.arecyclerview.widget.ARecyclerBaseAdapter;
import com.tofly.ghrq_route.R;
import com.tofly.ghrq_route.module.OfflineWork.domain.OfflineWorkJobBean.OfflineWorkJobType;
import com.tofly.ghrq_route.module.OfflineWork.domain.OfflineWorkJobCountBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Amu on 2017/5/22.
 */

public class OfflineWorkJobsInfoAdapter extends ARecyclerBaseAdapter<OfflineWorkJobsInfoAdapter.MyViewHolder, OfflineWorkJobCountBean> {

    public OfflineWorkJobsInfoAdapter(Context context, List<OfflineWorkJobCountBean> data) {
        super(context, data);
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View rootView = LayoutInflater.from(mContext).inflate(R.layout.offline_work_job_count_item, parent, false);
        return new MyViewHolder(rootView);
    }

    @Override
    public void onBindViewHolder(final MyViewHolder holder, final int position) {
        OfflineWorkJobCountBean jobBean = getItem(position);
        if (jobBean != null) {
            int job_type = jobBean.getJob_type();
            String text_job_type = "";
            switch (job_type) {
                case OfflineWorkJobType.JOB_SIGN_UP_OFF_ADD:
                    text_job_type = "签到历史记录";
                    break;
                case OfflineWorkJobType.JOB_UPLOAD_PHOTO_ADD:
                    text_job_type = "照片上传记录";
                    break;
                case OfflineWorkJobType.JOB_PLAN_INFO_CHANGED:
                    text_job_type = "计划信息更新记录";
                    break;
                case OfflineWorkJobType.JOB_DANGER_DANGER_ADD:
                    text_job_type = "新增隐患上报记录";
                    break;
                case OfflineWorkJobType.JOB_DANGER_PLAN_ROUTE_ADD:
                    text_job_type = "隐患巡检/整改录入记录";
                    break;
                case OfflineWorkJobType.JOB_COMMON_DEVICE_ROUTE_ADD:
                    text_job_type = "调压设备/阀门/阀室/阴保站/测试桩录入记录";
                    break;
                case OfflineWorkJobType.JOB_BUILD_MANAGE_ADD:
                    text_job_type = "新增工地发现记录";
                    break;
                case OfflineWorkJobType.JOB_BUILD_REPORT_ADD:
                    text_job_type = "新增工地回报记录";
                    break;
                case OfflineWorkJobType.JOB_BUILD_LOG_ADD:
                    text_job_type = "工地监护日志记录";
                    break;
                case OfflineWorkJobType.JOB_BUILD_NOTICE_PHOTO_ADD:
                    text_job_type = "工地告知书图片，语音待上传记录";
                    break;
                case OfflineWorkJobType.JOB_PLAN_POINTS_OVER_ADD:
                    text_job_type = "已到位巡检点待上传记录";
                    break;
                case OfflineWorkJobType.JOB_SAVED_GPS_UPLOAD:
                    text_job_type = "未提交的本地GPS记录";
                    break;
            }
            holder.textView1.setText(text_job_type);
            String text_count = jobBean.getJob_count() + "条";
            holder.textView2.setText(text_count);
        }
    }

    class MyViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.text1)
        AppCompatTextView textView1;
        @BindView(R.id.text2)
        AppCompatTextView textView2;

        MyViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
