package com.hh.arome.ui.setting;

import android.view.View;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView;

import androidx.appcompat.widget.Toolbar;

import com.hh.arome.R;
import com.hh.arome.bean.DeviceConfigResultBean;
import com.hh.arome.bean.SimpleResultBean;
import com.hh.arome.common.ConfigData;
import com.hh.arome.mvp.contract.DeviceConfigUpdateContract;
import com.hh.arome.mvp.presenter.DeviceConfigUpdatePresenter;
import com.hh.arome.ui.base.BaseHHActivity;
import com.hh.arome.utlis.log.AppLogUtils;

public class FunctionActivity extends BaseHHActivity implements View.OnClickListener, DeviceConfigUpdateContract.View {


    private ImageButton iv_title_left;
    private TextView tv_title_center;
    private Toolbar tb_center;
    private EditText et_timeout;
    private TextView tv_confirm;

    DeviceConfigUpdatePresenter mDeviceConfigUpdatePresenter;

    @Override
    public int setLayout() {
        return R.layout.activity_setting_function;
    }

    @Override
    protected void initView() {
        super.initView();

        iv_title_left = findViewById(R.id.iv_title_left);
        tv_title_center = findViewById(R.id.tv_title_center);
        tb_center = findViewById(R.id.tb_center);
        et_timeout = findViewById(R.id.et_timeout);
        tv_confirm = findViewById(R.id.tv_confirm);
        iv_title_left.setOnClickListener(this);
        tv_confirm.setOnClickListener(this);
    }

    DeviceConfigResultBean deviceConfigBean;

    @Override
    protected void initData() {

        tv_title_center.setText("功能配置");

        mDeviceConfigUpdatePresenter = new DeviceConfigUpdatePresenter(this);

        deviceConfigBean = ConfigData.getDeviceConfigResultBean();

        if (deviceConfigBean == null) {
            AppLogUtils.e("deviceConfigBean == null");
            deviceConfigBean = new DeviceConfigResultBean();
        }

    }

    @Override
    protected void initListener() {

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_title_left:
                finish();
                break;
            case R.id.tv_confirm:
//                handleDataAndRequest();

                break;
        }
    }


    private void handleDataAndRequest() {

//        deviceConfigBean.setUseAlipayFace(isUseAlipayFace);

//        ToastUtils.showLongToast("本地配置已生效");
        ConfigData.setDeviceConfigResultBean(deviceConfigBean);

        // 开始请求接口
        mDeviceConfigUpdatePresenter.requestDeviceConfigUpdate(deviceConfigBean);

    }

    @Override
    public void showDeviceConfigUpdateData(SimpleResultBean resultBean) {

    }

    @Override
    public void showLoading() {

    }

    @Override
    public void dismissLoading() {

    }

    @Override
    public void showError(String msg) {

    }

    @Override
    public void showError(String url, String msg) {

    }
}
