From a75c10e7f56ba10173079e528a9c337d734af6bd Mon Sep 17 00:00:00 2001 From: Caisking Date: Tue, 1 Jul 2025 17:36:03 +0800 Subject: [PATCH] =?utf8?q?=E8=BF=90=E5=8A=A8=E5=8D=A1=E7=89=87=E6=8E=A7?= =?utf8?q?=E5=88=B6=E7=95=8C=E9=9D=A2=E5=A2=9E=E5=8A=A0gps=E7=8A=B6?= =?utf8?q?=E6=80=81=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../training_card/include/TrainingControlView.h | 3 +++ .../training_card/src/TraingCardPresenter.cpp | 17 ++++++++++++++--- .../training_card/src/TrainingControlView.cpp | 10 ++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingControlView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingControlView.h index bfe13d96f..d0358c15d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingControlView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingControlView.h @@ -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); }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp index f7ac60cf6..230ce9ddd 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp @@ -101,9 +101,7 @@ void TraingCardPresenter::ModifiesTime() { } if (TimeStr.empty()) { - WEARABLE_LOGE( - WEARABLE_LOG_MODULE_APP, - "TraingModel::GetInstance()->DisplayMotionDuration() nullptr"); + WEARABLE_LOGE( WEARABLE_LOG_MODULE_APP,"TraingModel::GetInstance()->DisplayMotionDuration() nullptr"); return; } if (TrainingControlView::GetInstance()->GetTimeLabel() != nullptr) { @@ -129,6 +127,19 @@ void TraingCardPresenter::UpdateTimeOfControl() { TrainingControlView::GetInstance()->GetTimeLabel()->SetText( TimeStr.c_str()); } + if(TrainingControlView::GetInstance()->GetGpsStatusLabel() != nullptr) { + //获取GPS状态 + bool gpsStatus = TraingModel::GetInstance()->GetGPSConnectState(); + std::string gpsStatusStr; + if (gpsStatus) { + gpsStatusStr = "GPS定位成功"; + TrainingControlView::GetInstance()->GetGpsStatusLabel()->SetTextColor(Color::Green()); + } else { + gpsStatusStr = "GPS未定位成功"; + TrainingControlView::GetInstance()->GetGpsStatusLabel()->SetTextColor(Color::Red()); + } + TrainingControlView::GetInstance()->GetGpsStatusLabel()->SetText(gpsStatusStr.c_str()); + } } void TraingCardPresenter::UpdateTimeOfData() { std ::string TimeStr = TraingModel::GetInstance()->DisplayMotionDuration(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingControlView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingControlView.cpp index 1ca79f226..5a1353315 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingControlView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingControlView.cpp @@ -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 -- 2.17.1