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

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.BaseActivity;
import com.example.administrator.zhapp.adapter.GridViewAdapter;
import com.example.administrator.zhapp.contans.Contans;
import com.example.administrator.zhapp.entity.GridViewBean;
import com.example.administrator.zhapp.utils.SPUtils;

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

/**
 * 移动仓库管理
 */
public class YdckglActivity extends BaseActivity {

    private GridView gv;
    private String[] str = {"库存查询", "库存盘点", "物料接收", "物料发放", "退料入库", "接收退回", "货架移位", "物资图片上传", "条码打印", "货架标签打印"};
    private int[] imageId = {R.mipmap.icon13, R.mipmap.icon1, R.mipmap.icon7, R.mipmap.icon5, R.mipmap.icon2, R.mipmap.icon2, R.mipmap.icon3, R.mipmap.icon17, R.mipmap.icon11, R.mipmap.icon11};
    private int[] colors = {R.drawable.radius_c7, R.drawable.radius_c1, R.drawable.radius_c2, R.drawable.radius_c3, R.drawable.radius_c4, R.drawable.radius_b2, R.drawable.radius_c5, R.drawable.radius_a1, R.drawable.radius_c6, R.drawable.radius_a4};

    private boolean flag = true;

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

    protected void initView() {
        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();

        List<Integer> item = new ArrayList<>();
        String name = SPUtils.get(context, Contans.USERNAME, "").toString().toUpperCase();
        if (name.contains("CKCX")) {
            item.add(0);
            item.add(8);
            item.add(9);
            flag = false;
        }

        gv.setSelector(new ColorDrawable(Color.TRANSPARENT));
        gv.setAdapter(new GridViewAdapter(this, getGridViewData(), item, flag));
        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(YdckglActivity.this, KccxActivity.class);
                        startActivity(intent);
                        break;
                    case 1:
                        intent = new Intent(YdckglActivity.this, Kcpd2Activity.class);
                        startActivity(intent);
                        break;
                    case 2:
                        intent = new Intent(YdckglActivity.this, MateLablePrint.class);
                        startActivity(intent);
                        break;
                    case 3:
                        intent = new Intent(YdckglActivity.this, MaterialIssue.class);
                        startActivity(intent);
                        break;
                    case 4:
                        intent = new Intent(YdckglActivity.this, TlrkActivity.class);
                        startActivity(intent);
                        break;
                    case 5:
                        intent = new Intent(YdckglActivity.this, JstkActivity.class);
                        startActivity(intent);
                        break;
                    case 6:
                        intent = new Intent(YdckglActivity.this, ShelvesShift.class);
                        startActivity(intent);
                        break;
                    case 7:
                        intent = new Intent(YdckglActivity.this, WztpScActivity.class);
                        startActivity(intent);
                        break;
                    case 8:
                        intent = new Intent(YdckglActivity.this, TmdyActivity.class);
                        startActivity(intent);
                        break;
                    case 9:
                        intent = new Intent(YdckglActivity.this, HjbqdyActivity.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;
    }
}