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

import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import androidx.appcompat.widget.Toolbar;
import android.view.View;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.TextView;

import com.example.administrator.zhapp.R;
import com.example.administrator.zhapp.activity.BaseActivity;
import com.example.administrator.zhapp.adapter.GridViewAdapter;
import com.example.administrator.zhapp.entity.GridViewBean;

import java.util.ArrayList;
import java.util.List;

/**
 * 消防保卫巡查管理
 */
public class XfbwxcglActivity extends BaseActivity {

    private GridView gv;
    private String[] str = {"任务", "消防巡查", "保安巡更", "楼宇巡查"};
    private int[] imageId = {R.mipmap.icon3, R.mipmap.icon6, R.mipmap.icon10, R.mipmap.icon9};
//    private int[] colors = {R.color.e1, R.color.e2, R.color.e3, R.color.e4};

    private int[] colors = {R.drawable.radius_e1, R.drawable.radius_e2, R.drawable.radius_e3, R.drawable.radius_e4};
    private GridViewAdapter adapter;

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

    protected void initView() {
        mToolbar = (Toolbar) findViewById(R.id.toolbar);
        title = (TextView) findViewById(R.id.title);
        gv = (GridView) 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("综合巡查");
        setBack();

//        adapter = new GridViewAdapter(this, str, imageId, new ArrayList<Integer>(), true, colors);
        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(XfbwxcglActivity.this, XxzActivity.class);
                        startActivity(intent);
                        break;
                    case 1:
                        intent = new Intent(XfbwxcglActivity.this, XxfxcActivity.class);
                        startActivity(intent);
                        break;
                    case 2:
                        intent = new Intent(XfbwxcglActivity.this, XbaxgActivity.class);
                        startActivity(intent);
                        break;
                    case 3:
                        intent = new Intent(XfbwxcglActivity.this, XlyxcActivity.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;
    }
}