package com.example.watch.ui.activity

import android.content.Intent
import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.example.watch.R


class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

//        首次加载
        FirstRun()

//        登录判断
        login()


//        点击按钮Toast
//        val button4 = findViewById<Button>(R.id.CONNECT)
//        button4.setOnClickListener {
//            Toast.makeText(this, "112233!", Toast.LENGTH_LONG).show();
////            获取蓝牙权限
//            val mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter()
//            if (mBluetoothAdapter == null) {
//                // Device does not support Bluetooth
//                Toast.makeText(this, "当前设备不支持蓝牙!", Toast.LENGTH_LONG).show();
//            } else {
//                Toast.makeText(this, "当前设备不支持蓝牙!", Toast.LENGTH_LONG).show();
//            }
//        }


//        跳转BaseActivity
//        val intent = Intent(this, BaseActivity().javaClass)
//        startActivity(intent)


    }


    private fun startScan() {
        TODO("Not yet implemented")
    }

    private fun initView() {

//        val navBatton = findViewById<Button>(R.id.navigation_second)
//        navBatton.setOnClickListener {
//            //        跳到其他页面
//            val historyIntent = Intent(this, SearchActivity::class.java)
//            this.startActivity(historyIntent)
//        }

    }

    private fun login(){
        //        val login = 1
//        if(login == 1){
//            val LoginActivityIntent = Intent(this, LoginActivity::class.java)
//            startActivity(LoginActivityIntent)
//        }
    }

    private fun FirstRun(){
        val sharedPreferences = getSharedPreferences("FirstRun", 0)
        val first_run = sharedPreferences.getBoolean("First", true)
        if (first_run) {
            sharedPreferences.edit().putBoolean("First", false).commit()
            val ViewPageActivityIntent = Intent(this, ViewPageActivity::class.java)
            startActivity(ViewPageActivityIntent)
        } else {
            setContentView(R.layout.activity_main)
        }
    }

}
