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

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 SbxdjglActivity extends BaseActivity {

    GridView gv;
    private String[] str = {"任务", "工作", "缺陷工单录入", "读取NFC标签"};
    private int[] imageId = {R.mipmap.icon3, R.mipmap.icon6, R.mipmap.icon15, R.mipmap.icon11};
    private int[] colors = {R.drawable.radius_b1, R.drawable.radius_b2, R.drawable.radius_e2, R.drawable.radius_a4};
    private GridViewAdapter adapter;

    private int[] item = {2};

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

    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) {
            mToolbar.setNavigationIcon(R.mipmap.back);
            mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(SbxdjglActivity.this, MainActivity.class);
                    startActivity(intent);
                    finish();
                }
            });
        } else {
            setBack();

        }

        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(SbxdjglActivity.this, SxcdjActivity.class);
                        startActivity(intent);
                        break;
                    case 1:
                        intent = new Intent(SbxdjglActivity.this, SdjgzActivity.class);
                        startActivity(intent);
                        break;
                    case 2:
                        intent = new Intent(SbxdjglActivity.this, SQxgdlrfActivity.class);
                        startActivity(intent);
                        break;
                    case 3:
                        intent = new Intent(SbxdjglActivity.this, NFCInfoActivity.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;
    }
}