From 912c02716f98524ba8a745a764dde3496254e128 Mon Sep 17 00:00:00 2001 From: Caisking Date: Mon, 28 Jul 2025 14:24:02 +0800 Subject: [PATCH] =?utf8?q?=E5=B1=8F=E8=94=BDgps=E7=9A=84=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/traing/include/TraingEnddataView.h | 2 ++ .../nativeui/traing/src/TraingEnddataView.cpp | 14 ++++++++++---- .../training_card/src/TraingCardPresenter.cpp | 8 ++++++-- .../training_card/src/TrainingControlView.cpp | 16 +++++++++------- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataView.h index 23f89f044..756bba8f0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataView.h @@ -135,6 +135,8 @@ private: UIImageView *imageLine11 = nullptr; UIImageView *imageLine12 = nullptr; + UICanvas *canvas = nullptr; + bool viewiInitStatus{false}; std::vector trackSegments_; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp index 5ffceca2e..c2d140b04 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp @@ -481,6 +481,11 @@ void TraingEnddataView::DeInit() { exitLabel = nullptr; } + if (canvas) { + delete canvas; + canvas = nullptr; + } + if (scrollView_) { delete scrollView_; scrollView_ = nullptr; @@ -651,7 +656,7 @@ void TraingEnddataView::InitData() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Stride length set: %s\r\n", strideStr.c_str()); // 打印步幅 } - +#if defined(BOARD_W9) || defined(BOARD_N9) //读取一下gps文件 std::string gpsFilePath = TraingModel::GetInstance()->GetCanvasDataPath(enddata->starttime); @@ -661,8 +666,8 @@ void TraingEnddataView::InitData() { return; } } +#endif } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingEnddataView data initialization complete.\r\n"); } @@ -691,9 +696,9 @@ void TraingEnddataView::OnStart() { container_->SetOnDragListener(presenter_); SetKeyActListener(); - +#if defined(BOARD_W9) || defined(BOARD_N9) ///////////////////////////gps轨迹测试////////////////////// - UICanvas *canvas = new UICanvas(); + canvas = new UICanvas(); canvas->SetHeight(CANVAS_SIZE); canvas->SetWidth(CANVAS_SIZE); canvas->SetPosition(33, 100); @@ -701,6 +706,7 @@ void TraingEnddataView::OnStart() { GenerateTrackPoints(); DrawTrackSegment(canvas); DrawMarkers(canvas); +#endif } void TraingEnddataView::OnSetUpView() { 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 230ce9ddd..58813f1b4 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,7 +101,9 @@ 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) { @@ -127,7 +129,8 @@ void TraingCardPresenter::UpdateTimeOfControl() { TrainingControlView::GetInstance()->GetTimeLabel()->SetText( TimeStr.c_str()); } - if(TrainingControlView::GetInstance()->GetGpsStatusLabel() != nullptr) { +#if defined(BOARD_W9) || defined(BOARD_N9) + if (TrainingControlView::GetInstance()->GetGpsStatusLabel() != nullptr) { //获取GPS状态 bool gpsStatus = TraingModel::GetInstance()->GetGPSConnectState(); std::string gpsStatusStr; @@ -140,6 +143,7 @@ void TraingCardPresenter::UpdateTimeOfControl() { } TrainingControlView::GetInstance()->GetGpsStatusLabel()->SetText(gpsStatusStr.c_str()); } +#endif } 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 5a1353315..b6709e41a 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 @@ -5,6 +5,7 @@ #include "common/image_cache_manager.h" #include "components/ui_button.h" #include "components/ui_label_ext.h" +#include "languagecode/LanguageInit.h" #include "string" #include "traing/Training_UiConfig.h" #include "traing/include/TraingModel.h" @@ -14,7 +15,6 @@ #include #include #include -#include "languagecode/LanguageInit.h" namespace OHOS { static TrainingControlView *g_pTrainingControlView{nullptr}; @@ -74,20 +74,22 @@ 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); Add(imagepoint); + +#if defined(BOARD_W9) || defined(BOARD_N9) + InitLabel(gpsstatus, 83, 365, 300, 35, "label1", "gps:定位中...", + DEFAULT_VECTOR_FONT_FILENAME, 30); + gpsstatus->SetTextColor(Color::Red()); + Add(gpsstatus); +#endif } UILabelExt *TrainingControlView::GetLabel() { return labelstop; } @@ -113,7 +115,7 @@ void TrainingControlView::DeInit() { delete labelstop; labelstop = nullptr; } - if(gpsstatus != nullptr) { + if (gpsstatus != nullptr) { delete gpsstatus; gpsstatus = nullptr; } -- 2.17.1