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

import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;

import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;

import com.bonait.bnframework.R;
import com.bonait.bnframework.common.base.BaseFragment;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.image.MyBitmapUtils;
import com.orhanobut.logger.Logger;

import butterknife.BindView;
import butterknife.ButterKnife;

public class SystemDeviceinFragment extends BaseFragment {

    @BindView(R.id.edittext1)
    EditText edittext1;
    @BindView(R.id.edittext2)
    EditText edittext2;
    @BindView(R.id.edittext3)
    EditText edittext3;
    @BindView(R.id.edittext4)
    EditText edittext4;
    @BindView(R.id.edittext5)
    EditText edittext5;
    @BindView(R.id.edittext6)
    EditText edittext6;
    @BindView(R.id.edittext7)
    EditText edittext7;
//    @BindView(R.id.image)
//    ImageView image;
    private Context context;
    @Override
    protected View onCreateView() {
        View root = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_system_devicein, null);
        ButterKnife.bind(this, root);
        return root;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        Logger.d("我的fragment创建");
        context = getContext();
        initdata();
    }

    /**
     * 初始化数据
     */
    public void initdata()
    {
        if(ConfigName.getInstance().organizeMode !=null && ConfigName.getInstance().deviceInformation!=null)
        {
            edittext1.setText(ConfigName.getInstance().deviceInformation.id);
            edittext2.setText(ConfigName.getInstance().deviceInformation.deviceName);
            edittext3.setText(ConfigName.getInstance().deviceInformation.deviceLoc);
            edittext4.setText(ConfigName.getInstance().organizeMode.tel);
            edittext5.setText(ConfigName.getInstance().deviceInformation.deviceAddr);
            edittext6.setText(ConfigName.getInstance().organizeMode.id);
            edittext7.setText(ConfigName.getInstance().organizeMode.store_Name);

//            if(ConfigName.getInstance().organizeMode.logo!=null)
//            {
//                new MyBitmapUtils().disPlay(image,ConfigName.getInstance().organizeMode.logo);
//            }
        }else
        {
            edittext1.setText(ConfigName.getInstance().DeviceId);
            edittext2.setText(ConfigName.getInstance().versionSelectionEnum);
            edittext3.setText("未知");
            edittext4.setText("");
            edittext5.setText("未知");
            edittext6.setText("未知");
            edittext7.setText("未知");
        }
    }
    @Override
    public void onDestroy() {
        super.onDestroy();
        Logger.d("我的fragment销毁");
    }

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