package com.baoshi.swms.activity;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.viewpager2.widget.ViewPager2;

import com.baoshi.swms.R;
import com.baoshi.swms.adapter.WaybillDispatch;

import java.util.ArrayList;

/**
 * 运单调配 ACTIVITY
 *
 * @author Zhendong Zhou
 * @date   2021/12/3 18:05
 */
public class WaybillDispatchActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_waybill_dispatch);
        initPager();
    }

    private void initPager() {
        ViewPager2 viewPager = findViewById(R.id.dispatch_viewpager);
        ArrayList<Fragment> fragments = new ArrayList<>();
        //这里采用viewpager + fragment的方式是为了下方留有扩展，例如：统计信息等
        fragments.add(com.baoshi.swms.fragment.WaybillDispatch.newInstance(R.layout.dispatch_waybill_fragment));
        //与传统viewpager设置方式一样 区别是此处的适配器切换为fragment适配器
        WaybillDispatch fa = new WaybillDispatch(getSupportFragmentManager(), getLifecycle(), fragments);
        viewPager.setAdapter(fa);
    }
}