package com.bonait.bnframework.modules.home.fragment.from;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.viewpager.widget.ViewPager;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;

import com.bonait.bnframework.R;
import com.bonait.bnframework.common.base.BaseActivity;
import com.bonait.bnframework.common.base.BaseFragment;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.tabbar.MainNavigateTabBar;
import com.bonait.bnframework.modules.home.fragment.GongnengFragment;
import com.bonait.bnframework.modules.home.fragment.from.fragment.Jcsjgl_sxgl_fragment;
import com.bonait.bnframework.modules.home.fragment.from.fragment.Jcsjgl_wl_fragment;
import com.qmuiteam.qmui.arch.QMUIFragment;
import com.qmuiteam.qmui.arch.QMUIFragmentPagerAdapter;
import com.qmuiteam.qmui.widget.QMUITopBarLayout;
import com.qmuiteam.qmui.widget.QMUIViewPager;
import com.qmuiteam.qmui.widget.tab.QMUITabSegment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class JcsjglActivity extends BaseActivity {

    @BindView(R.id.topbar)
    QMUITopBarLayout mTopBar;
    @BindView(R.id.tabs)
    QMUITabSegment tabs;
    @BindView(R.id.viewpager_wl)
    QMUIViewPager viewpager_wl;

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

        ButterKnife.bind(this);

        initTopBar();
        initFragment();
    }


    private void initTopBar() {
        mTopBar.setTitle("基础数据管理");
        mTopBar.addLeftImageButton(R.mipmap.fanhui,R.id.topbar).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }
    /**
     * viewPager里添加fragment
     */
    private void initFragment() {
        QMUIFragmentPagerAdapter adapter=new QMUIFragmentPagerAdapter(getSupportFragmentManager()) {
            @Override
            public int getCount() {
                return 2;
            }
            @Override
            public QMUIFragment createFragment(int position) {
                switch (position) {
                    case 0:
                        return new Jcsjgl_wl_fragment();
                    case 1:
                    default:
                        return new Jcsjgl_sxgl_fragment();
                }
            }
            @Override
            public CharSequence getPageTitle(int position) {
                switch (position) {
                    case 0:
                        return "物料管理";
                    case 1:
                    default:
                        return "属性管理";
                }
            }
        };
        viewpager_wl.setAdapter(adapter);
        tabs.setupWithViewPager(viewpager_wl,true);
    }
    //-------------------------配置viewPager与fragment关联----------------------------//

    @Override
    public void onDestroy() {
        super.onDestroy();
    }

    @Override
    protected boolean canDragBack() {
        return false;
    }
}