650:解决呼吸训练息屏回到主界面滑动list会死机问题
authorluozheng <1732036298@qq.com>
Fri, 18 Jul 2025 08:27:00 +0000 (16:27 +0800)
committerluozheng <1732036298@qq.com>
Fri, 18 Jul 2025 08:27:00 +0000 (16:27 +0800)
code/sdk/application/wearable/fd230/nativeapp/nativeui/respiratorytraining/include/RespiratoryTrainingView.h
code/sdk/application/wearable/fd230/nativeapp/nativeui/respiratorytraining/src/RespiratoryTrainingView.cpp
code/sdk/middleware/services/gui/uikit/ui/frameworks/dock/pointer_input_device.cpp

index 09d1549..19e8763 100644 (file)
@@ -104,6 +104,7 @@ namespace OHOS
         UILabelExt *RespiratoryTrainingLabel_ = nullptr;
         bool animateStart_ = false;
         /* -------------------------------------------------------------------------- */
+        UIViewGroup *group{nullptr};
         UILabelExt *titlelabel{nullptr};                          // 标题
         UILabelExt *TrainingDurationSelectiontitlelabel{nullptr}; // 选择的训练时长
         UIImageView *Image{nullptr};
index 4c1a273..ab6fbc6 100644 (file)
@@ -49,7 +49,7 @@ namespace OHOS
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RespiratoryTrainingView::ChangeRespiratoryTrainingView");
         if (RespiratoryTrainingScrollView[thisView] == nullptr)
         {
-            AddViewToRootContainer(RespiratoryTrainingScrollView[thisView]);
+            group->Add(RespiratoryTrainingScrollView[thisView]);
         }
         if (TrainingDurationSelectiontitlelabel)
         {
@@ -77,7 +77,7 @@ namespace OHOS
                 return false;
             }
             RespiratoryTrainingScrollView[thisView] = scrollView;
-            AddViewToRootContainer(RespiratoryTrainingScrollView[thisView]);
+            group->Add(RespiratoryTrainingScrollView[thisView]);
         }
         return true;
     }
@@ -100,7 +100,7 @@ namespace OHOS
                 return false;
             }
             RespiratoryTrainingScrollView[thisView] = scrollView;
-            AddViewToRootContainer(RespiratoryTrainingScrollView[thisView]);
+            group->Add(RespiratoryTrainingScrollView[thisView]);
         }
         return true;
     }
@@ -465,7 +465,7 @@ namespace OHOS
         RespiratoryTrainingScrollView[RESPIRATORYTRAINING]->SetHorizontalScrollState(false);
         RespiratoryTrainingScrollView[RESPIRATORYTRAINING]->SetTouchable(true);
         RespiratoryTrainingScrollView[RESPIRATORYTRAINING]->SetDraggable(true);
-        AddViewToRootContainer(RespiratoryTrainingScrollView[RESPIRATORYTRAINING]);
+        group->Add(RespiratoryTrainingScrollView[RESPIRATORYTRAINING]);
 
         return true;
     }
@@ -490,6 +490,12 @@ namespace OHOS
     void RespiratoryTrainingView::ClearAll(void)
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[RespiratoryTrainingView]ClearAll start");
+        if(group != nullptr)
+        {
+            group->RemoveAll();
+            delete group;
+            group = nullptr;
+        }
         if (RespiratoryTrainingScrollView[RESPIRATORYTRAINING] != nullptr)
         {
             RespiratoryTrainingScrollView[RESPIRATORYTRAINING]->RemoveAll();
@@ -572,12 +578,17 @@ namespace OHOS
 
     void RespiratoryTrainingView::OnStart()
     {
-
+        if (group == nullptr)
+        {
+            group = new UIViewGroup();
+            group->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+            group->SetOnDragListener(presenter_);
+            AddViewToRootContainer(group);
+        }
+        RespiratoryTrainingViewInit();
         RootView::GetInstance()->SetDraggable(true);
         RootView::GetInstance()->SetTouchable(true);
-        RootView::GetInstance()->SetOnDragListener(presenter_);
         RootView::GetInstance()->SetOnKeyActListener(presenter_);
  
-        RespiratoryTrainingViewInit();
     }
 }
\ No newline at end of file
index d03b1fa..4994c4e 100644 (file)
@@ -259,9 +259,9 @@ void PointerInputDevice::DispatchDragStartEvent()
         if ((MATH_ABS(dragLen_.x) >= DRAG_LIMIT_X) || (MATH_ABS(dragLen_.y) >= DRAG_LIMIT_Y)) {
         // if ((MATH_ABS(dragLen_.x) >= INDEV_DRAG_LIMIT) || (MATH_ABS(dragLen_.y) >= INDEV_DRAG_LIMIT)) {
             // HISI delete begin
-            //if ((touchableView_ != nullptr) && !cancelSent_) {
-            //    DispatchCancelEvent();
-            //}
+            if ((touchableView_ != nullptr) && !cancelSent_) {
+                DispatchCancelEvent();
+            }
             // HISI delete end
             printf("=====PointerInputDevice::DispatchDragStartEvent absx(%d) limitx(%d) absy(%d) limity(%d) \r\n",
             MATH_ABS(dragLen_.x),DRAG_LIMIT_X,