快捷训练Slice修改析构
authorCaisking <3449750381@qq.com>
Fri, 27 Sep 2024 10:01:45 +0000 (18:01 +0800)
committerCaisking <3449750381@qq.com>
Fri, 27 Sep 2024 10:01:45 +0000 (18:01 +0800)
code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingView.h
code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingView.cpp

index 6b7dac6..f134317 100644 (file)
@@ -36,12 +36,9 @@ namespace OHOS
         UIView *GetView();
 
     private:
-        UIView::OnDragListener *draglistener{nullptr};
         TraingView(TraingView &&) = delete;
         TraingView &operator=(TraingView &&) = delete;
 
-        UIViewGroup *container_ = nullptr;
-
         UIButton *buttonmore_ = nullptr;
         UIButton *button1_ = nullptr;
         UIButton *button2_ = nullptr;
index 9f2cbf0..5662544 100644 (file)
@@ -157,7 +157,11 @@ namespace OHOS
 \r
     void TraingView::DeInitView()\r
     {\r
-        container_->RemoveAll();\r
+        if(container_)\r
+        {\r
+            container_->RemoveAll(); \r
+        }\r
+\r
         if (buttonmore_ != nullptr)\r
         {\r
             delete buttonmore_;\r
@@ -223,19 +227,8 @@ namespace OHOS
             delete btnmore_image;\r
             btnmore_image = nullptr;\r
         }\r
-        // 删除容器\r
-        if (container_ != nullptr)\r
-        {\r
-            delete container_;\r
-            container_ = nullptr;\r
-        }\r
     }\r
 \r
-    UIView *TraingView::GetView()\r
-    {\r
-        InitView();\r
-        return container_;\r
-    }\r
     // 设置按键监听\r
     static void SetKeyActListener()\r
     {\r
@@ -273,7 +266,7 @@ namespace OHOS
         container_->SetTouchable(true);\r
         container_->SetDraggable(true);\r
 \r
-        GetView();\r
+       InitView();\r
 \r
         SetContainerView(container_);\r
         // 增加按键监听\r
@@ -296,9 +289,12 @@ namespace OHOS
     {\r
         View<TraingPresenter>::OnStop();\r
 \r
-\r
-        RootView::GetInstance()->ClearOnKeyActListener();\r
-        //FocusManager::GetInstance()->ClearFocus();\r
+        if (container_ != nullptr)\r
+        {\r
+            container_->RemoveAll();\r
+            delete container_;\r
+            container_ = nullptr;\r
+        }\r
         RootView::GetInstance()->RemoveAll();\r
         return;\r
     }\r