|
|
@@ -7,6 +7,7 @@ import android.content.Context
|
|
|
import android.content.DialogInterface
|
|
|
import android.content.Intent
|
|
|
import android.content.pm.PackageManager
|
|
|
+import android.graphics.Color
|
|
|
import android.net.Uri
|
|
|
import android.os.Bundle
|
|
|
import android.os.Handler
|
|
|
@@ -17,6 +18,7 @@ import android.view.KeyEvent
|
|
|
import android.view.View
|
|
|
import android.view.WindowManager
|
|
|
import android.widget.Button
|
|
|
+import android.widget.ImageView
|
|
|
import android.widget.TextView
|
|
|
import android.widget.Toast
|
|
|
import androidx.appcompat.app.AlertDialog
|
|
|
@@ -31,9 +33,8 @@ import com.google.android.material.bottomnavigation.BottomNavigationView
|
|
|
import com.yanzhenjie.permission.AndPermission
|
|
|
import com.yanzhenjie.permission.runtime.Permission
|
|
|
import kotlinx.android.synthetic.main.activity_main.*
|
|
|
-import org.w3c.dom.Text
|
|
|
import timber.log.Timber
|
|
|
-import com.example.watch.ui.activity.BaseData
|
|
|
+
|
|
|
|
|
|
class MainActivity : AppCompatActivity(), ScannerFragment.OnDeviceSelectedListener,
|
|
|
WearManagerCallbacks {
|
|
|
@@ -340,7 +341,7 @@ class MainActivity : AppCompatActivity(), ScannerFragment.OnDeviceSelectedListen
|
|
|
return super.onKeyDown(keyCode, event)
|
|
|
}
|
|
|
|
|
|
-// 获取心率数据
|
|
|
+ // 获取心率数据
|
|
|
override fun onHeartRateMeasurementReceived(
|
|
|
device: BluetoothDevice,
|
|
|
heartRate: Int,
|
|
|
@@ -355,6 +356,8 @@ class MainActivity : AppCompatActivity(), ScannerFragment.OnDeviceSelectedListen
|
|
|
energyExpanded,
|
|
|
rrIntervals
|
|
|
)
|
|
|
+// 心率带已链接
|
|
|
+ bindHeartSuccess()
|
|
|
|
|
|
//心跳
|
|
|
findViewById<TextView>(R.id.heartReal).text = heartRate.toString()
|
|
|
@@ -362,26 +365,47 @@ class MainActivity : AppCompatActivity(), ScannerFragment.OnDeviceSelectedListen
|
|
|
// 男:((-55.0969 +(0.6309×HR)+(0.1988 xW)+(0.2017×A))/ 4.184)×60 xT
|
|
|
// 女:((-20.4022 +(0.4472×HR) - (0.1263 xW)+(0.074×A))/ 4.184)×60 xT
|
|
|
// 其中,HR =心率(次/分钟) W =体重(公斤) A=年龄(岁) T =锻炼持续时间的时间(以小时计)
|
|
|
- this.findViewById<TextView>(R.id.activLevel).text = BaseData().calcActivity(heartRate,BaseData().sex,BaseData().weight,BaseData().age,1)
|
|
|
+ this.findViewById<TextView>(R.id.activLevel).text =
|
|
|
+ BaseData().calcActivity(heartRate, BaseData().sex, BaseData().weight, BaseData().age, 1)
|
|
|
// todo 全部卡路里
|
|
|
-// this.findViewById<TextView>(R.id.calNum).text = ().toString()
|
|
|
+ this.findViewById<TextView>(R.id.calNum).text =
|
|
|
+ BaseData().calcSumCalc(heartRate, BaseData().sex, BaseData().weight, BaseData().age, 1)
|
|
|
// todo 运动卡路里
|
|
|
+ this.findViewById<TextView>(R.id.sportNum).text =
|
|
|
+ BaseData().calcSportCalc(
|
|
|
+ heartRate,
|
|
|
+ BaseData().sex,
|
|
|
+ BaseData().weight,
|
|
|
+ BaseData().age,
|
|
|
+ 1
|
|
|
+ )
|
|
|
|
|
|
// todo CK
|
|
|
+ this.findViewById<TextView>(R.id.ckNum).text =
|
|
|
+ BaseData().calcSumCalc(heartRate, BaseData().sex, BaseData().weight, BaseData().age, 1)
|
|
|
|
|
|
-}
|
|
|
+ }
|
|
|
|
|
|
- fun setDeafultData(){
|
|
|
- this.findViewById<TextView>(R.id.height).text = BaseData().heigh.toString()
|
|
|
+ fun setDeafultData() {
|
|
|
+ this.findViewById<TextView>(R.id.height).text = BaseData().heigh.toString()
|
|
|
// var sex = if (BaseData().sex == 1) "男" else "女"
|
|
|
// this.findViewById<TextView>(R.id.sex).text = sex
|
|
|
- this.findViewById<TextView>(R.id.age).text = BaseData().age.toString()
|
|
|
- this.findViewById<TextView>(R.id.weight).text = BaseData().weight.toString()
|
|
|
- this.findViewById<TextView>(R.id.peaceHr).text = BaseData().peaceHr.toString()
|
|
|
+ this.findViewById<TextView>(R.id.age).text = BaseData().age.toString()
|
|
|
+ this.findViewById<TextView>(R.id.weight).text = BaseData().weight.toString()
|
|
|
+ this.findViewById<TextView>(R.id.peaceHr).text = BaseData().peaceHr.toString()
|
|
|
|
|
|
this.findViewById<TextView>(R.id.activLevel).text = "--"
|
|
|
this.findViewById<TextView>(R.id.heartReal).text = "--"
|
|
|
}
|
|
|
+
|
|
|
+ // 心率带已链接
|
|
|
+ fun bindHeartSuccess() {
|
|
|
+ findViewById<ImageView>(R.id.chain).setVisibility(View.GONE); // 隐藏
|
|
|
+ findViewById<Button>(R.id.chainBtn).setVisibility(View.GONE); // 隐藏
|
|
|
+ findViewById<TextView>(R.id.unchain).text = "心率带已连接"
|
|
|
+ findViewById<TextView>(R.id.unchain).setTextColor(Color.parseColor("#AACC03"))
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|