Sfoglia il codice sorgente

调整加载顺序

Signed-off-by: duanchangpeng <838560574@qq.com>
duanchangpeng 4 anni fa
parent
commit
a923949426

+ 16 - 19
app/src/main/java/com/example/watch/ui/activity/MainActivity.kt

@@ -66,9 +66,6 @@ class MainActivity : AppCompatActivity(), ScannerFragment.OnDeviceSelectedListen
 //        首次加载
         FirstRun()
 
-//        登录判断
-        login()
-
 //        连接心率带
         linkHeartBand()
 
@@ -84,8 +81,6 @@ class MainActivity : AppCompatActivity(), ScannerFragment.OnDeviceSelectedListen
 //        绘制心律图
         ChartView()
 
-        //        test 根据心率强度计算背景色和提示语
-//        headStatus(60)
     }
 
     fun setStatusBarColor(colorType: String) {
@@ -149,6 +144,21 @@ class MainActivity : AppCompatActivity(), ScannerFragment.OnDeviceSelectedListen
         mManager!!.setManagerCallbacks(this)
     }
 
+    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 OneActivityIntent = Intent(this, OneActivity::class.java)
+            startActivity(OneActivityIntent)
+        } else {
+
+//            setContentView(R.layout.activity_main)
+            //        登录判断
+            login()
+        }
+    }
+
     private fun login() {
         val sharedPreferences = getSharedPreferences("login", 0)
         val loginState = sharedPreferences.getBoolean("token", true)
@@ -162,20 +172,7 @@ class MainActivity : AppCompatActivity(), ScannerFragment.OnDeviceSelectedListen
         }
     }
 
-    private fun FirstRun() {
-        val sharedPreferences = getSharedPreferences("FirstRun", 0)
-        val first_run = sharedPreferences.getBoolean("First", true)
-//        val first_run = true
-        if (first_run) {
-            sharedPreferences.edit().putBoolean("First", false).commit()
-//            val ViewPageActivityIntent = Intent(this, ViewPageActivity::class.java)
-//            startActivity(ViewPageActivityIntent)
-            val OneActivityIntent = Intent(this, OneActivity::class.java)
-            startActivity(OneActivityIntent)
-        } else {
-            setContentView(R.layout.activity_main)
-        }
-    }
+
 
     protected var mManager: WearManager? = null
     protected var mLoading: LoadingDialog? = null