From 2091a7a9bcbb74eccf683d4722b35224db0d4340 Mon Sep 17 00:00:00 2001 From: Caisking Date: Tue, 1 Jul 2025 17:37:06 +0800 Subject: [PATCH] =?utf8?q?=E8=BF=90=E5=8A=A8=E5=BC=80=E5=A7=8B=E5=89=8D?= =?utf8?q?=E8=BF=9B=E8=A1=8CGPS=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../traing/include/TraingNomalPresenter.h | 4 +- .../nativeui/traing/include/TraingNomalView.h | 2 + .../traing/src/TraingNomalPresenter.cpp | 11 ++++- .../nativeui/traing/src/TraingNomalView.cpp | 44 ++++++++++++++++++- 4 files changed, 56 insertions(+), 5 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingNomalPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingNomalPresenter.h index cc6134cfe..b1b0b9006 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingNomalPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingNomalPresenter.h @@ -4,7 +4,7 @@ #include "Presenter.h" #include "TraingNomalView.h" - +#include "ModelListenerSample.h" namespace OHOS { class TraingNomalView; @@ -12,6 +12,7 @@ namespace OHOS class TraingNomalPresenter : public Presenter, public UIView::OnClickListener, public RootView::OnKeyActListener, + public ModelListenerSample, public UIView::OnDragListener { public: @@ -23,6 +24,7 @@ namespace OHOS void OnResume() override; void OnStop() override; void NavigateBack(); + void Notify() override; static TraingNomalPresenter *GetInstance(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingNomalView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingNomalView.h index ce3aab93f..185323268 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingNomalView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingNomalView.h @@ -59,6 +59,7 @@ namespace OHOS void PreLoad(void); void UpdateTraingTag(); // 更新训练目标 + bool updateview(); private: UIView::OnDragListener *draglistener{nullptr}; TraingNomalView(TraingNomalView &&) = delete; @@ -75,6 +76,7 @@ namespace OHOS UILabel *heartrate_label_ = nullptr; bool viewiInitStatus{false}; + bool updat_view_status{false}; }; } // namespace OHOS #endif // TraingNomal_PRESENTER_H diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalPresenter.cpp index 4a6740da3..09c3cbf2a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalPresenter.cpp @@ -43,13 +43,13 @@ namespace OHOS void TraingNomalPresenter::OnStart() { - + TraingModel::GetInstance()->Traing_StartTimer(1000); Presenter::OnStart(); } void TraingNomalPresenter::OnPause(void) { - + TraingModel::GetInstance()->Traing_StopTimer(); Presenter::OnPause(); } @@ -128,4 +128,11 @@ namespace OHOS } return true; } + + void TraingNomalPresenter::Notify() + { + //获取gps定位状态 + TraingNomalView::GetInstance()->updateview(); + + } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalView.cpp index 1f20d6c3e..5df8c8188 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalView.cpp @@ -19,18 +19,19 @@ namespace OHOS TraingNomalView::TraingNomalView() { + TraingModel::GetInstance()->start_heart_gps(); g_pTraingNomalView = this; } TraingNomalView::~TraingNomalView() { DeInit(); + // TraingModel::GetInstance()->stop_heart_gps(); g_pTraingNomalView = nullptr; } TraingNomalView *TraingNomalView::GetInstance() { - return g_pTraingNomalView; } @@ -67,7 +68,7 @@ namespace OHOS buttonGo_->SetOnClickListener(static_cast(TraingNomalPresenter::GetInstance())); buttonSet_->SetOnClickListener(static_cast(TraingNomalPresenter::GetInstance())); container_->Add(buttonGo_); - container_->Add(buttonSet_); + container_->Add(buttonSet_); #if defined(BOARD_W9) || defined(BOARD_N9) InitUILabel(heartrate_label_, -32, 230, 200, 60, "heartrate_label_", "--", DEFAULT_VECTOR_FONT_FILENAME, 30); container_->Add(heartrate_label_); @@ -76,6 +77,7 @@ namespace OHOS // 获取gps状态 bool gps_status = TraingModel::GetInstance()->GetGPSConnectState(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "gps状态: %d", gps_status); if (gps_status) { //连接状态 @@ -212,4 +214,42 @@ namespace OHOS RootView::GetInstance()->RemoveAll(); return; } + //更新gps状态 + bool TraingNomalView::updateview() + { + if(gps_image_ == nullptr) + { + return false; + } + // 更新GPS状态显示 + bool gps_status = TraingModel::GetInstance()->GetGPSConnectState(); + if(gps_status == updat_view_status) + { + return false; + } + updat_view_status = gps_status; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "gps状态: %d", updat_view_status); + ImageInfo *image; + if (updat_view_status) + { + // 连接状态 - 加载并设置GPS连接图标 + ImageCacheManager::GetInstance().UnloadSingleRes(GPS_2_IMAGE); + image = ImageCacheManager::GetInstance().LoadSingleRes(GPS_1_IMAGE, false); + if (image == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "加载GPS连接图标失败: %s", GPS_1_IMAGE); + return false; + } + } + else + { + ImageCacheManager::GetInstance().UnloadSingleRes(GPS_1_IMAGE); + image = ImageCacheManager::GetInstance().LoadSingleRes(GPS_2_IMAGE, false); + if (image == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "加载GPS断开图标失败: %s", GPS_2_IMAGE); + return false; + } + } + gps_image_->SetSrc(image); + return true; + } } -- 2.17.1