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

import android.graphics.Color;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentPagerAdapter;
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.fragment.xfbwxcgl.XscFragment;
import com.example.administrator.zhapp.fragment.xfbwxcgl.XxzjhFragment;
import com.example.administrator.zhapp.weight.AutoRadioGroup;
import com.example.administrator.zhapp.weight.NoscrollViewPager;
import java.util.ArrayList;
import java.util.List;


public class XxzActivity extends BaseActivity {

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

    private XxzjhFragment xzjh;
    private XscFragment xsc;
    private List<Fragment> fragments;
    private FragmentPagerAdapter adapter;

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

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

    @Override
    public void initData() {

        setBack();
        setTitle("综合巡查下载计划");
        fragments = new ArrayList<>();
        xzjh = XxzjhFragment.newInstance();
        xsc = XscFragment.newInstance();

        fragments.add(xzjh);
        fragments.add(xsc);

        adapter = new MyFragmentAdapter(getSupportFragmentManager(), fragments);
        fl.setAdapter(adapter);
        rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.rb1) {
                    rb1.setTextColor(Color.WHITE);
                    rb2.setTextColor(Color.GRAY);
                    fl.setCurrentItem(0, false);
                } else if (i == R.id.rb2) {
                    rb2.setTextColor(Color.WHITE);
                    rb1.setTextColor(Color.GRAY);
                    fl.setCurrentItem(1, false);
                }
            }
        });
    }
}
