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

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

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.modules.home.fragment.from.DeviceInformationActivity;
import com.bonait.bnframework.modules.home.fragment.from.ImageSourceActivity;
import com.bonait.bnframework.modules.home.fragment.from.PlcControlActivity;
import com.bonait.bnframework.modules.home.fragment.from.SystemParameterActivity;
import com.bonait.bnframework.modules.home.fragment.from.DzcjyActivity;
import com.bonait.bnframework.modules.home.fragment.from.WdszActivity;
import com.orhanobut.logger.Logger;
import com.qmuiteam.qmui.widget.QMUITopBarLayout;

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

public class SheZhifragment extends BaseFragment {


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

    public SheZhifragment() {
    }

    @Override
    protected View onCreateView() {
        View root = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_she_zhi, 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.xtcs,R.id.imagegl,R.id.shebeixinxi
    ,R.id.plckz,R.id.dzcsz,R.id.wdsz})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.plckz://
                skipToActivity(PlcControlActivity.class);
                break;
            case R.id.xtcs://
                skipToActivity(SystemParameterActivity.class);
                break;
            case R.id.imagegl://
                skipToActivity(ImageSourceActivity.class);
                break;
            case R.id.shebeixinxi://
                skipToActivity(DeviceInformationActivity.class);
                break;

            case R.id.dzcsz://电子秤设置
                skipToActivity(DzcjyActivity.class);
                break;
            case R.id.wdsz://温度设置
                skipToActivity(WdszActivity.class);
                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;
    }
}