运动卡片控制界面增加gps状态标签
authorCaisking <Casiking@zhihuishixun.com>
Tue, 1 Jul 2025 09:36:03 +0000 (17:36 +0800)
committerCaisking <Casiking@zhihuishixun.com>
Tue, 1 Jul 2025 09:36:03 +0000 (17:36 +0800)
code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingControlView.h
code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingControlView.cpp

index bfe13d9..d0358c1 100644 (file)
@@ -47,6 +47,7 @@ namespace OHOS
         UIButton *GetButton();
 
         UILabelExt *GetTimeLabel();
+        UILabelExt *GetGpsStatusLabel();
 
     private:
         UIView::OnDragListener *draglistener{nullptr};
@@ -62,6 +63,8 @@ namespace OHOS
 
         UIImageView *imagepoint = nullptr;
 
+        UILabelExt *gpsstatus = nullptr;
+
         void ClearAll(void);
     };
 }
index f7ac60c..230ce9d 100644 (file)
@@ -101,9 +101,7 @@ void TraingCardPresenter::ModifiesTime() {
   }\r
 \r
   if (TimeStr.empty()) {\r
-    WEARABLE_LOGE(\r
-        WEARABLE_LOG_MODULE_APP,\r
-        "TraingModel::GetInstance()->DisplayMotionDuration() nullptr");\r
+    WEARABLE_LOGE( WEARABLE_LOG_MODULE_APP,"TraingModel::GetInstance()->DisplayMotionDuration() nullptr");\r
     return;\r
   }\r
   if (TrainingControlView::GetInstance()->GetTimeLabel() != nullptr) {\r
@@ -129,6 +127,19 @@ void TraingCardPresenter::UpdateTimeOfControl() {
     TrainingControlView::GetInstance()->GetTimeLabel()->SetText(\r
         TimeStr.c_str());\r
   }\r
+  if(TrainingControlView::GetInstance()->GetGpsStatusLabel() != nullptr) {\r
+    //获取GPS状态\r
+    bool gpsStatus = TraingModel::GetInstance()->GetGPSConnectState();\r
+    std::string gpsStatusStr;\r
+    if (gpsStatus) {\r
+      gpsStatusStr = "GPS定位成功";\r
+      TrainingControlView::GetInstance()->GetGpsStatusLabel()->SetTextColor(Color::Green());\r
+    } else {\r
+      gpsStatusStr = "GPS未定位成功";\r
+      TrainingControlView::GetInstance()->GetGpsStatusLabel()->SetTextColor(Color::Red());\r
+    }\r
+    TrainingControlView::GetInstance()->GetGpsStatusLabel()->SetText(gpsStatusStr.c_str());\r
+  }\r
 }\r
 void TraingCardPresenter::UpdateTimeOfData() {\r
   std ::string TimeStr = TraingModel::GetInstance()->DisplayMotionDuration();\r
index 1ca79f2..5a13533 100644 (file)
@@ -74,11 +74,16 @@ void TrainingControlView::InitView() {
     labelstop->SetTextId(STR_PAUSE);
   }
 
+  InitLabel(gpsstatus, 83, 365, 300, 35, "label1", "gps:定位中...",
+               DEFAULT_VECTOR_FONT_FILENAME, 30);
+  gpsstatus->SetTextColor(Color::Red());
+
   // 添加到视图中
   Add(labeltitle);
   Add(labeltimer);
   Add(labelend);
   Add(labelstop);
+  Add(gpsstatus);
 
   // 初始化 Image
   InitImageView(imagepoint, 193, 421, 80, 20, "image1", CONTROL_POINT_IMAGE);
@@ -108,6 +113,10 @@ void TrainingControlView::DeInit() {
     delete labelstop;
     labelstop = nullptr;
   }
+  if(gpsstatus != nullptr) {
+    delete gpsstatus;
+    gpsstatus = nullptr;
+  }
 
   // 删除Button
   if (buttonEnd != nullptr) {
@@ -136,4 +145,5 @@ void TrainingControlView::PreLoad(void) {
 void TrainingControlView::UnLoad(void) {}
 
 UILabelExt *TrainingControlView::GetTimeLabel() { return labeltimer; }
+UILabelExt *TrainingControlView::GetGpsStatusLabel() { return gpsstatus; }
 } // namespace OHOS