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

import android.graphics.Color;
import androidx.fragment.app.Fragment;
import android.widget.RadioButton;
import android.widget.RadioGroup;
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.ydckgl.PdlbFragment;
import com.example.administrator.zhapp.fragment.ydckgl.PdxxFragment;
import com.example.administrator.zhapp.weight.AutoRadioGroup;
import com.example.administrator.zhapp.weight.NoscrollViewPager;
import java.util.ArrayList;
import java.util.List;


public class KcpdCxActivity extends BaseActivity {

    NoscrollViewPager fl;
    RadioButton rb1;
    RadioButton rb2;
    AutoRadioGroup rg;

    private String pdid;
    private String pch;
    private List<Fragment> list;
    private MyFragmentAdapter adapter;
    private PdlbFragment pdlb;
    private PdxxFragment pdxx;

    private void findView() {
        fl = findViewById(R.id.fl_centent);
        rb1 = findViewById(R.id.rb1);
        rb2 = findViewById(R.id.rb2);
        rg = findViewById(R.id.rg);
    }


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

    @Override
    protected void initView() {
        findView();
        setBack();
        setTitle("盘点信息");
        pdid = getIntent().getExtras().getString(Contans.KEY_PDID);
        pch = getIntent().getExtras().getString("pch");
    }

    public void initData() {
        setBack();
        pdxx = PdxxFragment.newInstance(pdid, pch);
        pdlb = PdlbFragment.newInstance(pdid);
        list = new ArrayList<>();
        list.add(pdxx);
        list.add(pdlb);
        adapter = new MyFragmentAdapter(getSupportFragmentManager(), list);
        fl.setAdapter(adapter);
        rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                switch (i) {
                    case R.id.rb1:
                        rb1.setTextColor(Color.WHITE);
                        rb2.setTextColor(Color.GRAY);
                        fl.setCurrentItem(0, false);
                        break;
                    case R.id.rb2:
                        rb2.setTextColor(Color.WHITE);
                        rb1.setTextColor(Color.GRAY);
                        fl.setCurrentItem(1, false);
                        break;
                }
            }
        });
    }
}
