From a5d2417f78731e6b264cdcffc180e3e5d3e9d0de Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Fri, 16 Jan 2026 15:03:08 +0800 Subject: [PATCH] =?utf8?q?=E8=A7=A3=E5=86=B3HRV=E9=A1=B5=E9=9D=A2=E6=BB=91?= =?utf8?q?=E5=8A=A8=E4=B8=8D=E8=83=BD=E9=80=80=E5=87=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/goal/src/Maingoalview.cpp | 1 - .../nativeui/health/CheckAbnormalView.cpp | 35 +++++++++++++------ .../nativeui/health/CheckAbnormalView.h | 1 + .../nativeui/hrv/include/HrvPresenter.h | 1 + .../nativeui/hrv/src/HrvPresenter.cpp | 29 ++++++++------- .../nativeapp/nativeui/hrv/src/HrvView.cpp | 2 ++ 6 files changed, 45 insertions(+), 24 deletions(-) diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/goal/src/Maingoalview.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/goal/src/Maingoalview.cpp index 9e52ac710..0dbcb6fc4 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/goal/src/Maingoalview.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/goal/src/Maingoalview.cpp @@ -103,7 +103,6 @@ namespace OHOS { AddViewToRootContainer(GetGoalPageView()); - // GetRootContainer()->Add(GetGoalPageView()); if (goalSwipeViewList != nullptr) { diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/health/CheckAbnormalView.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/health/CheckAbnormalView.cpp index 347e2b40c..ce04c4032 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/health/CheckAbnormalView.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/health/CheckAbnormalView.cpp @@ -63,8 +63,8 @@ namespace OHOS ReButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffFF8A36); // 设置按键颜色 ReButton->SetOnClickListener(presenter_); - AddViewToRootContainer(StButton); - AddViewToRootContainer(ReButton); + group->Add(StButton); + group->Add(ReButton); return true; } /*** @@ -81,8 +81,8 @@ namespace OHOS noteLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); noteLabel->SetRollSpeed(23); - AddViewToRootContainer(titleLabel); - AddViewToRootContainer(noteLabel); + group->Add(titleLabel); + group->Add(noteLabel); return true; } /*** @@ -96,7 +96,7 @@ namespace OHOS noteimage->SetPosition(193, 120, 80, 80); noteimage->SetSrc(BLOOD_PATH_NOTE); - AddViewToRootContainer(noteimage); + group->Add(noteimage); return true; } /*** @@ -106,6 +106,19 @@ namespace OHOS bool CheckAbnormalView::CheckAbnormalViewInit() { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bool CheckAbnormalView::InitView()"); + group = new UIViewGroup(); + if (group == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[FindPhoneViewInit_BlueToothConnected] group new fail!!"); + return false; + } + group->SetPosition(0, 0, 466, 466); + group->SetStyle(STYLE_BACKGROUND_OPA, 0); + group->SetTouchable(true); + group->SetDraggable(true); + group->SetOnDragListener(presenter_); + AddViewToRootContainer(group); + if (!Initbackground()) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Initbackground error!"); @@ -126,6 +139,12 @@ namespace OHOS */ void CheckAbnormalView::DeInit() { + if(group!=nullptr) + { + group->RemoveAll(); + delete group; + group = nullptr; + } if (StButton != nullptr) { delete StButton; @@ -166,11 +185,5 @@ namespace OHOS { custom_VibratorFunc_int(0); } - - - GetRootContainer()->SetDraggable(true); - GetRootContainer()->SetTouchable(true); - GetRootContainer()->SetOnDragListener(presenter_); - //RootView::GetInstance()->SetOnKeyActListener(presenter_); } } diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/health/CheckAbnormalView.h b/code/sdk/application/wearable/fd272/nativeapp/nativeui/health/CheckAbnormalView.h index a6e7e77d8..b17125f90 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/health/CheckAbnormalView.h +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/health/CheckAbnormalView.h @@ -56,6 +56,7 @@ namespace OHOS bool Initbackground(); private: + UIViewGroup *group = nullptr; // 提醒图标 UIImageView *noteimage = nullptr; // 按键 diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/hrv/include/HrvPresenter.h b/code/sdk/application/wearable/fd272/nativeapp/nativeui/hrv/include/HrvPresenter.h index e3105da95..78f1a78a3 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/hrv/include/HrvPresenter.h +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/hrv/include/HrvPresenter.h @@ -33,6 +33,7 @@ public: static HrvPresenter *GetInstance(void); bool OnClick(UIView &view, const ClickEvent &event) override; bool OnKeyAct(UIView &view, const KeyEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; bool OnDragEnd(UIView &view, const DragEvent &event) override; private: diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/hrv/src/HrvPresenter.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/hrv/src/HrvPresenter.cpp index d1005f4a3..3173f3906 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/hrv/src/HrvPresenter.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/hrv/src/HrvPresenter.cpp @@ -52,24 +52,29 @@ bool HrvPresenter::OnClick(UIView &view, const ClickEvent &event) return false; } + +bool HrvPresenter::OnDrag(UIView &view, const DragEvent &event) +{ + return true; +} + bool HrvPresenter::OnDragEnd(OHOS::UIView &view, const OHOS::DragEvent &event) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HrvPresenter::OnDragEnd"); if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) { - if (event.GetPreLastPoint().x - event.GetStartPoint().x > 100) - NativeAbility::GetInstance().Back(); - } - if (event.GetDragDirection() == DragEvent::DIRECTION_BOTTOM_TO_TOP) - { - // 上拉更新HRV数据 - HrvView::GetInstance()->update_hrv_data(1); - } - if (event.GetDragDirection() == DragEvent::DIRECTION_TOP_TO_BOTTOM) - { - // 下拉刷新HRV数据 - HrvView::GetInstance()->update_hrv_data(2); + NativeAbility::GetInstance().Back(); } + // if (event.GetDragDirection() == DragEvent::DIRECTION_BOTTOM_TO_TOP) + // { + // // 上拉更新HRV数据 + // HrvView::GetInstance()->update_hrv_data(1); + // } + // if (event.GetDragDirection() == DragEvent::DIRECTION_TOP_TO_BOTTOM) + // { + // // 下拉刷新HRV数据 + // HrvView::GetInstance()->update_hrv_data(2); + // } return true; } diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/hrv/src/HrvView.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/hrv/src/HrvView.cpp index 31c85dc4c..70e8a7e56 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/hrv/src/HrvView.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/hrv/src/HrvView.cpp @@ -88,6 +88,8 @@ void HrvView::OnStart() group->SetPosition(0, 0, 466, 466); group->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); group->SetStyle(STYLE_BACKGROUND_OPA, 0xD0); + group->SetTouchable(true); + group->SetDraggable(true); group->SetOnDragListener((UIView::OnDragListener *)OHOS::HrvPresenter::GetInstance()); AddViewToRootContainer(group); -- 2.17.1