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

import static com.bonait.bnframework.MainApplication.getContext;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

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

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.modules.home.fragment.SheZhifragment;
import com.qmuiteam.qmui.widget.QMUITopBarLayout;

import butterknife.BindView;
import butterknife.ButterKnife;

public class DeviceInformationActivity extends BaseActivity {

    @BindView(R.id.topbar)
    QMUITopBarLayout mTopBar;
    private Context context;

    @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;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_deviceinformation);
        ButterKnife.bind(this);
        context=getContext();
        initTopBar();
        initFragment();
        initdata();
    }

    private void initTopBar() {
        mTopBar.setTitle("设备信息");
        mTopBar.addLeftImageButton(R.mipmap.fanhui,R.id.topbar).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();            }
        });
    }

    /**
     * 初始化数据
     */
    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("未知");
        }
    }

    /**
     *
     * viewPager里添加fragment
     */
    private void initFragment() {

    }
    //-------------------------配置viewPager与fragment关联----------------------------//

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

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