解决HRV页面滑动不能退出问题 3095/2
authorluozheng <1732036298@qq.com>
Fri, 16 Jan 2026 07:03:08 +0000 (15:03 +0800)
committerluozheng <1732036298@qq.com>
Fri, 16 Jan 2026 07:03:08 +0000 (15:03 +0800)
code/sdk/application/wearable/fd272/nativeapp/nativeui/goal/src/Maingoalview.cpp
code/sdk/application/wearable/fd272/nativeapp/nativeui/health/CheckAbnormalView.cpp
code/sdk/application/wearable/fd272/nativeapp/nativeui/health/CheckAbnormalView.h
code/sdk/application/wearable/fd272/nativeapp/nativeui/hrv/include/HrvPresenter.h
code/sdk/application/wearable/fd272/nativeapp/nativeui/hrv/src/HrvPresenter.cpp
code/sdk/application/wearable/fd272/nativeapp/nativeui/hrv/src/HrvView.cpp

index 9e52ac7..0dbcb6f 100644 (file)
@@ -103,7 +103,6 @@ namespace OHOS
     {
       
         AddViewToRootContainer(GetGoalPageView());
-        // GetRootContainer()->Add(GetGoalPageView());
 
         if (goalSwipeViewList != nullptr)
         {
index 347e2b4..ce04c40 100644 (file)
@@ -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_);
     }
 }
index a6e7e77..b17125f 100644 (file)
@@ -56,6 +56,7 @@ namespace OHOS
         bool Initbackground();
 
     private:
+        UIViewGroup *group = nullptr;
         // 提醒图标
         UIImageView *noteimage = nullptr;
         // 按键
index e3105da..78f1a78 100644 (file)
@@ -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:
index d1005f4..3173f39 100644 (file)
@@ -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;
 }
 
index 31c85dc..70e8a7e 100644 (file)
@@ -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);