|
|
@@ -18,6 +18,7 @@ import android.view.KeyEvent
|
|
|
import android.view.View
|
|
|
import android.view.WindowManager
|
|
|
import android.view.animation.Animation
|
|
|
+import android.view.animation.DecelerateInterpolator
|
|
|
import android.view.animation.ScaleAnimation
|
|
|
import android.widget.*
|
|
|
import androidx.appcompat.app.AlertDialog
|
|
|
@@ -56,10 +57,9 @@ class MainActivity : AppCompatActivity(), ScannerFragment.OnDeviceSelectedListen
|
|
|
private val viewPager: ViewPager? = null
|
|
|
private val bottomNavigationView: BottomNavigationView? = null
|
|
|
private val mPagerAdapter: FragmentPagerAdapter? = null
|
|
|
-
|
|
|
var toast: Toast? = null
|
|
|
var mExitTime: Long = 0
|
|
|
- var HeartLine = arrayListOf<Any>(0, 0, 0)
|
|
|
+ var HeartLine = arrayListOf<Any>()
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
super.onCreate(savedInstanceState)
|
|
|
@@ -85,25 +85,6 @@ class MainActivity : AppCompatActivity(), ScannerFragment.OnDeviceSelectedListen
|
|
|
// 绘制心律图
|
|
|
ChartView()
|
|
|
|
|
|
- // 心跳动画根据心跳数进行加载 todo 获取心率数据后跑不动
|
|
|
- heartAnimate()
|
|
|
- }
|
|
|
-
|
|
|
- fun heartAnimate() {
|
|
|
- val mIdIvFace = findViewById<ImageView>(R.id.heart)
|
|
|
- val scaleAnimation = ScaleAnimation(
|
|
|
- 0.6f, 1f, 0.6f, 1f,
|
|
|
- Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f
|
|
|
- )
|
|
|
- // 设置动画持续时间
|
|
|
- scaleAnimation.duration = 1000
|
|
|
-
|
|
|
- // 为ImageView设置动画效果
|
|
|
- mIdIvFace.setAnimation(scaleAnimation)
|
|
|
- // 启动动画
|
|
|
-// scaleAnimation.startNow()
|
|
|
- scaleAnimation.repeatCount = Animation.INFINITE
|
|
|
- scaleAnimation.start()
|
|
|
}
|
|
|
|
|
|
fun setStatusBarColor(colorType: String) {
|
|
|
@@ -123,8 +104,8 @@ class MainActivity : AppCompatActivity(), ScannerFragment.OnDeviceSelectedListen
|
|
|
|
|
|
private fun linkHeartBand() {
|
|
|
val chainBtn = findViewById<Button>(R.id.chainBtn)
|
|
|
- chainBtn.setOnClickListener {
|
|
|
|
|
|
+ chainBtn.setOnClickListener {
|
|
|
if (isBLEEnabled()) {
|
|
|
if (!mDeviceConnected) {
|
|
|
showDeviceScanningDialog()
|
|
|
@@ -365,8 +346,6 @@ class MainActivity : AppCompatActivity(), ScannerFragment.OnDeviceSelectedListen
|
|
|
override fun onSportReceived(device: BluetoothDevice, step: Int, distance: Int, calorie: Int) {
|
|
|
findViewById<TextView>(R.id.sportNum).text = calorie.toString()
|
|
|
findViewById<TextView>(R.id.calNum).text = (calorie * 1.25).toInt().toString()
|
|
|
- findViewById<TextView>(R.id.ckNum).text = BaseData().calcCk(calorie)
|
|
|
-
|
|
|
}
|
|
|
|
|
|
// 连续两次回退
|
|
|
@@ -401,6 +380,10 @@ class MainActivity : AppCompatActivity(), ScannerFragment.OnDeviceSelectedListen
|
|
|
// 心率带已链接
|
|
|
bindHeartSuccess()
|
|
|
|
|
|
+ // 心跳动画根据心跳数进行加载,大于100速度快
|
|
|
+ val scalegetAnim: Animation = Animate().getScaleAnimation(heartRate)
|
|
|
+ findViewById<TextView>(R.id.heartReal).startAnimation(scalegetAnim)
|
|
|
+
|
|
|
//心跳
|
|
|
findViewById<TextView>(R.id.heartReal).text = heartRate.toString()
|
|
|
if (rrIntervals != null) {
|
|
|
@@ -423,16 +406,15 @@ class MainActivity : AppCompatActivity(), ScannerFragment.OnDeviceSelectedListen
|
|
|
)
|
|
|
)
|
|
|
|
|
|
+// 计算CK
|
|
|
+ findViewById<TextView>(R.id.ckNum).text = BaseData().calcCk(heartRate)
|
|
|
+
|
|
|
// todo 最大心率 和 平均心率
|
|
|
// val arrayList = ArrayList<Int>()
|
|
|
|
|
|
-
|
|
|
-// 运动强度
|
|
|
-// 男:((-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 =锻炼持续时间的时间(以小时计)
|
|
|
- var ActityVal =
|
|
|
- BaseData().calcActivity(heartRate, BaseData().sex, BaseData().weight, BaseData().age, 1)
|
|
|
+// var ActityVal =
|
|
|
+// BaseData().calcActivity(heartRate, BaseData().sex, BaseData().weight, BaseData().age, 0.8)
|
|
|
+ var ActityVal = BaseData().clacActLevel(heartRate)
|
|
|
this.findViewById<TextView>(R.id.activLevel).text = ActityVal
|
|
|
|
|
|
|
|
|
@@ -533,10 +515,10 @@ class MainActivity : AppCompatActivity(), ScannerFragment.OnDeviceSelectedListen
|
|
|
|
|
|
fun ChartView() {
|
|
|
val aaChartView = findViewById<AAChartView>(R.id.aa_chart_view)
|
|
|
-// arrayOf(0, 0)
|
|
|
val aaChartModel = AAChartModel()
|
|
|
.chartType(AAChartType.Line)
|
|
|
.backgroundColor("#fff")
|
|
|
+ .colorsTheme(arrayOf("#F90505"))
|
|
|
.series(
|
|
|
arrayOf(
|
|
|
AASeriesElement()
|