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

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

/**
 * 设备巡点检管理--现场点检
 */
public class SxcdjActivity extends BaseActivity {

    NoscrollViewPager vp;
    RadioButton rb1;
    RadioButton rb2;
    RadioButton rb3;
    AutoRadioGroup rg;

    private List<Fragment> list;
    private MyFragmentAdapter adapter;

    private XzjhFragment xzjh;
    private DjdscFragment djdsc;

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

    protected void initView() {
        vp = findViewById(R.id.vp_centent);
        rb1 = findViewById(R.id.rb1);
        rb2 = findViewById(R.id.rb2);
        rb3 = findViewById(R.id.rb3);
        rg = findViewById(R.id.rg);
    }

    public void initData() {
        setTitle("点检下载计划");
        setBack();
        xzjh = XzjhFragment.newInstance();
        djdsc = DjdscFragment.newInstance();
        list = new ArrayList<>();
        list.add(xzjh);
        list.add(djdsc);
        adapter = new MyFragmentAdapter(getSupportFragmentManager(), list);
        vp.setAdapter(adapter);



        vp.setOffscreenPageLimit(2);
        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);
                        rb3.setTextColor(Color.GRAY);
                        vp.setCurrentItem(0, false);
                        break;
                    case R.id.rb2:
                        rb1.setTextColor(Color.GRAY);
                        rb2.setTextColor(Color.WHITE);
                        rb3.setTextColor(Color.GRAY);
                        vp.setCurrentItem(1, false);
                        break;

                }
            }
        });
    }

    public void updataDjdsc() {
        djdsc.getDataInSQL();
    }
}