package com.hh.arome.ui.setting;

import android.content.Intent;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.appcompat.widget.Toolbar;

import com.hh.arome.R;
import com.hh.arome.common.ConfigData;
import com.hh.arome.ui.MainActivity;
import com.hh.arome.ui.base.BaseHHActivity;

public class SettingActivity extends BaseHHActivity implements View.OnClickListener {


    private Toolbar tb_center;
    private ImageView iv_1;
    private ImageView iv_gather;
    private ImageView iv_push;
    private ImageView iv_system_config;
    private ImageView iv_zolo;
    private ImageView iv_function;
    private RelativeLayout item_function;

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

    RelativeLayout item_base_info, item_gather, item_push, item_system_config, item_zolo;

    TextView tv_title_center;
    ImageButton iv_title_left;

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

        tv_title_center = findViewById(R.id.tv_title_center);
        iv_title_left = findViewById(R.id.iv_title_left);

        item_base_info = findViewById(R.id.item_base_info);
        item_gather = findViewById(R.id.item_gather);
        item_push = findViewById(R.id.item_push);
        item_system_config = findViewById(R.id.item_system_config);
        item_zolo = findViewById(R.id.item_zolo);

        tb_center = findViewById(R.id.tb_center);
        iv_1 = findViewById(R.id.iv_1);
        iv_gather = findViewById(R.id.iv_gather);
        iv_push = findViewById(R.id.iv_push);
        iv_system_config = findViewById(R.id.iv_system_config);
        iv_zolo = findViewById(R.id.iv_zolo);
        iv_title_left.setOnClickListener(this);
        item_base_info.setOnClickListener(this);
        item_gather.setOnClickListener(this);
        item_push.setOnClickListener(this);
        item_system_config.setOnClickListener(this);
        item_zolo.setOnClickListener(this);
        iv_function = findViewById(R.id.iv_function);
        item_function = findViewById(R.id.item_function);
        item_function.setOnClickListener(this);
    }

    @Override
    protected void initData() {
        tv_title_center.setText("设置");
    }

    @Override
    protected void initListener() {

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_title_left:
                startMainActivity();
                break;
            case R.id.item_base_info:
                startActivity(BaseInfoActivity.class);
                break;
            case R.id.item_gather:
                startActivity(GatherActivity.class);
                break;
            case R.id.item_push:
                startActivity(PushActivity.class);
                break;
            case R.id.item_system_config:
                startActivity(SystemConfigActivity.class);
                break;
            case R.id.item_zolo:
                startActivity(ZoloActivity.class);
                break;
            case R.id.item_function:
                startActivity(FunctionActivity.class);
                break;
        }
    }


    //返回键监听
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
            startMainActivity();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }


    private void startMainActivity() {
        ConfigData.mSessionId = "";
        startActivity(MainActivity.class);
        finish();
    }
}
