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 android.widget.TextView;
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.ydckgl.MateLablePrintFragment;
import com.example.administrator.zhapp.fragment.ydckgl.YsAndPzFragment;
import com.example.administrator.zhapp.weight.AutoRadioGroup;
import com.example.administrator.zhapp.weight.NoscrollViewPager;
import java.util.ArrayList;
import java.util.List;

/**
 * 移动仓库管理-物料接收
 */
public class MateLablePrint extends BaseActivity {

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

    private List<Fragment> list;
    private MyFragmentAdapter adapter;
    private MateLablePrintFragment mpf;
    private YsAndPzFragment ypf;

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

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

    public void initData() {
        setBack();
        title.setText("物料标签打印");
        mpf = MateLablePrintFragment.newInstance();
        ypf = YsAndPzFragment.newInstance();
        list = new ArrayList<>();
        list.add(mpf);
        list.add(ypf);
        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);
                        title.setText("物料标签打印");
                        break;
                    case R.id.rb2:
                        rb2.setTextColor(Color.WHITE);
                        rb1.setTextColor(Color.GRAY);
                        fl.setCurrentItem(1, false);
                        title.setText("验收与批准接收");
                        break;
                }
            }
        });
    }
    public TextView getToolbar() {
        return title;
    }
}