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


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.ajhxcgl.AscFragment;
import com.example.administrator.zhapp.fragment.ajhxcgl.AxzFragment;
import com.example.administrator.zhapp.weight.AutoRadioGroup;
import com.example.administrator.zhapp.weight.NoscrollViewPager;
import java.util.ArrayList;
import java.util.List;

public class AjhXzActivity extends BaseActivity {

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

    private AxzFragment xz;
    private AscFragment sc;
    private List<Fragment> fragments;
    private FragmentPagerAdapter adapter;

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

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

        setBack();
        setTitle("安健环计划下载");
        fragments = new ArrayList<>();
        xz = AxzFragment.newInstance("", "");
        sc = AscFragment.newInstance("", "");

        fragments.add(xz);
        fragments.add(sc);

        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);
                }
            }
        });
    }

    @Override
    protected void initData() {

    }
}