package com.example.administrator.zhapp.activity.ajhxcgl;

import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.View;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.GridView;
import com.example.administrator.zhapp.R;
import com.example.administrator.zhapp.activity.BaseActivity;
import com.example.administrator.zhapp.activity.MainActivity;
import com.example.administrator.zhapp.adapter.GridViewAdapter;
import com.example.administrator.zhapp.entity.GridViewBean;
import java.util.ArrayList;
import java.util.List;

/**
 * 安健环巡查管理
 */
public class AjhxcglActivity extends BaseActivity {

    GridView gv;
    private String[] str = {"任务", "工作", "隐患排查录入", "工作情况上报", "工作情况查看", "卸氨情况上报"};
    private int[] imageId = {R.mipmap.icon3, R.mipmap.icon8, R.mipmap.icon16, R.mipmap.icon1, R.mipmap.icon4, R.mipmap.icon5};
    private int[] colors = {R.drawable.radius_d1, R.drawable.radius_d2, R.drawable.radius_d4, R.drawable.radius_e1, R.drawable.radius_e2, R.drawable.radius_c2};

    private GridViewAdapter adapter;

    @Override
    public int getContentViewID() {
        return R.layout.activity_ajhxcgl;
    }

    protected void initView() {
        gv = findViewById(R.id.gv);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
    }

    public void initData() {

        mToolbar.setBackgroundColor(Color.parseColor("#00000000"));
        setTitle("安健环巡查");
        if (getIntent().getExtras() == null) {
            setBack();
        } else {
            mToolbar.setNavigationIcon(R.mipmap.back);
            mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(AjhxcglActivity.this, MainActivity.class);
                    startActivity(intent);
                }
            });
        }
        adapter = new GridViewAdapter(this, getGridViewData(), new ArrayList<Integer>(), true);
        gv.setSelector(new ColorDrawable(Color.TRANSPARENT));
        gv.setAdapter(adapter);
        gv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Intent intent;
                switch (i) {
                    case 0:
                        intent = new Intent(AjhxcglActivity.this, AjhXzActivity.class);
                        startActivity(intent);
                        break;
                    case 1:
                        intent = new Intent(AjhxcglActivity.this, AjhGzActivity.class);
                        startActivity(intent);
                        break;
                    case 2:
                        intent = new Intent(AjhxcglActivity.this, YhpclrListActivity.class);
                        startActivity(intent);
                        break;
                    case 3:
                        intent = new Intent(AjhxcglActivity.this, GzqksbActivity.class);
                        startActivity(intent);
                        break;
                    case 4:
                        intent = new Intent(AjhxcglActivity.this, GzqkckActivity.class);
                        startActivity(intent);
                        break;
                    case 5:
                        intent = new Intent(AjhxcglActivity.this, xaqksbActivity.class);
                        startActivity(intent);
                        break;
                }
            }
        });
    }

    private List<GridViewBean> getGridViewData() {

        List<GridViewBean> datas = new ArrayList<>();
        for (int i = 0; i < str.length; i++) {
            GridViewBean bean = new GridViewBean();
            bean.setTitle(str[i]);
            bean.setBackgroup(colors[i]);
            bean.setImageid(imageId[i]);
            bean.setShow(false);
            datas.add(bean);
        }
        return datas;
    }
}