package com.wd.workoffice.ui.activity.bat.work;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.wd.workoffice.R;
import com.wd.workoffice.app.WorkToolBarActivity;
import com.wd.workoffice.bean.DepBean;
import com.wd.workoffice.ui.adapter.WorkDepManageAdapter;

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

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * author : flexible
 * email : lgd19940421@163.com
 * github: https://github.com/FlexibleXd
 **/
public class WorkDepPersonActivity extends WorkToolBarActivity {

    @BindView(R.id.rv_manger)
    RecyclerView rvManger;
    @BindView(R.id.rv_simple)
    RecyclerView rvSimple;
    @BindView(R.id.tv_manage)
    TextView tvManage;
    @BindView(R.id.tv_simple)
    TextView tvSimple;
    private List<String> manageList;
    private List<String> simpleList;
    private WorkDepManageAdapter manageAdapter;
    private WorkDepManageAdapter simpleAdapter;

    @Override
    protected void initView() {
        ButterKnife.bind(this);
        rvSimple.setLayoutManager(new LinearLayoutManager(this, RecyclerView.VERTICAL, false));
        rvManger.setLayoutManager(new LinearLayoutManager(this, RecyclerView.VERTICAL, false));
    }


    @Override
    protected void initData() {
        List<DepBean.DeptUserListBean> simple = JSON.parseArray(getIntent().getStringExtra("simple"), DepBean.DeptUserListBean.class);
        List<DepBean.DeptRulerListBean> manage = JSON.parseArray(getIntent().getStringExtra("manage"), DepBean.DeptRulerListBean.class);
        manageList = new ArrayList<>();
        simpleList = new ArrayList<>();
        for (DepBean.DeptUserListBean deptUserListBean : simple) {
            simpleList.add(deptUserListBean.getNickName());
        }
        for (DepBean.DeptRulerListBean deptUserListBean : manage) {
            manageList.add(deptUserListBean.getNickName());
        }
        if (manageList.size() == 0) {
            tvManage.setVisibility(View.GONE);
        }
        if (simpleList.size() == 0) {
            tvSimple.setVisibility(View.GONE);
        }
        manageAdapter = new WorkDepManageAdapter(R.layout.item_store_client, manageList);
        simpleAdapter = new WorkDepManageAdapter(R.layout.item_store_client, simpleList);
        manageAdapter.bindToRecyclerView(rvManger);
        simpleAdapter.bindToRecyclerView(rvSimple);
    }


    @Override
    protected void initEvent() {
    }

    @Override
    protected int layoutId() {
        return R.layout.activity_work_dep_person;
    }

}
