package com.example.bpa.view.fragment.setting;

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

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CompoundButton;
import android.widget.Switch;

import com.example.bpa.R;
import com.example.bpa.app.Main;
import com.example.bpa.config.ConfigName;
import com.example.bpa.db.QueryDB;
import com.example.bpa.db.mode.BPA_SYSTEMSET;

import java.util.ArrayList;
import java.util.Arrays;

public class ovarparameter extends Fragment {

    Switch Switch_1,Switch_2;
    /**
     * 界面实例
     */
    private View view;

    //region 私有函数
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.activity_ovarparameter, container,false);
        Init();
        initEvents();
        return view;
    }
    //endregion


    //region 公有函数

    /**
     * 初始化
     */
    public void Init()
    {
        Switch_1 = view.findViewById(R.id.Switch_1);
        Switch_2= view.findViewById(R.id.Switch_2);
        Switch_1.setChecked(ConfigName.getInstance().IsUserDownOrder);
        Switch_2.setChecked(ConfigName.getInstance().AutomaticHeating);
    }
    /**
     * 初始化按钮事件
     */
    private void initEvents()
    {
        /**
         * 设置是否运行手动控制
         */
        Switch_1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                ConfigName.getInstance().IsUserDownOrder=b;
                Main.getInstance().SavePZ();
            }
        });

        /**
         * 设置是否是否自动加热
         */
        Switch_2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                ConfigName.getInstance().AutomaticHeating=b;
                Main.getInstance().SavePZ();
            }
        });
    }
    //endregion
}