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

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;

import com.bonait.bnframework.R;
import com.bonait.bnframework.common.base.BaseFragment;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.bonait.bnframework.modules.home.fragment.from.JcsjglActivity;
import com.bonait.bnframework.modules.home.fragment.from.LogActivity;
import com.bonait.bnframework.modules.home.fragment.from.PlcControlActivity;
import com.bonait.bnframework.modules.home.fragment.from.RealTimeActivity;
import com.orhanobut.logger.Logger;
import com.qmuiteam.qmui.widget.QMUITopBarLayout;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class GuanLifragment extends BaseFragment {

    @BindView(R.id.topbar)
    QMUITopBarLayout mTopBar;//顶部标题
    private Context context;

    public GuanLifragment() {
    }

    @Override
    protected View onCreateView() {
        View root = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_guan_li, null);
        ButterKnife.bind(this, root);
        return root;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        context = getContext();
        initTopBar();
    }

    /**
     * 初始化TopBar
     */
    private void initTopBar() {
        mTopBar.setTitle("系统管理");
    }
    @OnClick({R.id.plckz,R.id.rzgl,R.id.ssjk})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.plckz://
                skipToActivity(PlcControlActivity.class);
                //ConfigName.getInstance().fragmentAdapter.replaceFragment(4,new PlcControlActivity());
                break;
            case R.id.rzgl://
                skipToActivity(LogActivity.class);

                //ConfigName.getInstance().fragmentAdapter.replaceFragment(4,new LogActivity());
                break;
            case R.id.ssjk://
                skipToActivity(RealTimeActivity.class);

                //ConfigName.getInstance().fragmentAdapter.replaceFragment(4,new RealTimeActivity());
                break;
        }
    }
    @Override
    public void onDestroy() {
        super.onDestroy();
        Logger.d("第一页销毁");
    }

    /**
     * 当在activity设置viewPager + BottomNavigation + fragment时，
     * 为防止viewPager左滑动切换界面，与fragment左滑返回上一界面冲突引起闪退问题，
     * 必须加上此方法，禁止fragment左滑返回上一界面。
     * <p>
     * 切记！切记！切记！否则会闪退！
     * <p>
     * 当在fragment设置viewPager + BottomNavigation + fragment时，则不会出现这个问题。
     */
    @Override
    protected boolean canDragBack() {
        return false;
    }
}