package com.bjzc.bhzhgd.activity.qfgd;


import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.bjzc.bhzhgd.R;
import com.bjzc.bhzhgd.adapter.QfOptionAdapter;
import com.bjzc.bhzhgd.base.BaseActivity3;
import com.bjzc.bhzhgd.bean.Q4OptionBean;
import java.util.ArrayList;
import java.util.List;


/**
 * Created by ruihong on 2022/6/16.
 */

public class QfOptionActivity extends BaseActivity3 {

    RecyclerView rlv;
    List<Q4OptionBean.DataBean> datas;
    QfOptionAdapter qfBmlbinfoAdapter;


    @Override
    public int getLayoutId() {
        return R.layout.activity_qfbmlist;
    }

    @Override
    public void initView() {
        rlv = findViewById(R.id.rlv);
        initToolbar("部门列表", "确定", new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                for (Q4OptionBean.DataBean dataBean : qfBmlbinfoAdapter.getDatas()) {

                    if (dataBean.isSelected()) {

                        Intent resultIntent = new Intent();

                        Bundle bundle = new Bundle();

                        bundle.putString("XLID", dataBean.getXLID());

                        bundle.putString("XLMC", dataBean.getXLMC());

                        resultIntent.putExtras(bundle);

                        setResult(RESULT_OK, resultIntent);

                        finish();

                    }
                }
            }
        });
    }

    @Override
    public void initData() {

        datas = new ArrayList<>();
        Intent intent = getIntent();
        datas = intent.getParcelableArrayListExtra("options");
        setAdapter();
    }

    private void setAdapter() {

        qfBmlbinfoAdapter = new QfOptionAdapter(context, datas);

        rlv.setLayoutManager(new LinearLayoutManager(context));

        rlv.setAdapter(qfBmlbinfoAdapter);
    }

}

