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

import android.graphics.Color;
import androidx.fragment.app.Fragment;
import androidx.appcompat.widget.Toolbar;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import com.example.administrator.zhapp.DBModel.Ajhxzrwqy;
import com.example.administrator.zhapp.R;
import com.example.administrator.zhapp.activity.BaseActivity;
import com.example.administrator.zhapp.adapter.MyFragmentAdapter;
import com.example.administrator.zhapp.contans.Contans;
import com.example.administrator.zhapp.fragment.ajhxcgl.AjhxcDetaliFragment;
import com.example.administrator.zhapp.fragment.ajhxcgl.YhpcFragment;
import com.example.administrator.zhapp.weight.AutoRadioGroup;
import com.example.administrator.zhapp.weight.NoscrollViewPager;
import java.util.ArrayList;
import java.util.List;

/**
 * 安健环巡查管理-安健环巡查详情
 */
public class AjhxcDetaliActivity extends BaseActivity {

    NoscrollViewPager vp_content;
    RadioButton rb1;
    RadioButton rb2;
    AutoRadioGroup rg;

    private AjhxcDetaliFragment af;
    private YhpcFragment yf;
    private List<Fragment> list;
    private MyFragmentAdapter adapter;

    private ArrayList<Ajhxzrwqy> rwqys;

    //private ArrayList<SbdjInfo> lists;
    private int item;

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

    @Override
    protected void initView() {
        vp_content = findViewById(R.id.vp_centent);
        rb1 = findViewById(R.id.rb1);
        rb2 = findViewById(R.id.rb2);
        rg = findViewById(R.id.rg);
    }

    public void initData() {

        item = getIntent().getExtras().getInt("item");
        rwqys = getIntent().getExtras().getParcelableArrayList(Contans.KEY_SBDJLIST);

        setTitle("安健环巡查");
        setBack();

        af = AjhxcDetaliFragment.newInstance(item, rwqys);
        yf = YhpcFragment.newInstance(" ", " ");
        list = new ArrayList<>();
        list.add(af);
        list.add(yf);

        adapter = new MyFragmentAdapter(getSupportFragmentManager(), list);
        vp_content.setAdapter(adapter);

        rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {

                if (i == R.id.rb1) {
                    vp_content.setCurrentItem(0, false);
                    rb1.setTextColor(Color.WHITE);
                    rb2.setTextColor(Color.GRAY);
                } else if (i == R.id.rb2) {
                    vp_content.setCurrentItem(1, false);
                    rb2.setTextColor(Color.WHITE);
                    rb1.setTextColor(Color.GRAY);
                }
            }
        });
    }

    public Toolbar getmToolbar() {
        return mToolbar;
    }
}
