package com.example.administrator.zhapp.activity;

import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
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.ajhxcgl.YhpclrListActivity;
import com.example.administrator.zhapp.activity.sbxdjgl.SQxgdlrfActivity;
import com.example.administrator.zhapp.adapter.GridViewAdapter;
import com.example.administrator.zhapp.entity.GridViewBean;

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


public class GdActivity extends BaseActivity {

    GridView gv;
    private String[] str = {"缺陷工单录入", "隐患排查单录入"};
    private int[] imageId = {R.mipmap.icon15, R.mipmap.icon16};
    //    private int[] colors = {R.color.c1, R.color.d2};
    private int[] colors = {R.drawable.radius_c1, R.drawable.radius_d2};
    private GridViewAdapter adapter;

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

    @Override
    protected void initView() {
        gv = findViewById(R.id.gv);

        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);

        mToolbar.setBackgroundColor(Color.parseColor("#00000000"));
        title.setText("工单录入");
        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(GdActivity.this, SQxgdlrfActivity.class);
                        startActivity(intent);
                        break;
                    case 1:
                        intent = new Intent(GdActivity.this, YhpclrListActivity.class);
                        startActivity(intent);
                        break;
                }
            }
        });
    }

    @Override
    protected void initData() {

    }

    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;
    }
}
