优化训练蓝牙控制接口
authorCaisking <3449750381@qq.com>
Mon, 22 Apr 2024 03:59:18 +0000 (11:59 +0800)
committerCaisking <3449750381@qq.com>
Mon, 22 Apr 2024 03:59:18 +0000 (11:59 +0800)
code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardView.h
code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardView.cpp

index 604c5be..a8e0bf0 100644 (file)
@@ -81,7 +81,7 @@ namespace OHOS
         void ShowGetTagView();\r
         void ShowEndView();\r
         bool RefreshEndView();\r
-        UIView *GetTraingCrad();\r
+        UICrossView *GetTraingCrad();\r
         int GetCurrentPage();\r
         void SetPopupViewStatus(PopupType type, bool status);\r
         UIImageAnimatorView *GetAnimator();\r
index 5ce1228..fd78117 100644 (file)
@@ -304,10 +304,19 @@ namespace OHOS
         default:\r
             break;\r
         }\r
-        \r
+\r
         ExerciseState cmdState = static_cast<ExerciseState>(cmd->controlmd);\r
+        if (TraingCardView::GetInstance()->GetTraingCrad()->GetCurrentPageId() != Control_Card::CONTROL && cmdState != ExerciseState::Start)\r
+        {\r
+            // 跳转卡片界面\r
+            TraingCardView::GetInstance()->GetTraingCrad()->SetHorCurrentPage(Control_Card::CONTROL);\r
+        }\r
+\r
+        // 结束\r
         if (cmdState == ExerciseState::End)\r
         {\r
+            TraingModel::GetInstance()->SetSportState(ExerciseState::End);\r
+            ControlSensor(ExerciseState::End);\r
             if (TraingCardView::GetInstance()->RefreshEndView())\r
             {\r
                 // 进行存储操作?\r
@@ -317,8 +326,36 @@ namespace OHOS
             {\r
                 NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGMORE);\r
             }\r
+            return true;\r
+        }\r
+        // 暂停和恢复\r
+        if (cmdState == ExerciseState::Continue || cmdState == ExerciseState::Pause)\r
+        {\r
+            // 开始状态\r
+            if (TraingModel::GetInstance()->GetSportState() == ExerciseState::Start || TraingModel::GetInstance()->GetSportState() == ExerciseState::Continue)\r
+            {\r
+                TrainingControlView::GetInstance()->GetLabel()->SetText("继续");\r
+                TrainingControlView::GetInstance()->GetButton()->SetImageSrc(SPORT_CONTINUE_IMAGE, SPORT_CONTINUE_IMAGE);\r
+                // 设置为暂停状态\r
+                TraingModel::GetInstance()->SetSportState(ExerciseState::Pause);\r
+                // 暂停计时器\r
+                PauseTimer();\r
+                // 暂停运动库\r
+                ControlSensor(ExerciseState::Pause);\r
+            }\r
+            // 暂停状态\r
+            if (TraingModel::GetInstance()->GetSportState() == ExerciseState::Pause)\r
+            {\r
+                TrainingControlView::GetInstance()->GetLabel()->SetText("暂停");\r
+                TrainingControlView::GetInstance()->GetButton()->SetImageSrc(SPORT_PAUSE_IMAGE, SPORT_PAUSE_IMAGE);\r
+                // 设置为继续状态\r
+                TraingModel::GetInstance()->SetSportState(ExerciseState::Continue);\r
+                // 恢复计时器\r
+                ResumeTimer();\r
+                // 恢复运动库\r
+                ControlSensor(ExerciseState::Continue);\r
+            }\r
         }\r
-        ControlSensor(static_cast<ExerciseState>(cmdState));\r
         return true;\r
     }\r
 \r
index bb1c894..cd91f93 100644 (file)
@@ -79,7 +79,7 @@ namespace OHOS
         // swipe_->HorAdd(DetailView);\r
 \r
         swipe_->VerAdd(DetailView, UICrossView::VPage::DOWN_PAGE);\r
-        swipe_->SetHorCurrentPage(Control_Card::CONTROL);\r
+        swipe_->SetHorCurrentPage(Control_Card::DATA);\r
 \r
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingCardView::InitPage over");\r
     }\r
@@ -444,7 +444,7 @@ namespace OHOS
     }\r
 \r
     /*获取卡片View单例*/\r
-    UIView *TraingCardView::GetTraingCrad()\r
+    UICrossView *TraingCardView::GetTraingCrad()\r
     {\r
         return swipe_;\r
     }\r