界面优化解决息屏滑动监听失效
authorluozheng <1732036298@qq.com>
Mon, 16 Mar 2026 09:16:37 +0000 (17:16 +0800)
committerluozheng <1732036298@qq.com>
Mon, 16 Mar 2026 09:16:37 +0000 (17:16 +0800)
45 files changed:
code/sdk/application/wearable/n9/nativeapp/nativelauncher/include/AppViewIDs.h
code/sdk/application/wearable/n9/nativeapp/nativeui/callerlog/src/CallerLogView.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/goal/src/Maingoalview.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/health/CheckAbnormalView.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/health/CheckAbnormalView.h
code/sdk/application/wearable/n9/nativeapp/nativeui/heartrate/include/HeartDetectionView.h
code/sdk/application/wearable/n9/nativeapp/nativeui/heartrate/include/HeartResultView.h
code/sdk/application/wearable/n9/nativeapp/nativeui/heartrate/src/HeartDetectionView.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/heartrate/src/HeartResultView.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/motionrecognition/src/MotionRecognitionView.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/networkandcall/src/NetworkAndCallView.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/set_aod/src/SetAodDialView.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/set_desktop/include/SetDesktopModel.h [deleted file]
code/sdk/application/wearable/n9/nativeapp/nativeui/set_desktop/include/SetDesktopPresenter.h [deleted file]
code/sdk/application/wearable/n9/nativeapp/nativeui/set_desktop/include/SetDesktopView.h [deleted file]
code/sdk/application/wearable/n9/nativeapp/nativeui/set_desktop/src/SetDesktopModel.cpp [deleted file]
code/sdk/application/wearable/n9/nativeapp/nativeui/set_desktop/src/SetDesktopPresenter.cpp [deleted file]
code/sdk/application/wearable/n9/nativeapp/nativeui/set_desktop/src/SetDesktopView.cpp [deleted file]
code/sdk/application/wearable/n9/nativeapp/nativeui/set_dial_style/include/SetDialStyleView.h
code/sdk/application/wearable/n9/nativeapp/nativeui/set_dial_style/src/SetDialStyleView.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/set_time_format/include/SetTimeFormatView.h
code/sdk/application/wearable/n9/nativeapp/nativeui/set_time_format/src/SetTimeFormatView.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/sleep/include/SleepControlView.h
code/sdk/application/wearable/n9/nativeapp/nativeui/sleep/src/SleepControlView.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/sleepmode/src/SleepModeView.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/systemupdate/src/SystemUpdateView.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/traing/include/TraingNomalView.h
code/sdk/application/wearable/n9/nativeapp/nativeui/traing/include/TraingView.h
code/sdk/application/wearable/n9/nativeapp/nativeui/traing/src/TraingEnddataView.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/traing/src/TraingNomalView.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/traing/src/TraingSetView.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/traing/src/TraingView.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/include/TraingGPSView.h
code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/include/TraingGPSbackView.h
code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/include/TraingGPSlackView.h
code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/include/TraingGPSlostView.h
code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/include/TraingGPSnoteView.h
code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/include/TraingGPSsetView.h
code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/src/TraingGPSView.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/src/TraingGPSbackView.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/src/TraingGPSlackView.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/src/TraingGPSlostView.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/src/TraingGPSnoteView.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/src/TraingGPSsetView.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_card/src/TraingCardView.cpp

index b105dcf..b92743c 100644 (file)
@@ -123,7 +123,6 @@ typedef enum : uint16_t
   VIEW_CALCULATOR,     // 计算器
   VIEW_SCHEDULE,       // 日程
   VIEW_SLEEPMODE,      // sleep mode
-  VIEW_SET_DESKTOP,    // 设置主题
   VIEW_THUNDER_BIRD,   //雷鸟
   VIEW_THUNDER_RECORD, //雷鸟录音
   /* ---------------------------- 650-0723patch 合并 ---------------------------- */
index bc0d0a1..ed0a37c 100644 (file)
@@ -125,7 +125,7 @@ void CallerLogView::InitBluetoothHintsGroup()
     hintsImageView->SetSrc(PNG_BLUETOOTH_HINTS_PATH);\r
     hintsGroup->Add(hintsImageView);\r
     \r
-    GetRootContainer()->Add(hintsGroup);\r
+    AddViewToRootContainer(hintsGroup);\r
     hintsGroup->SetVisible(false);\r
     return;\r
 }\r
@@ -208,7 +208,7 @@ void CallerLogView::OnStart()
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerLogView::CreateNoDataCallerLogViewGroup error");\r
         return;\r
     }\r
-    GetRootContainer()->Add(group);\r
+    AddViewToRootContainer(group);\r
 \r
     if (!CreateCallerLogViewGroup()) {\r
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerLogView::CreateCallerLogViewGroup error");\r
@@ -256,7 +256,7 @@ void CallerLogView::OnStart()
         return;\r
     }\r
 \r
-    GetRootContainer()->Add(scrollview);\r
+    AddViewToRootContainer(scrollview);\r
 \r
     if (num == 0) {\r
         group->SetVisible(true);\r
index 9e52ac7..00d3251 100644 (file)
@@ -101,10 +101,7 @@ namespace OHOS
 
     void MaingoalrView::OnStart()
     {
-      
         AddViewToRootContainer(GetGoalPageView());
-        // GetRootContainer()->Add(GetGoalPageView());
-
         if (goalSwipeViewList != nullptr)
         {
             UIView::OnClickListener *goalOnClickListener = (UIView::OnClickListener *)OHOS::MaingoalPresenter::GetInstance();
@@ -131,11 +128,6 @@ namespace OHOS
             goalSwipeViewList->SetOnDragListener(goalOnDragListener);
             goalSwipeViewList->SetOnSwipeListener(goalOnSwipeListener);
         }
-        
-        /* --------------------------------- 添加按键监听 --------------------------------- */
-        // RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::MaingoalPresenter::GetInstance();
-        //RootView::GetInstance()->SetOnKeyActListener(keyactListener);
-        /* -------------------------------------------------------------------------- */
     }
 
    
index 347e2b4..5798136 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;
     }
     /***
@@ -126,6 +126,12 @@ namespace OHOS
      */
     void CheckAbnormalView::DeInit()
     {
+        if (group != nullptr)
+        {
+            group->RemoveAll();
+            delete group;
+            group = nullptr;
+        }
         if (StButton != nullptr)
         {
             delete StButton;
@@ -155,7 +161,23 @@ namespace OHOS
 
     void CheckAbnormalView::OnStart()
     {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CheckAbnormalView::OnStart");
+        if(group == nullptr)
+        {
+            group = new UIViewGroup();
+            if (group == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CheckAbnormalView::new UIViewGroup fail");
+                return;
+            }
+            group->SetPosition(0, 0, VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION);
+            group->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+            group->SetStyle(STYLE_BACKGROUND_OPA, UN_OPACITY);
+            group->SetTouchable(true);
+            group->SetDraggable(true);
+            group->SetOnDragListener(presenter_);
+        }
+        AddViewToRootContainer(group);
+
 
         if (!CheckAbnormalViewInit())
         {
@@ -166,11 +188,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 2cc2921..cf53cad 100644 (file)
@@ -40,6 +40,7 @@ namespace OHOS
         void UpShowHeartText(void);
 
     private:
+        UIViewGroup *group{nullptr};
         UIImageAnimatorView *imageAnimator{nullptr};
         UILabelExt *titleLabel{nullptr};
         UILabel *HeartText{nullptr};
index 62b3738..213b27c 100644 (file)
@@ -38,6 +38,7 @@ namespace OHOS
         bool Initbackground();
 
     private:
+        UIViewGroup *group = nullptr;
         UIImageView *background = nullptr;
         UILabelExt *titleLabel = nullptr;
         UILabelExt *timeLabel = nullptr;
index d712849..3dec439 100644 (file)
@@ -53,6 +53,9 @@ namespace OHOS
     HeartDetectionView::~HeartDetectionView()
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HeartDetectionView::~HeartDetectionView");
+        group->RemoveAll();
+        delete group;
+        group = nullptr;
 
         delete titleLabel;
         titleLabel = nullptr;
@@ -92,8 +95,7 @@ namespace OHOS
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartDetectionViewInit is begin");
         /*初始化title*/
         InitLabelExt(titleLabel, 83, 50, 300, 35, "title", STR_CHECKON, DEFAULT_VECTOR_FONT_FILENAME, 30);
-        AddViewToRootContainer(titleLabel);
-
+        group->Add(titleLabel);
         /* -------------------------------------------------------------------------- */
         imageAnimator = new UIImageAnimatorView();
         if (imageAnimator == nullptr)
@@ -103,16 +105,16 @@ namespace OHOS
         }
         imageAnimator->SetImageAnimatorSrc(g_imageAnimatorInfo_heart, DETECTION_IMAGE_ANIMATORVIEW_SIZE, DETECTION_IMAGE_ANIMATORVIEW_SPEED);
         imageAnimator->SetRepeat(true);
-        AddViewToRootContainer(imageAnimator);
+        group->Add(imageAnimator);
 
         /* -------------------------------------------------------------------------- */
         /*初始化心率值label*/
         InitUILabel(HeartText, 83, 83, 300, 300, "hearttext", "--", GILROY_BOLD_FONT, 140);
-        AddViewToRootContainer(HeartText);
+        group->Add(HeartText);
 
         /* -------------------------------------------------------------------------- */
         InitButtonExt(testButton, 118, 336, 230, 80, STOPCHECK, STR_CHECKSTOP, 30);
-        AddViewToRootContainer(testButton);
+        group->Add(testButton);
 
         /* -------------------------------------------------------------------------- */
         UIView::OnClickListener *clickLeftListener = (UIView::OnClickListener *)OHOS::HeartDetectionPresenter::GetInstance();
@@ -129,18 +131,27 @@ namespace OHOS
     void HeartDetectionView::OnStart()
     {
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartDetectionView::OnStart");
-       
+        if(group == nullptr)
+        {
+            group = new UIViewGroup();
+            if (group == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartDetectionView::new UIViewGroup fail");
+                return;
+            }
+            group->SetPosition(0, 0, VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION);
+            group->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+            group->SetStyle(STYLE_BACKGROUND_OPA, UN_OPACITY);
+            group->SetTouchable(true);
+            group->SetDraggable(true);
+            group->SetOnDragListener(presenter_);
+        }
+
         if (!HeartDetectionViewInit())
         {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartDetectionView::InitHeartView fail");
         }
 
-
-     
-        GetRootContainer()->SetDraggable(true);
-        GetRootContainer()->SetTouchable(true);
-        GetRootContainer()->SetOnDragListener(presenter_);     
-
         if (imageAnimator != nullptr)
         {
             imageAnimator->Start();
index 29e654e..f37246d 100644 (file)
@@ -162,6 +162,12 @@ namespace OHOS
      */
     void HeartResultView::DeInit()
     {
+        if (group != nullptr)
+        {
+            group->RemoveAll();
+            delete group;
+            group = nullptr;
+        }
         if (background != nullptr)
         {
             delete background;
@@ -186,17 +192,27 @@ namespace OHOS
 
     void HeartResultView::OnStart()
     {
-       
+        if(group == nullptr)
+        {
+            group = new UIViewGroup();
+            if (group == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CheckAbnormalView::new UIViewGroup fail");
+                return;
+            }
+            group->SetPosition(0, 0, VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION);
+            group->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+            group->SetStyle(STYLE_BACKGROUND_OPA, UN_OPACITY);
+            group->SetTouchable(true);
+            group->SetDraggable(true);
+            group->SetOnDragListener(presenter_);
+        }
+        AddViewToRootContainer(group);
 
         if (!HeartResultViewInit())
         {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartResultView::InitHeartView fail");
         }
-
-  
-        GetRootContainer()->SetDraggable(true);
-        GetRootContainer()->SetTouchable(true);
-        GetRootContainer()->SetOnDragListener(presenter_);     
     }
     
 }
index 255d73a..c9d5f45 100644 (file)
@@ -169,18 +169,11 @@ namespace OHOS
     void MotionRecognitionView::OnStart()
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionRecognitionView::OnStart");
-        View<MotionRecognitionPresenter>::OnStart();
-      
-       
-
         if (!viewInitStatus)
         {
             MotionRecognitionViewInit();
         }
 
-        // 增加按键监听
-        // GetRootContainer()->SetOnKeyActListener(presenter_);
-
         scrollView->Add(Title);
         scrollView->Add(MotionRecognitionImage);
         scrollView->Add(MotionRecognitionLabel);
index f9efdb9..68a4bc3 100644 (file)
@@ -219,7 +219,6 @@ namespace OHOS
 
     void NetworkAndCallView::OnStart()
     {
-        View<NetworkAndCallPresenter>::OnStart();
         NetworkAndCallViewInit();
         NetworkAndCallScrollView[NETWORKANDCALLVIEW]->Add(Title);
         for (int i = 0; i < ITEM_NUM; i++)
@@ -239,10 +238,6 @@ namespace OHOS
         AddViewToRootContainer(NetworkAndCallScrollView[NETWORKANDCALLVIEW]);
     }
 
-
-
-    
-
     // 获取VOLTE button
     UIToggleButton *NetworkAndCallView::GetVoLTEToggleButton(void)
     {
@@ -271,7 +266,7 @@ namespace OHOS
         if (NetworkAndCallScrollView[thisView] == nullptr)
         {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NetworkAndCallView::ChangeNetworkAndCallView");
-            GetRootContainer()->Add(NetworkAndCallScrollView[thisView]);
+            AddViewToRootContainer(NetworkAndCallScrollView[thisView]);
         }
         return true;
     }
@@ -289,7 +284,7 @@ namespace OHOS
                 return false;
             }
             NetworkAndCallScrollView[thisView] = mobileDataOptionsView->MobileDataOptionsViewInit();
-            GetRootContainer()->Add(NetworkAndCallScrollView[thisView]);
+            AddViewToRootContainer(NetworkAndCallScrollView[thisView]);
         }
         return true;
     }
index 170c332..ded52eb 100644 (file)
@@ -173,16 +173,12 @@ namespace OHOS
     void SetAodDialView::OnStart()
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetAodDialView::OnStart");
-        View<SetAodDialPresenter>::OnStart();
 
         if (!viewInitStatus)
         {
             SetAodDialViewInit();
         }
 
-        // 增加按键监听
-        // GetRootContainer()->SetOnKeyActListener(presenter_);
-
         scrollView->Add(Title);
         scrollView->Add(SetAodDialImage);
         scrollView->Add(SetAodDialLabel);
diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/set_desktop/include/SetDesktopModel.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/set_desktop/include/SetDesktopModel.h
deleted file mode 100644 (file)
index 723a0c3..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
- * Description: SetDesktopModel.h
- * Author:
- * Create: 2021-11-23
- */
-
-#ifndef SET_DESKTOP_MODEL_H
-#define SET_DESKTOP_MODEL_H
-
-#include <cstdint>
-#include <map>
-#include "AppViewIDs.h"
-#include "UiConfig.h"
-
-typedef enum {
-    APPLIST_STYLE,
-    HEXAGONS_STYLE,
-    FOOTBALL_STYLE,
-    WATERFALL_STYLE
-} DesktopStyle;
-
-namespace OHOS {
-    class SetDesktopModel {
-    public:
-        static SetDesktopModel &GetInstance(void);
-        DesktopStyle GetDesktopStyle(void);
-        void SetDesktopStyle(DesktopStyle style);
-    private:
-        SetDesktopModel();
-        SetDesktopModel(const SetDesktopModel &);
-        SetDesktopModel &operator=(const SetDesktopModel &);
-        virtual ~SetDesktopModel();
-    };
-}
-
-#endif // SET_DESKTOP_MODEL_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/set_desktop/include/SetDesktopPresenter.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/set_desktop/include/SetDesktopPresenter.h
deleted file mode 100644 (file)
index b098142..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
- * Description: SetDesktopPresenter.h
- * Author:
- * Create: 2021-11-23
- */
-
-#ifndef SET_DESKTOP_PRESENTER_H
-#define SET_DESKTOP_PRESENTER_H
-
-#include "key/include/KeyInputListener.h"
-#include "Presenter.h"
-#include "components/ui_view.h"
-
-namespace OHOS {
-static const char *SET_DESKTOP_LIST = "setdesktopList";
-static const char *SET_DESKTOP_HEXAGONS = "setdesktopHexagons";
-static const char *SET_DESKTOP_FOOTBALL = "setdesktopFootball";
-static const char *SET_DESKTOP_WATERFALL = "setdesktopWaterfall";
-
-class SetDesktopView;
-class SetDesktopModel;
-class SetDesktopPresenter : public Presenter<SetDesktopView>,
-                         public UIView::OnClickListener,
-                         public UIView::OnDragListener {
-public:
-    SetDesktopPresenter();
-    ~SetDesktopPresenter() override;
-    bool OnClick(UIView &view, const ClickEvent &event) override;
-    bool OnDrag(UIView& view, const DragEvent& event) override;
-    uint8_t GetCurrentStyle(void);
-private:
-};
-}
-
-#endif // SET_DESKTOP_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/set_desktop/include/SetDesktopView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/set_desktop/include/SetDesktopView.h
deleted file mode 100644 (file)
index 8de6379..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
- * Description: SetDesktopView.h
- * Author:
- * Create: 2021-11-23
- */
-
-#ifndef SET_DESKTOP_VIEW_H
-#define SET_DESKTOP_VIEW_H
-
-#include "View.h"
-#include "components/ui_scroll_view.h"
-#include "components/ui_view_group.h"
-#include "components/ui_label.h"
-#include "components/ui_image_view.h"
-#include "components/ui_toggle_button.h"
-#include "ChangeSliceListener.h"
-#include "UiConfig.h"
-
-namespace OHOS {
-class SetDesktopPresenter;
-
-class SetDesktopView : public View<SetDesktopPresenter> {
-public:
-    SetDesktopView();
-    ~SetDesktopView() override;
-
-    static SetDesktopView *GetInstance()
-    {
-        static SetDesktopView instance;
-        return &instance;
-    }
-
-    void OnStart() override;
-    void UpdateSelectedStyle(uint8_t selectedStyle);
-    uint8_t GetCurrentSelectedStyle(void);
-
-private:
-    void InitFootballItem();
-    void InitWaterfallItem();
-    UIScrollView *scrollview{nullptr};
-    UILabel titleText;
-    UIToggleButton hexagonsBtn;
-    UIToggleButton listBtn;
-    UIToggleButton footballBtn_;
-    UIToggleButton waterfallBtn_;
-    UIImageView hexagonsImage;
-    UIImageView listImage;
-    UIImageView footballImage_;
-    UIImageView waterfallImage_;
-    UILabel listText;
-    UILabel hexagonsText;
-    UILabel footballText_;
-    UILabel waterfallText_;
-};
-}
-#endif // SET_DESKTOP_VIEW_H
diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/set_desktop/src/SetDesktopModel.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/set_desktop/src/SetDesktopModel.cpp
deleted file mode 100644 (file)
index fb62432..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
- * Description: SettingModel.cpp
- * Author:
- * Create: 2021-11-23
- */
-
-#include "set_desktop/include/SetDesktopModel.h"
-#include "kv_store.h"
-#include "securec.h"
-
-namespace OHOS {
-    static const int STYLE_VALUE_LEN = 32;
-    SetDesktopModel::SetDesktopModel() {}
-
-    SetDesktopModel::~SetDesktopModel() {}
-
-    SetDesktopModel &SetDesktopModel::GetInstance()
-    {
-        static SetDesktopModel instance;
-        return instance;
-    }
-
-    DesktopStyle SetDesktopModel::GetDesktopStyle(void)
-    {
-        DesktopStyle style;
-        char temp[STYLE_VALUE_LEN] = { 0 };
-        (void)UtilsGetValue("applist_style", temp, STYLE_VALUE_LEN);
-        if (strcmp(temp, "hexagons") == 0) {
-            style = HEXAGONS_STYLE;
-        } else if (strcmp(temp, "football") == 0) {
-            style = FOOTBALL_STYLE;
-        } else if (strcmp(temp, "waterfall") == 0) {
-            style = WATERFALL_STYLE;
-        } else {
-            style = APPLIST_STYLE;
-        }
-        return style;
-    }
-
-    void SetDesktopModel::SetDesktopStyle(DesktopStyle style)
-    {
-        if (style == APPLIST_STYLE) {
-            (void)UtilsSetValue("applist_style", "list");
-        } else if (style == HEXAGONS_STYLE) {
-            (void)UtilsSetValue("applist_style", "hexagons");
-        } else if (style == FOOTBALL_STYLE) {
-            (void)UtilsSetValue("applist_style", "football");
-        } else if (style == WATERFALL_STYLE) {
-            (void)UtilsSetValue("applist_style", "waterfall");
-        }
-    }
-
-}
diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/set_desktop/src/SetDesktopPresenter.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/set_desktop/src/SetDesktopPresenter.cpp
deleted file mode 100644 (file)
index ab8f0bd..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
- * Description: SettingPresenter.cpp
- * Author:
- * Create: 2021-11-23
- */
-
-#include "set_desktop/include/SetDesktopView.h"
-#include "set_desktop/include/SetDesktopModel.h"
-#include "set_desktop/include/SetDesktopPresenter.h"
-#include "NativeRegisterManager.h"
-
-namespace OHOS {
-
-REGIST_SLICE(VIEW_SET_DESKTOP, SetDesktopView, SetDesktopPresenter);
-
-    SetDesktopPresenter::SetDesktopPresenter()
-    {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDesktopPresenter::SetDesktopPresenter");
-    }
-
-    SetDesktopPresenter::~SetDesktopPresenter() {}
-
-    bool SetDesktopPresenter::OnDrag(UIView& view, const DragEvent& event)
-    {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDesktopPresenter::OnDrag");
-        UNUSED(view);
-        if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) &&
-            (event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) {
-            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnDrag ChangeSlice");
-            uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
-            NativeAbility::GetInstance().ChangeSlice(preSlice);
-        }
-        return false;
-    }
-
-    bool SetDesktopPresenter::OnClick(UIView &view, const ClickEvent &event)
-    {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDesktopPresenter::OnClick");
-        if (strcmp(view.GetViewId(), SET_DESKTOP_HEXAGONS) == 0) {
-            SetDesktopModel::GetInstance().SetDesktopStyle(DesktopStyle::HEXAGONS_STYLE);
-        } else if (strcmp(view.GetViewId(), SET_DESKTOP_LIST) == 0) {
-            SetDesktopModel::GetInstance().SetDesktopStyle(DesktopStyle::APPLIST_STYLE);
-        } else if (strcmp(view.GetViewId(), SET_DESKTOP_FOOTBALL) == 0) {
-            SetDesktopModel::GetInstance().SetDesktopStyle(DesktopStyle::FOOTBALL_STYLE);
-        } else if (strcmp(view.GetViewId(), SET_DESKTOP_WATERFALL) == 0) {
-            SetDesktopModel::GetInstance().SetDesktopStyle(DesktopStyle::WATERFALL_STYLE);
-        }
-        uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
-        NativeAbility::GetInstance().ChangeSlice(preSlice);
-        return true;
-    }
-
-    uint8_t SetDesktopPresenter::GetCurrentStyle(void)
-    {
-        DesktopStyle style = SetDesktopModel::GetInstance().GetDesktopStyle();
-        if (style == HEXAGONS_STYLE) {
-            return 1;   // 1: hexagons style enum index
-        } else if (style == FOOTBALL_STYLE) {
-            return 2;   // 2: football style enum index
-        } else if (style == WATERFALL_STYLE) {
-            return 3;   // 3: waterfall style enum index
-        }
-        return 0;
-    }
-}
diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/set_desktop/src/SetDesktopView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/set_desktop/src/SetDesktopView.cpp
deleted file mode 100644 (file)
index 69bc411..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
- * Description: SetDesktopView.cpp
- * Author:
- * Create: 2021-11-23
- */
-
-#include <string>
-#include "set_desktop/include/SetDesktopView.h"
-#include "set_desktop/include/SetDesktopPresenter.h"
-#include "components/ui_scroll_view_nested.h"
-#include "common/screen.h"
-
-#include "PageTransitionMgr.h"
-namespace OHOS {
-SetDesktopView::SetDesktopView()
-{
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDesktopView::SetDesktopView");
-}
-
-SetDesktopView::~SetDesktopView()
-{
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDesktopView::~SetDesktopView");
-    if (scrollview != nullptr) {
-        scrollview->RemoveAll();
-        delete scrollview;
-        scrollview = nullptr;
-    }
-}
-
-void SetDesktopView::OnStart()
-{
-    GetRootContainer()->SetDraggable(true);
-    if (PageTransitionMgr::GetInstance().GetTopSlideBackImage() == nullptr) { // support default slide back firstly
-        GetRootContainer()->SetOnDragListener(presenter_);
-    }
-    GetRootContainer()->SetTouchable(true);
-
-    scrollview = new UIScrollViewNested(UIAbstractScroll::HORIZONTAL);
-    UIScrollViewNested *nested = dynamic_cast<UIScrollViewNested*>(scrollview);
-    if (nested != nullptr) {
-        nested->SetBoundaryIntercept(DragEvent::DIRECTION_LEFT_TO_RIGHT, false);
-    }
-    scrollview->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
-    AddViewToRootContainer(scrollview);
-
-    titleText.SetPosition(180, 45, 260, 110);
-    titleText.SetText("桌面");
-    titleText.SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
-    titleText.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40);
-    titleText.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
-    AddViewToRootContainer(&titleText);
-
-    listImage.SetPosition(0, 135, 190, 190);
-    listImage.SetSrc(PNG_SET_DESKTOP_BG_IMAGE);
-    scrollview->Add(&listImage);
-
-    listBtn.SetPosition(22, 157, 148, 148);
-    listBtn.SetImages(PNG_SET_DESKTOP_LIST_IMAGE, PNG_SET_DESKTOP_LIST_IMAGE);
-    listBtn.SetViewId(SET_DESKTOP_LIST);
-    scrollview->Add(&listBtn);
-
-    listText.SetPosition(61, 328, 200, 60);
-    listText.SetText("列表");
-    listText.SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
-    listText.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
-    listText.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
-    scrollview->Add(&listText);
-
-    hexagonsImage.SetPosition(150, 135, 190, 190);
-    hexagonsImage.SetSrc(PNG_SET_DESKTOP_BG_IMAGE);
-    scrollview->Add(&hexagonsImage);
-
-    hexagonsBtn.SetPosition(172, 157, 148, 148);
-    hexagonsBtn.SetImages(PNG_SET_DESKTOP_HEXAGONS_IMAGE, PNG_SET_DESKTOP_HEXAGONS_IMAGE);
-    hexagonsBtn.SetViewId(SET_DESKTOP_HEXAGONS);
-    scrollview->Add(&hexagonsBtn);
-
-    hexagonsText.SetPosition(218, 328, 200, 60);
-    hexagonsText.SetText("蜂窝");
-    hexagonsText.SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
-    hexagonsText.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
-    hexagonsText.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
-    scrollview->Add(&hexagonsText);
-
-    InitFootballItem();
-    InitWaterfallItem();
-    listBtn.SetOnClickListener(presenter_);
-    hexagonsBtn.SetOnClickListener(presenter_);
-    footballBtn_.SetOnClickListener(presenter_);
-    waterfallBtn_.SetOnClickListener(presenter_);
-    UpdateSelectedStyle(presenter_->GetCurrentStyle());
-}
-
-void SetDesktopView::UpdateSelectedStyle(uint8_t selectedStyle)
-{
-    hexagonsImage.SetVisible(false);
-    hexagonsBtn.SetState(false);
-    listImage.SetVisible(false);
-    listBtn.SetState(false);
-    footballImage_.SetVisible(false);
-    footballBtn_.SetState(false);
-    waterfallImage_.SetVisible(false);
-    waterfallBtn_.SetState(false);
-
-    if (selectedStyle == 1) { // 1: select hexagons style
-        hexagonsImage.SetVisible(true);
-        hexagonsBtn.SetState(true);
-    } else if (selectedStyle == 2) { // 2: select football style
-        footballImage_.SetVisible(true);
-        footballBtn_.SetState(true);
-    } else if (selectedStyle == 3) { // 3: select waterfall style
-        waterfallImage_.SetVisible(true);
-        waterfallBtn_.SetState(true);
-    } else {
-        listImage.SetVisible(true);
-        listBtn.SetState(true);
-    }
-}
-
-void SetDesktopView::InitFootballItem()
-{
-    footballImage_.SetPosition(300, 135, 190, 190);
-    footballImage_.SetSrc(PNG_SET_DESKTOP_BG_IMAGE);
-    scrollview->Add(&footballImage_);
-
-    footballBtn_.SetPosition(322, 157, 148, 148);
-    footballBtn_.SetImages(PNG_SET_DESKTOP_HEXAGONS_IMAGE, PNG_SET_DESKTOP_HEXAGONS_IMAGE);
-    footballBtn_.SetViewId(SET_DESKTOP_FOOTBALL);
-    scrollview->Add(&footballBtn_);
-
-    footballText_.SetPosition(368, 328, 200, 60);
-    footballText_.SetText("足球");
-    footballText_.SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
-    footballText_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
-    footballText_.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
-    scrollview->Add(&footballText_);
-}
-
-void SetDesktopView::InitWaterfallItem()
-{
-    waterfallImage_.SetPosition(450, 135, 190, 190);
-    waterfallImage_.SetSrc(PNG_SET_DESKTOP_BG_IMAGE);
-    scrollview->Add(&waterfallImage_);
-
-    waterfallBtn_.SetPosition(472, 157, 148, 148);
-    waterfallBtn_.SetImages(PNG_SET_DESKTOP_HEXAGONS_IMAGE, PNG_SET_DESKTOP_HEXAGONS_IMAGE);
-    waterfallBtn_.SetViewId(SET_DESKTOP_WATERFALL);
-    scrollview->Add(&waterfallBtn_);
-
-    waterfallText_.SetPosition(518, 328, 200, 60);
-    waterfallText_.SetText("瀑布");
-    waterfallText_.SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
-    waterfallText_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
-    waterfallText_.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
-    scrollview->Add(&waterfallText_);
-}
-uint8_t SetDesktopView::GetCurrentSelectedStyle()
-{
-    return presenter_->GetCurrentStyle();
-}
-}
index 4b3476c..c736bff 100644 (file)
@@ -26,6 +26,7 @@ namespace OHOS
         void OnClick(UIView &view);
 
     private:
+        UIViewGroup group;
         UILabelExt labelTitle_;
 
         UILabelExt labelCover_;
index d0fc991..964c0d2 100644 (file)
@@ -15,31 +15,36 @@ namespace OHOS
 
     SetDialStyleView::~SetDialStyleView()
     {
+        group.RemoveAll();
     }
 
     void SetDialStyleView::OnStart()
     {
-        GetRootContainer()->SetDraggable(true);
-        GetRootContainer()->SetTouchable(true);
+        group.SetPosition(0, 0, VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION);
+        group.SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+        group.SetStyle(STYLE_BACKGROUND_OPA, UN_OPACITY);
+        group.SetTouchable(true);
+        group.SetDraggable(true);
+        group.SetOnDragListener(presenter_);
+        AddViewToRootContainer(&group);
+
+
         if (PageTransitionMgr::GetInstance().GetTopSlideBackImage() == nullptr)
         { // support default slide back firstly
-            GetRootContainer()->SetOnDragListener(presenter_);
+            group.SetOnDragListener(presenter_);
         }
 
-
             Cover_Image_.SetPosition(43, 120, 380, 100);
             Cover_Image_.SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
             Cover_Image_.SetStyle(STYLE_BACKGROUND_OPA, 0xff);
             Cover_Image_.SetStyle(STYLE_BORDER_RADIUS, 100);
-            AddViewToRootContainer(&Cover_Image_);
-
-            
+            group.Add(&Cover_Image_);
 
             Roller_Image_.SetPosition(43, 240, 380, 100);
             Roller_Image_.SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
             Roller_Image_.SetStyle(STYLE_BACKGROUND_OPA, 0xff);
             Roller_Image_.SetStyle(STYLE_BORDER_RADIUS, 100);
-            AddViewToRootContainer(&Roller_Image_);
+            group.Add(&Roller_Image_);
 
             labelTitle_.SetPosition(83, 50, 300, 60);
             labelTitle_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
@@ -48,24 +53,25 @@ namespace OHOS
             labelTitle_.SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
             labelTitle_.SetRollSpeed(23);
             labelTitle_.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
-            AddViewToRootContainer(&labelTitle_);
+            group.Add(&labelTitle_);
 
             labelCover_.SetPosition(90, 153, 200, 60);
             labelCover_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
             labelCover_.SetTextId(STR_OVERLAY_FLOW);
-            AddViewToRootContainer(&labelCover_);
+            group.Add(&labelCover_);
+
 
             labelRoller_.SetPosition(90, 273, 200, 60);
             labelRoller_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
             labelRoller_.SetTextId(STR_ROLLER);
-            AddViewToRootContainer(&labelRoller_);
+            group.Add(&labelRoller_);
 
             btnCover_.SetPosition(298, 145, 100, 50);
             btnCover_.SetImages(PNG_TOGGLEBUTTON_ON_IMAGE, PNG_TOGGLEBUTTON_OFF_IMAGE);
-            AddViewToRootContainer(&btnCover_);
+            group.Add(&btnCover_);
             btnRoller_.SetPosition(298, 265, 100, 50);
             btnRoller_.SetImages(PNG_TOGGLEBUTTON_ON_IMAGE, PNG_TOGGLEBUTTON_OFF_IMAGE);
-            AddViewToRootContainer(&btnRoller_);
+            group.Add(&btnRoller_);
 
             const DialStyle style = SetDialStyleModel::GetInstance().GetStyle();
             int len = sizeof(styleTable_) / sizeof(styleTable_[0]);
index 16f094d..d3a16c0 100644 (file)
 namespace OHOS {
 SetTimeFormatView::SetTimeFormatView() {}
 
-SetTimeFormatView::~SetTimeFormatView() {}
+SetTimeFormatView::~SetTimeFormatView() {
+  group.RemoveAll();
+}
 
 void SetTimeFormatView::OnStart() {
 
+  group.SetPosition(0, 0, 466, 466);
+  group.SetTouchable(true);
+  group.SetDraggable(true);
+  group.SetOnDragListener(presenter_);
+  AddViewToRootContainer(&group);
+
   if (!SetTimeFormatInit())
   {
       WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartResultView::InitHeartView fail");
   }
-
-  GetRootContainer()->SetDraggable(true);
-  GetRootContainer()->SetPosition(0, 0, 466, 466);
-  GetRootContainer()->SetOnDragListener(presenter_);
-
-  GetRootContainer()->SetTouchable(true);
 }
 
 bool SetTimeFormatView::SetTimeFormatInit() {
@@ -39,7 +41,7 @@ bool SetTimeFormatView::SetTimeFormatInit() {
   Format24H_Image_.SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
   Format24H_Image_.SetStyle(STYLE_BACKGROUND_OPA, 0xff);
   Format24H_Image_.SetStyle(STYLE_BORDER_RADIUS, 100);
-  AddViewToRootContainer(&Format24H_Image_);
+  group.Add(&Format24H_Image_);
 
   labelTitle_.SetPosition(83, 50, 300, 60);
   labelTitle_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
@@ -47,7 +49,7 @@ bool SetTimeFormatView::SetTimeFormatInit() {
   labelTitle_.SetTextId(STR_TIME_SET); // TODO:多国语言
   labelTitle_.SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); // 居中
   labelTitle_.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
-  AddViewToRootContainer(&labelTitle_);
+  group.Add(&labelTitle_);
 
   labelFormat24H_.SetPosition(90, 153, 200, 60);
   labelFormat24H_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
@@ -55,17 +57,18 @@ bool SetTimeFormatView::SetTimeFormatInit() {
   labelFormat24H_.SetTextId(STR_FORMAT); // TODO:多国语言
   labelFormat24H_.SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
   labelFormat24H_.SetRollSpeed(23);
-  AddViewToRootContainer(&labelFormat24H_);
+  group.Add(&labelFormat24H_);
+
 
   btnFormat24H_.SetPosition(298, 145, 100, 50);
   btnFormat24H_.SetImages(PNG_TOGGLEBUTTON_ON_IMAGE,
                           PNG_TOGGLEBUTTON_OFF_IMAGE);
-  AddViewToRootContainer(&btnFormat24H_);
+  group.Add(&btnFormat24H_);
 
   labelNote_.SetPosition(53, 240, 360, 100);
   labelNote_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);
   labelNote_.SetTextId(STR_FORMAT_NOTE);
-  AddViewToRootContainer(&labelNote_);
+  group.Add(&labelNote_);
 
   const TimeFormat style = SetTimeFormatModel::GetInstance().GetTimeStyle();
   if (style == TimeFormat::TIME_FORMAT_24H) {
index 47d2efe..b959ccc 100644 (file)
@@ -65,6 +65,7 @@ namespace OHOS
         SleepNapView *sleepnapView{nullptr};
 
     private:
+        UIViewGroup *group{nullptr};
         int16_t maxPage = MAX_SLEEPVIEW;
         UISwipeView *SleepSwipeViewList{nullptr};
         AppGroupView *recordCard[MAX_SLEEPVIEW]{nullptr};
index c4f93a9..4b1591f 100644 (file)
@@ -38,6 +38,13 @@ namespace OHOS
 
     void SleepControlView::ClearAll(void)
     {
+        if (group != nullptr)
+        {
+            group->RemoveAll();
+            delete group;
+            group = nullptr;
+        }
+
         if (SleepSwipeViewList != nullptr)
         {
             for (int32_t i = 0; i < maxPage; i++)
@@ -101,12 +108,24 @@ namespace OHOS
     void SleepControlView::OnStart()
     {
         SleepModel::GetInstance().msg_save_sleep_data();
-
-        GetRootContainer()->SetTouchable(true);
-        GetRootContainer()->SetDraggable(true);
-        AddViewToRootContainer(GetSleepControlPageView());
-        // GetRootContainer()->Add(GetSleepControlPageView());
-
+        if(group == nullptr)
+        {
+            group = new UIViewGroup();
+            if (group == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CheckAbnormalView::new UIViewGroup fail");
+                return;
+            }
+            group->SetPosition(0, 0, VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION);
+            group->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+            group->SetStyle(STYLE_BACKGROUND_OPA, 255);
+            group->SetTouchable(true);
+            group->SetDraggable(true);
+            group->SetOnDragListener(presenter_);
+        }
+        AddViewToRootContainer(group);
+        group->Add(GetSleepControlPageView());
+        
         if (SleepSwipeViewList == nullptr)
         {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SleepSwipeViewList is nullptr!");
index 29a9d0e..a53b0aa 100644 (file)
@@ -33,12 +33,7 @@ namespace OHOS
 
     void SleepModeView::OnStart()
     {
-        View<SleepModePresenter>::OnStart();
-        GetRootContainer()->SetTouchable(true);
-        GetRootContainer()->SetDraggable(true);
-
         ScrollView_ = InitScreen();
-
         AddViewToRootContainer(ScrollView_);
 
     }
index e526144..37748d7 100644 (file)
@@ -941,8 +941,7 @@ namespace OHOS
             updatasider->SetVisible(false);
 
         }
-
-        GetRootContainer()->Add(SystemUpdateScrollView);
+        AddViewToRootContainer(SystemUpdateScrollView);
     }
 
     void SystemUpdateView::NoNeedUpdateViewInit(void)
index 310f592..e9118e7 100644 (file)
@@ -63,6 +63,7 @@ namespace OHOS
         TraingNomalView(TraingNomalView &&) = delete;
         TraingNomalView &operator=(TraingNomalView &&) = delete;
 
+        UIViewGroup *group = nullptr;
         UILabelExt *sporttitle_ = nullptr;
         UIButton *buttonGo_ = nullptr;
         UILabelButtonExt *buttonSet_ = nullptr;
index 61b9ca2..05f0260 100644 (file)
@@ -37,6 +37,8 @@ namespace OHOS
         TraingView(TraingView &&) = delete;
         TraingView &operator=(TraingView &&) = delete;
 
+        UIViewGroup *group = nullptr;
+
         UIButton *buttonmore_ = nullptr;
         UIButton *button1_ = nullptr;
         UIButton *button2_ = nullptr;
index a3c27c7..65d60d4 100644 (file)
@@ -767,10 +767,6 @@ void TraingEnddataView::OnStart() {
   PreLoad();
   InitData(); // 刷新数据
 
-  GetRootContainer()->SetDraggable(true);
-  GetRootContainer()->SetTouchable(true);
-  GetRootContainer()->SetOnDragListener(presenter_);
-
   // 检查是否有足够的GPS数据来绘制轨迹
   if (isNeedGPS == false) {
     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "该运动项不需要GPS");
index 3f8ca1e..9e6e615 100644 (file)
@@ -43,7 +43,7 @@ namespace OHOS
 
         // 初始化Lable
         InitLabelExt(sporttitle_, 83, 50, 300, 35, "label1", sport_id, DEFAULT_VECTOR_FONT_FILENAME, 30);
-        AddViewToRootContainer(sporttitle_);
+        group->Add(sporttitle_);
         
         // 初始化Button
         InitButton(buttonGo_, 133, 133, 200, 200, BUTTONGO);
@@ -61,8 +61,8 @@ namespace OHOS
 
         buttonGo_->SetOnClickListener(static_cast<UIView::OnClickListener *>(TraingNomalPresenter::GetInstance()));
         buttonSet_->SetOnClickListener(static_cast<UIView::OnClickListener *>(TraingNomalPresenter::GetInstance()));
-        AddViewToRootContainer(buttonGo_);
-        AddViewToRootContainer(buttonSet_);
+        group->Add(buttonGo_);
+        group->Add(buttonSet_);
         /*判断是否需要GPS*/
         if(TraingModel::GetInstance()->IsNeedGPS(sport_id) == false)
         {
@@ -71,9 +71,9 @@ namespace OHOS
         }
 #if defined(SUPPORT_GNSS)
         InitUILabel(heartrate_label_, -32, 230, 200, 60, "heartrate_label_", "--", DEFAULT_VECTOR_FONT_FILENAME, 30);
-        AddViewToRootContainer(heartrate_label_);
+        group->Add(heartrate_label_);
         InitUILabel(gps_label_, 295, 230, 200, 60, "label_time", "GPS", DEFAULT_VECTOR_FONT_FILENAME, 30);
-        AddViewToRootContainer(gps_label_);
+        group->Add(gps_label_);
         
         // 获取gps状态
         bool gps_status = TraingModel::GetInstance()->GetGPSConnectState();
@@ -90,9 +90,9 @@ namespace OHOS
             InitImageView(gps_image_, 375, 193, 100, 100, "gps_image", GPS_2_IMAGE);
             buttonGo_->SetImageSrc(GO_2_IMAGE, GO_2_IMAGE);
         }
-        AddViewToRootContainer(gps_image_);
+        group->Add(gps_image_);
         InitImageView(heartrate_image_, 48, 193, 100, 100, "heartrate_image_", HEARTRATE_1_IMAGE);
-        AddViewToRootContainer(heartrate_image_);
+        group->Add(heartrate_image_);
 #endif
     }
     /* DeInit:删除组件*/
@@ -146,32 +146,28 @@ namespace OHOS
             viewiInitStatus = true;
         }
     }
-    // 设置按键监听
-    static void SetKeyActListener()
-    {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetKeyActListener");
-        // 增加按键监听
-        RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::TraingNomalPresenter::GetInstance();
-        RootView::GetInstance()->SetOnKeyActListener(keyactListener);
-    }
+
     void TraingNomalView::OnStart()
     {
-       
-
-        // 创建 draglistener 实例并设置为拖动监听器
-        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(TraingNomalPresenter::GetInstance());
-        if (draglistener == nullptr)
+        if(group == nullptr)
         {
-            return;
+            group = new UIViewGroup();
+            if (group == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CheckAbnormalView::new UIViewGroup fail");
+                return;
+            }
+            group->SetPosition(0, 0, VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION);
+            group->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+            group->SetStyle(STYLE_BACKGROUND_OPA, UN_OPACITY);
+            group->SetTouchable(true);
+            group->SetDraggable(true);
+            group->SetOnDragListener(presenter_);
         }
-        GetRootContainer()->SetOnDragListener(draglistener);
-
-        GetRootContainer()->SetTouchable(true);
-        GetRootContainer()->SetDraggable(true);
+        AddViewToRootContainer(group);
 
         PreLoad();
-
-        SetKeyActListener();
+        RootView::GetInstance()->SetOnKeyActListener(presenter_);
     }
 
     // 更新训练目标 [考虑 通用目标 特殊目标]
@@ -224,8 +220,6 @@ namespace OHOS
         }
         gps_image_->SetSrc(image);
         buttonGo_->SetImageSrc(button_image_path.c_str(), button_image_path.c_str());
-        //刷新一下
-        GetRootContainer()->Invalidate();
         return true; 
     }
 }
index 0b6b4a1..51cbe23 100644 (file)
@@ -244,7 +244,7 @@ namespace OHOS
                 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingSetView:: new container[%d] fail", thisview);\r
                 return false;\r
             }\r
-            GetRootContainer()->Add(SetTagScrollView[thisview]);\r
+            AddViewToRootContainer(SetTagScrollView[thisview]);\r
         }\r
         return true;\r
     }\r
@@ -260,7 +260,7 @@ namespace OHOS
                 return false;\r
             }\r
             SetTagScrollView[thisview] = setcalories->SetCaluliViewInit();\r
-            GetRootContainer()->Add(SetTagScrollView[thisview]);\r
+            AddViewToRootContainer(SetTagScrollView[thisview]);\r
         }\r
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetTagScrollView[%d] is not null", thisview);\r
         return true;\r
@@ -277,7 +277,7 @@ namespace OHOS
                 return false;\r
             }\r
             SetTagScrollView[thisview] = settime->SetTimeViewInit();\r
-            GetRootContainer()->Add(SetTagScrollView[thisview]);\r
+            AddViewToRootContainer(SetTagScrollView[thisview]);\r
         }\r
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetTagScrollView[%d] is not null", thisview);\r
         return true;\r
@@ -294,7 +294,7 @@ namespace OHOS
                 return false;\r
             }\r
             SetTagScrollView[thisview] = setmile->SetMileViewInit();\r
-            GetRootContainer()->Add(SetTagScrollView[thisview]);\r
+            AddViewToRootContainer(SetTagScrollView[thisview]);\r
         }\r
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetTagScrollView[%d] is not null", thisview);\r
         return true;\r
@@ -311,7 +311,7 @@ namespace OHOS
                 return false;\r
             }\r
             SetTagScrollView[thisview] = setstep->SetStepViewInit();\r
-            GetRootContainer()->Add(SetTagScrollView[thisview]);\r
+            AddViewToRootContainer(SetTagScrollView[thisview]);\r
         }\r
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetTagScrollView[%d] is not null", thisview);\r
         return true;\r
@@ -425,13 +425,12 @@ namespace OHOS
         }\r
 \r
         SetKeyActListener();\r
-        // GetRootContainer()->Add(SetTagScrollView[SET_VIEW]);\r
         // SetCurrentViewId(SET_VIEW); // 设置当前页面ID\r
 \r
         if (group != nullptr)\r
         {\r
             SetTagScrollView[SET_VIEW] = group;\r
-            GetRootContainer()->Add(SetTagScrollView[SET_VIEW]);\r
+            AddViewToRootContainer(SetTagScrollView[SET_VIEW]);\r
             SetCurrentViewId(SET_VIEW);\r
         }\r
     }\r
index b79ec68..cc4b56c 100644 (file)
@@ -133,8 +133,6 @@ bool TraingView::AddImageView() {
   return true;\r
 }\r
 void TraingView::InitView() {\r
-\r
-\r
   // 初始化按键\r
   AddButton();\r
   // 初始化标签\r
@@ -142,27 +140,31 @@ void TraingView::InitView() {
   // 初始化图片\r
   AddImageView();\r
 \r
-  AddViewToRootContainer(button1_);\r
-  AddViewToRootContainer(button2_);\r
-  AddViewToRootContainer(button3_);\r
-  AddViewToRootContainer(buttonmore_);\r
+  group->Add(button1_);\r
+  group->Add(button2_);\r
+  group->Add(button3_);\r
+  group->Add(buttonmore_);\r
 \r
-  AddViewToRootContainer(title_label);\r
-  AddViewToRootContainer(btn1_label);\r
-  AddViewToRootContainer(btn2_label);\r
-  AddViewToRootContainer(btn3_label);\r
-  AddViewToRootContainer(btnmore_label);\r
+  group->Add(title_label);\r
+  group->Add(btn1_label);\r
+  group->Add(btn2_label);\r
+  group->Add(btn3_label);\r
+  group->Add(btnmore_label);\r
 \r
-  AddViewToRootContainer(btn1_image);\r
-  AddViewToRootContainer(btn2_image);\r
-  AddViewToRootContainer(btn3_image);\r
-  AddViewToRootContainer(btnmore_image);\r
+  group->Add(btn1_image);\r
+  group->Add(btn2_image);\r
+  group->Add(btn3_image);\r
+  group->Add(btnmore_image);\r
 \r
-  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel::InitView");\r
 }\r
 \r
 void TraingView::DeInitView() {\r
 \r
+  if (group != nullptr) {\r
+    group->RemoveAll();\r
+    delete group;\r
+    group = nullptr;\r
+  }\r
   if (buttonmore_ != nullptr) {\r
     delete buttonmore_;\r
     buttonmore_ = nullptr;\r
@@ -216,41 +218,26 @@ void TraingView::DeInitView() {
     btnmore_image = nullptr;\r
   }\r
 }\r
-\r
-// 设置按键监听\r
-static void SetKeyActListener() {\r
-  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetKeyActListener");\r
-  // 增加按键监听\r
-  RootView::OnKeyActListener *keyactListener =\r
-      (RootView::OnKeyActListener *)OHOS::TraingPresenter::GetInstance();\r
- RootView::GetInstance()->SetOnKeyActListener(keyactListener);\r
-}\r
 void TraingView::OnStart() {\r
-#if 0\r
-        printf(" data--training1_Text: %s\n", data->training1_Text.c_str());\r
-        printf(" data--training1_Image: %s\n", data->training1_Image.c_str());\r
-        printf(" data--training2_Text: %s\n", data->training2_Text.c_str());\r
-        printf(" data--training2_Image: %s\n", data->training2_Image.c_str());\r
-        printf(" data--training3_Text: %s\n", data->training3_Text.c_str());\r
-        printf(" data--training3_Image: %s\n", data->training3_Image.c_str());\r
-#endif\r
-\r
-\r
-  // 创建 draglistener 实例并设置为拖动监听器\r
-  UIView::OnDragListener *draglistener =\r
-      static_cast<UIView::OnDragListener *>(TraingPresenter::GetInstance());\r
-  if (draglistener == nullptr) {\r
-    return;\r
+  if(group == nullptr)\r
+  {\r
+      group = new UIViewGroup();\r
+      if (group == nullptr)\r
+      {\r
+          WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CheckAbnormalView::new UIViewGroup fail");\r
+          return;\r
+      }\r
+      group->SetPosition(0, 0, VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION);\r
+      group->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);\r
+      group->SetStyle(STYLE_BACKGROUND_OPA, 255);\r
+      group->SetTouchable(true);\r
+      group->SetDraggable(true);\r
+      group->SetOnDragListener(presenter_);\r
   }\r
-  GetRootContainer()->SetOnDragListener(draglistener);\r
-  GetRootContainer()->SetTouchable(true);\r
-  GetRootContainer()->SetDraggable(true);\r
+  AddViewToRootContainer(group);\r
 \r
   InitView();\r
-\r
-\r
-  // 增加按键监听\r
-  SetKeyActListener();\r
+  RootView::GetInstance()->SetOnKeyActListener(presenter_);\r
 }\r
 \r
 \r
index e5befee..bd194b4 100644 (file)
@@ -49,6 +49,7 @@ namespace OHOS
         TraingGPSView(TraingGPSView &&) = delete;
         TraingGPSView &operator=(TraingGPSView &&) = delete;
 
+        UIViewGroup *group = nullptr;
         UILabelExt *label1_ = nullptr;
         UILabelExt *label2_ = nullptr;
         UILabelExt *label3_ = nullptr;
index d7428f6..7fa8dd0 100644 (file)
@@ -53,6 +53,7 @@ namespace OHOS
         TraingGPSbackView(TraingGPSbackView &&) = delete;
         TraingGPSbackView &operator=(TraingGPSbackView &&) = delete;
        
+        UIViewGroup *group = nullptr;
         UILabelExt *label1_ = nullptr;
         UILabelExt *label2_ = nullptr;      
         UIButton *button1_ = nullptr;   
index d5d6090..f222c73 100644 (file)
@@ -52,7 +52,7 @@ namespace OHOS
         TraingGPSlackView(TraingGPSlackView &&) = delete;
         TraingGPSlackView &operator=(TraingGPSlackView &&) = delete;
 
-   
+        UIViewGroup *group = nullptr;
         UILabelExt *label1_ = nullptr;
         UILabelExt *label2_ = nullptr;
         UILabelExt *label3_ = nullptr;
index 3eca401..01d607e 100644 (file)
@@ -52,6 +52,7 @@ namespace OHOS
         TraingGPSlostView(TraingGPSlostView &&) = delete;
         TraingGPSlostView &operator=(TraingGPSlostView &&) = delete;
  
+        UIViewGroup *group{nullptr};
         UILabelExt *label1_ = nullptr;
         UILabelExt *label2_ = nullptr;      
         UIButton *button1_ = nullptr;   
index c24c902..7187878 100644 (file)
@@ -53,11 +53,8 @@ private:
 
   UILabelExt *label1_ = nullptr;
   UILabelExt *label2_ = nullptr;
-
-
   UILabelButtonExt *button_wait = nullptr;
   UILabelButtonExt *button_go = nullptr;
-
   UIImageView *image1_ = nullptr;
   UIImageView *image2_ = nullptr;
   bool viewiInitStatus{false};
index b1e5c54..bb91eff 100644 (file)
@@ -51,9 +51,7 @@ namespace OHOS
         TraingGPSsetView(TraingGPSsetView &&) = delete;
         TraingGPSsetView &operator=(TraingGPSsetView &&) = delete;
 
-  
         UIScrollView *scrollView1_ = nullptr;
-
         UILabelExt *label1_ = nullptr;
         UILabelExt *label2_ = nullptr;
         UILabelExt *label3_ = nullptr;
index e91d9f8..36601a1 100644 (file)
@@ -85,17 +85,22 @@ void TraingGPSView::PreLoad(void) {
   }
 }
 void TraingGPSView::OnStart() {
-
-  // 创建 draglistener 实例并设置为拖动监听器
-  UIView::OnDragListener *draglistener =
-      static_cast<UIView::OnDragListener *>(TraingGPSPresenter::GetInstance());
-  if (draglistener == nullptr) {
-    return;
+  if (group == nullptr)
+  {
+      group = new UIViewGroup();
+      if (group == nullptr)
+      {
+          WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CheckAbnormalView::new UIViewGroup fail");
+          return;
+      }
+      group->SetPosition(0, 0, VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION);
+      group->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+      group->SetStyle(STYLE_BACKGROUND_OPA, 255);
+      group->SetTouchable(true);
+      group->SetDraggable(true);
+      group->SetOnDragListener(presenter_);
   }
-  GetRootContainer()->SetOnDragListener(draglistener);
-
-  GetRootContainer()->SetTouchable(true);
-  GetRootContainer()->SetDraggable(true);
+  AddViewToRootContainer(group);
 
   PreLoad();
 }
index 98c8101..797c9fc 100644 (file)
@@ -3,7 +3,7 @@
 
 #include "common/image_cache_manager.h"
 #include "components/ui_label_ext.h"
-#include"ui_resource_string.h"
+#include "ui_resource_string.h"
 #include "UiConfig.h"
 #include "ui_resource_image.h"
 #include <ui_scroll_view.h>
@@ -22,7 +22,32 @@ namespace OHOS
 
     TraingGPSbackView::~TraingGPSbackView()
     {
-        DeInit();
+        if (group != nullptr)
+        {
+            group->RemoveAll();
+            delete group;
+            group = nullptr;
+        }
+        if (label1_ != nullptr)
+        {
+            delete label1_;
+            label1_ = nullptr;
+        }
+        if (label2_ != nullptr)
+        {
+            delete label2_;
+            label2_ = nullptr;
+        }
+        if (button1_ != nullptr)
+        {
+            delete button1_;
+            button1_ = nullptr;
+        }
+        if (image1_ != nullptr)
+        {
+            delete image1_;
+            image1_ = nullptr;
+        }
         g_pTraingGPSbackView = nullptr;
     }
 
@@ -35,40 +60,22 @@ namespace OHOS
     /* InitView:初始化界面*/
     void TraingGPSbackView ::InitView()
     {
-       
         // 初始化Lable
-       InitLabel(label1_, 175, 52, 195, 35, "label1", "GPS连接", DEFAULT_VECTOR_FONT_FILENAME, 35);
-        AddViewToRootContainer(label1_);
-       InitLabel(label2_, 55, 253, 146, 35, "label2", "GPS已连接,当前信号正常", DEFAULT_VECTOR_FONT_FILENAME, 30);
-        AddViewToRootContainer(label2_);
+        InitLabel(label1_, 175, 52, 195, 35, "label1", "GPS连接", DEFAULT_VECTOR_FONT_FILENAME, 35);
+        group->Add(label1_);
+        InitLabel(label2_, 55, 253, 146, 35, "label2", "GPS已连接,当前信号正常", DEFAULT_VECTOR_FONT_FILENAME, 30);
+        group->Add(label2_);
 
         // 初始化image
-       InitImageView(image1_, 193, 140, 40, 40, "image1", BACK_IMAGE);
-        AddViewToRootContainer(image1_);
+        InitImageView(image1_, 193, 140, 40, 40, "image1", BACK_IMAGE);
+        group->Add(image1_);
 
         // 初始化Button
-       InitButton(button1_, 0, 366, 466, 100, BUTTONOK);
+        InitButton(button1_, 0, 366, 466, 100, BUTTONOK);
         // Set additional property
         button1_->SetOnClickListener(static_cast<UIView::OnClickListener *>(TraingGPSbackPresenter::GetInstance()));
         button1_->SetImageSrc(BUTTONOK_IMAGE, BUTTONOK_IMAGE);
-        AddViewToRootContainer(button1_);
-    }
-    /* DeInit:删除组件*/
-    void TraingGPSbackView::DeInit()
-    {
-        // UIView *view = static_cast<UIViewGroup *>(container_)->GetChildrenHead();
-        // while (view != nullptr)
-        // {
-        //     UIView *tempView = view;
-        //     view = view->GetNextSibling();
-        //     if (tempView->GetParent())
-        //     {
-        //         static_cast<UIViewGroup *>(tempView->GetParent())->Remove(tempView);
-        //     }
-        //     delete tempView;
-        // }
-        // delete container_;
-        // container_ = nullptr;
+        group->Add(button1_);
     }
 
     void TraingGPSbackView::PreLoad(void)
@@ -81,21 +88,23 @@ namespace OHOS
     }
     void TraingGPSbackView::OnStart()
     {
-
-
-        // 创建 draglistener 实例并设置为拖动监听器
-        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(TraingGPSbackPresenter::GetInstance());
-        if (draglistener == nullptr)
+        if (group == nullptr)
         {
-            return;
+            group = new UIViewGroup();
+            if (group == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CheckAbnormalView::new UIViewGroup fail");
+                return;
+            }
+            group->SetPosition(0, 0, VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION);
+            group->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+            group->SetStyle(STYLE_BACKGROUND_OPA, 255);
+            group->SetTouchable(true);
+            group->SetDraggable(true);
+            group->SetOnDragListener(presenter_);
         }
-        GetRootContainer()->SetOnDragListener(draglistener);
-
-        GetRootContainer()->SetTouchable(true);
-        GetRootContainer()->SetDraggable(true);
-
+        AddViewToRootContainer(group);
         PreLoad();
     }
 
-
 }
index 3f4ef1b..2a92eab 100644 (file)
@@ -3,7 +3,7 @@
 
 #include "common/image_cache_manager.h"
 #include "components/ui_label_ext.h"
-#include"ui_resource_string.h"
+#include "ui_resource_string.h"
 #include "UiConfig.h"
 #include "ui_resource_image.h"
 #include <ui_scroll_view.h>
@@ -33,57 +33,65 @@ namespace OHOS
 
         return g_pTraingGPSlackView;
     }
-   
+
     /* InitView:初始化界面*/
     void TraingGPSlackView ::InitView()
     {
 
-
         // 初始化Lable
-       InitLabel(label1_, 203, 52, 195, 35, "label1", "骑行", DEFAULT_VECTOR_FONT_FILENAME, 30);
-        AddViewToRootContainer(label1_);
-       InitLabel(label2_, 160, 370, 146, 35, "label2", "设定目标 >", DEFAULT_VECTOR_FONT_FILENAME, 30);
-        AddViewToRootContainer(label2_);
-       InitLabel(label3_, 41, 237, 54, 41, "lable3", "--", DEFAULT_VECTOR_FONT_FILENAME, 35);
-        AddViewToRootContainer(label3_);
-       InitLabel(label4_, 361, 237, 54, 41, "lable4", "--", DEFAULT_VECTOR_FONT_FILENAME, 35);
-        AddViewToRootContainer(label4_);
+        InitLabel(label1_, 203, 52, 195, 35, "label1", "骑行", DEFAULT_VECTOR_FONT_FILENAME, 30);
+        group->Add(label1_);
+        InitLabel(label2_, 160, 370, 146, 35, "label2", "设定目标 >", DEFAULT_VECTOR_FONT_FILENAME, 30);
+        group->Add(label2_);
+        InitLabel(label3_, 41, 237, 54, 41, "lable3", "--", DEFAULT_VECTOR_FONT_FILENAME, 35);
+        group->Add(label3_);
+        InitLabel(label4_, 361, 237, 54, 41, "lable4", "--", DEFAULT_VECTOR_FONT_FILENAME, 35);
+        group->Add(label4_);
         // 初始化image
-       InitImageView(image1_, 48, 193, 40, 40, "image1", HEARTRATE_2_IMAGE);
-       InitImageView(image2_, 375, 193, 40, 40, "image2", GPS_2_IMAGE);
-        AddViewToRootContainer(image1_);
-        AddViewToRootContainer(image2_);
+        InitImageView(image1_, 48, 193, 40, 40, "image1", HEARTRATE_2_IMAGE);
+        InitImageView(image2_, 375, 193, 40, 40, "image2", GPS_2_IMAGE);
+        group->Add(image1_);
+        group->Add(image2_);
         // 初始化Button
-       InitButton(button1_, 133, 133, 200, 200, BUTTONGO);
+        InitButton(button1_, 133, 133, 200, 200, BUTTONGO);
         // Set additional property
         char *button1defaultImgSrc = "/user/res/Training/Go_2.bin";
         char *button1triggeredImgSrc = nullptr;
         button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc);
 
-       InitButton(button2_, 160, 370, 146, 35, BUTTONSET);
+        InitButton(button2_, 160, 370, 146, 35, BUTTONSET);
         button2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); // 设置为透明按键
         button2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
         button2_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x80, UIButton::PRESSED); // 设置按下时的透明度为半透明
 
-        AddViewToRootContainer(button1_);
-        AddViewToRootContainer(button2_);
+        group->Add(button1_);
+        group->Add(button2_);
     }
     /* DeInit:删除组件*/
     void TraingGPSlackView::DeInit()
     {
-        // UIView *view = static_cast<UIViewGroup *>(container_)->GetChildrenHead();
-        // while (view != nullptr)
-        // {
-        //     UIView *tempView = view;
-        //     view = view->GetNextSibling();
-        //     if (tempView->GetParent())
-        //     {
-        //         static_cast<UIViewGroup *>(tempView->GetParent())->Remove(tempView);
-        //     }
-        //     delete tempView;
-        // }
-        // delete container_;
-        // container_ = nullptr;
+        if (group != nullptr)
+        {
+            group->RemoveAll();
+            delete group;
+            group = nullptr;
+        }
+        delete label1_;
+        label1_ = nullptr;
+        delete label2_;
+        label2_ = nullptr;
+        delete label3_;
+        label3_ = nullptr;
+        delete label4_;
+        label4_ = nullptr;
+        delete image1_;
+        image1_ = nullptr;
+        delete image2_;
+        image2_ = nullptr;
+        delete button1_;
+        button1_ = nullptr;
+        delete button2_;
+        button2_ = nullptr;
     }
 
     void TraingGPSlackView::PreLoad(void)
@@ -96,22 +104,23 @@ namespace OHOS
     }
     void TraingGPSlackView::OnStart()
     {
-
-
-        // 创建 draglistener 实例并设置为拖动监听器
-        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(TraingGPSlackPresenter::GetInstance());
-        if (draglistener == nullptr)
+        if (group == nullptr)
         {
-            return;
+            group = new UIViewGroup();
+            if (group == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CheckAbnormalView::new UIViewGroup fail");
+                return;
+            }
+            group->SetPosition(0, 0, VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION);
+            group->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+            group->SetStyle(STYLE_BACKGROUND_OPA, 255);
+            group->SetTouchable(true);
+            group->SetDraggable(true);
+            group->SetOnDragListener(presenter_);
         }
-        GetRootContainer()->SetOnDragListener(draglistener);
-
-        GetRootContainer()->SetTouchable(true);
-        GetRootContainer()->SetDraggable(true);
-
+        AddViewToRootContainer(group);
         PreLoad();
-
     }
 
-
 }
index 6ad8848..e98f46b 100644 (file)
@@ -3,7 +3,7 @@
 
 #include "common/image_cache_manager.h"
 #include "components/ui_label_ext.h"
-#include"ui_resource_string.h"
+#include "ui_resource_string.h"
 #include "UiConfig.h"
 #include "ui_resource_image.h"
 #include <ui_scroll_view.h>
@@ -29,47 +29,56 @@ namespace OHOS
 
     TraingGPSlostView *TraingGPSlostView::GetInstance()
     {
-
         return g_pTraingGPSlostView;
     }
-   
 
     /* InitView:初始化界面*/
     void TraingGPSlostView ::InitView()
     {
-
-        // 初始化Lable
-       InitLabel(label1_, 175, 52, 195, 35, "label1", "GPS丢失", DEFAULT_VECTOR_FONT_FILENAME, 35);
-        AddViewToRootContainer(label1_);
-       InitLabel(label2_, 55, 253, 146, 35, "label2", "当前位置搜索不到GPS信号", DEFAULT_VECTOR_FONT_FILENAME, 30);
-        AddViewToRootContainer(label2_);
+        InitLabel(label1_, 175, 52, 195, 35, "label1", "GPS丢失", DEFAULT_VECTOR_FONT_FILENAME, 35);
+        group->Add(label1_);
+        InitLabel(label2_, 55, 253, 146, 35, "label2", "当前位置搜索不到GPS信号", DEFAULT_VECTOR_FONT_FILENAME, 30);
+        group->Add(label2_);
 
         // 初始化image
-       InitImageView(image1_, 193, 140, 40, 40, "image1", WARNING_IMAGE);
-        AddViewToRootContainer(image1_);
+        InitImageView(image1_, 193, 140, 40, 40, "image1", WARNING_IMAGE);
+        group->Add(image1_);
 
         // 初始化Button
-       InitButton(button1_, 0, 366, 466, 100, BUTTONOK);
+        InitButton(button1_, 0, 366, 466, 100, BUTTONOK);
         // Set additional property
         button1_->SetImageSrc(BUTTONOK_IMAGE, nullptr);
-        AddViewToRootContainer(button1_);
+        group->Add(button1_);
     }
     /* DeInit:删除组件*/
     void TraingGPSlostView::DeInit()
     {
-        // UIView *view = static_cast<UIViewGroup *>(container_)->GetChildrenHead();
-        // while (view != nullptr)
-        // {
-        //     UIView *tempView = view;
-        //     view = view->GetNextSibling();
-        //     if (tempView->GetParent())
-        //     {
-        //         static_cast<UIViewGroup *>(tempView->GetParent())->Remove(tempView);
-        //     }
-        //     delete tempView;
-        // }
-        // delete container_;
-        // container_ = nullptr;
+        if (group != nullptr)
+        {
+            group->RemoveAll();
+            delete group;
+            group = nullptr;
+        }
+        if (label1_ != nullptr)
+        {
+            delete label1_;
+            label1_ = nullptr;
+        }
+        if (label2_ != nullptr)
+        {
+            delete label2_;
+            label2_ = nullptr;
+        }
+        if (button1_ != nullptr)
+        {
+            delete button1_;
+            button1_ = nullptr;
+        }
+        if (image1_ != nullptr)
+        {
+            delete image1_;
+            image1_ = nullptr;
+        }
     }
 
     void TraingGPSlostView::PreLoad(void)
@@ -82,18 +91,22 @@ namespace OHOS
     }
     void TraingGPSlostView::OnStart()
     {
-      
-        // 创建 draglistener 实例并设置为拖动监听器
-        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(TraingGPSlostPresenter::GetInstance());
-        if (draglistener == nullptr)
+        if (group == nullptr)
         {
-            return;
+            group = new UIViewGroup();
+            if (group == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CheckAbnormalView::new UIViewGroup fail");
+                return;
+            }
+            group->SetPosition(0, 0, VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION);
+            group->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+            group->SetStyle(STYLE_BACKGROUND_OPA, 255);
+            group->SetTouchable(true);
+            group->SetDraggable(true);
+            group->SetOnDragListener(presenter_);
         }
-        GetRootContainer()->SetOnDragListener(draglistener);
-
-        GetRootContainer()->SetTouchable(true);
-        GetRootContainer()->SetDraggable(true);
-
+        AddViewToRootContainer(group);
         PreLoad();
     }
 
index 8583e09..4d7c9db 100644 (file)
@@ -3,7 +3,7 @@
 
 #include "common/image_cache_manager.h"
 #include "components/ui_label_ext.h"
-#include"ui_resource_string.h"
+#include "ui_resource_string.h"
 #include "UiConfig.h"
 #include "ui_resource_image.h"
 #include <ui_scroll_view.h>
@@ -30,17 +30,12 @@ namespace OHOS
 
     TraingGPSnoteView *TraingGPSnoteView::GetInstance()
     {
-
         return g_pTraingGPSnoteView;
     }
 
-   
     /* InitView:初始化界面*/
     void TraingGPSnoteView ::InitView()
     {
-
-
-        // Add ScrollView to App
         if (scrollView1_ == nullptr)
         {
             scrollView1_ = new UIScrollView();
@@ -51,7 +46,7 @@ namespace OHOS
         scrollView1_->SetReboundSize(100);
         scrollView1_->SetScrollBlankSize(52);
         scrollView1_->SetHorizontalScrollState(false);
-        // Add to rootView
+        scrollView1_->SetOnDragListener(presenter_);
         AddViewToRootContainer(scrollView1_);
         scrollView1_->SetVisible(true);
 
@@ -72,23 +67,20 @@ namespace OHOS
         button_go->SetOnClickListener(presenter_);
 
         // 初始化Lable
-       InitLabel(label1_, 133, 52, 200, 60, "label1", "GPS未准备", DEFAULT_VECTOR_FONT_FILENAME, 30);
-       InitLabel(label2_, 33, 215, 400, 90, "label2", "GPS仍在定位,建议等待定位 完成后再开始训练", DEFAULT_VECTOR_FONT_FILENAME, 30);
-
+        InitLabel(label1_, 133, 52, 200, 60, "label1", "GPS未准备", DEFAULT_VECTOR_FONT_FILENAME, 30);
+        InitLabel(label2_, 33, 215, 400, 90, "label2", "GPS仍在定位,建议等待定位 完成后再开始训练", DEFAULT_VECTOR_FONT_FILENAME, 30);
 
         scrollView1_->Add(label1_);
         scrollView1_->Add(label2_);
 
-
         // Add ImageView to App
         if (image2_ == nullptr)
         {
             image2_ = new UIImageView();
         }
-        image2_->SetPosition(181, 500); // widget's left position and top position
-        image2_->Resize(100, 100);       // widget's width and height
-        image2_->SetViewId("image7");    // Set style
-        // Add to rootView
+        image2_->SetPosition(181, 500); 
+        image2_->Resize(100, 100);      
+        image2_->SetViewId("image7");   
         scrollView1_->Add(image2_);
         image2_->SetVisible(true);
     }
@@ -109,7 +101,7 @@ namespace OHOS
                 delete button_wait;
                 button_wait = nullptr;
             }
-            if(button_go != nullptr)
+            if (button_go != nullptr)
             {
                 delete button_go;
                 button_go = nullptr;
@@ -133,7 +125,6 @@ namespace OHOS
             delete scrollView1_;
             scrollView1_ = nullptr;
         }
-        
     }
 
     void TraingGPSnoteView::PreLoad(void)
@@ -146,20 +137,7 @@ namespace OHOS
     }
     void TraingGPSnoteView::OnStart()
     {
-
-        // 创建 draglistener 实例并设置为拖动监听器
-        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(TraingGPSnotePresenter::GetInstance());
-        if (draglistener == nullptr)
-        {
-            return;
-        }
-        GetRootContainer()->SetOnDragListener(draglistener);
-
-        GetRootContainer()->SetTouchable(true);
-        GetRootContainer()->SetDraggable(true);
-
         PreLoad();
-
     }
 
 }
index ead821e..86d501b 100644 (file)
@@ -3,7 +3,7 @@
 
 #include "common/image_cache_manager.h"
 #include "components/ui_label_ext.h"
-#include"ui_resource_string.h"
+#include "ui_resource_string.h"
 #include "UiConfig.h"
 #include "ui_resource_image.h"
 #include <ui_scroll_view.h>
@@ -33,10 +33,9 @@ namespace OHOS
 
     TraingGPSsetView *TraingGPSsetView::GetInstance()
     {
-
         return g_pTraingGPSsetView;
     }
-   
+
     /*  Traing:初始化list  */
     void TraingGPSsetView::InitList()
     {
@@ -92,7 +91,6 @@ namespace OHOS
     /* InitView:初始化界面*/
     void TraingGPSsetView ::InitView()
     {
-
         // Add ScrollView to App
         if (scrollView1_ == nullptr)
         {
@@ -105,36 +103,37 @@ namespace OHOS
         scrollView1_->SetReboundSize(100);
         scrollView1_->SetScrollBlankSize(52);
         scrollView1_->SetHorizontalScrollState(false);
+        scrollView1_->SetOnDragListener(presenter_);
         // Add to rootView
         AddViewToRootContainer(scrollView1_);
         scrollView1_->SetVisible(true);
 
         //  初始化Button
-       InitButton(button1_, 43, 120, 380, 100, BUTTONTIME);
-       InitButton(button2_, 43, 240, 380, 100, BUTTONMIL);
-       InitButton(button3_, 43, 360, 380, 100, BUTTONCALULI);
-       InitButton(button4_, 43, 480, 380, 100, BUTTONWALK);
+        InitButton(button1_, 43, 120, 380, 100, BUTTONTIME);
+        InitButton(button2_, 43, 240, 380, 100, BUTTONMIL);
+        InitButton(button3_, 43, 360, 380, 100, BUTTONCALULI);
+        InitButton(button4_, 43, 480, 380, 100, BUTTONWALK);
         scrollView1_->Add(button1_);
         scrollView1_->Add(button2_);
         scrollView1_->Add(button3_);
         scrollView1_->Add(button4_);
 
         // 初始化Image
-       InitImageView(image1_, 380, 160, 100, 100, "image1", ICON_IMAGE);
-       InitImageView(image2_, 380, 280, 100, 100, "image2", ICON_IMAGE);
-       InitImageView(image3_, 380, 400, 100, 100, "image3", ICON_IMAGE);
-       InitImageView(image4_, 380, 520, 100, 100, "image4", ICON_IMAGE);
+        InitImageView(image1_, 380, 160, 100, 100, "image1", ICON_IMAGE);
+        InitImageView(image2_, 380, 280, 100, 100, "image2", ICON_IMAGE);
+        InitImageView(image3_, 380, 400, 100, 100, "image3", ICON_IMAGE);
+        InitImageView(image4_, 380, 520, 100, 100, "image4", ICON_IMAGE);
         scrollView1_->Add(image1_);
         scrollView1_->Add(image2_);
         scrollView1_->Add(image3_);
         scrollView1_->Add(image4_);
 
         // 初始化Lable
-       InitLabel(label1_, 203, 52, 120, 35, "label1", "骑行", DEFAULT_VECTOR_FONT_FILENAME, 30);
-       InitLabel(label2_, 300, 160, 60, 35, "label2", "30 分钟", DEFAULT_VECTOR_FONT_FILENAME, 20);
-       InitLabel(label3_, 300, 280, 69, 23, "label3", "5 公里", DEFAULT_VECTOR_FONT_FILENAME, 20);
-       InitLabel(label4_, 300, 400, 60, 35, "label4", "500 千卡", DEFAULT_VECTOR_FONT_FILENAME, 20);
-       InitLabel(label5_, 300, 520, 60, 35, "label5", "2000 步", DEFAULT_VECTOR_FONT_FILENAME, 20);
+        InitLabel(label1_, 203, 52, 120, 35, "label1", "骑行", DEFAULT_VECTOR_FONT_FILENAME, 30);
+        InitLabel(label2_, 300, 160, 60, 35, "label2", "30 分钟", DEFAULT_VECTOR_FONT_FILENAME, 20);
+        InitLabel(label3_, 300, 280, 69, 23, "label3", "5 公里", DEFAULT_VECTOR_FONT_FILENAME, 20);
+        InitLabel(label4_, 300, 400, 60, 35, "label4", "500 千卡", DEFAULT_VECTOR_FONT_FILENAME, 20);
+        InitLabel(label5_, 300, 520, 60, 35, "label5", "2000 步", DEFAULT_VECTOR_FONT_FILENAME, 20);
         scrollView1_->Add(label1_);
         scrollView1_->Add(label2_);
         scrollView1_->Add(label3_);
@@ -148,19 +147,92 @@ namespace OHOS
     /* DeInit:删除组件 */
     void TraingGPSsetView::DeInit()
     {
-        // UIView *view = static_cast<UIViewGroup *>(container_)->GetChildrenHead();
-        // while (view != nullptr)
-        // {
-        //     UIView *tempView = view;
-        //     view = view->GetNextSibling();
-        //     if (tempView->GetParent())
-        //     {
-        //         static_cast<UIViewGroup *>(tempView->GetParent())->Remove(tempView);
-        //     }
-        //     delete tempView;
-        // }
-        // delete container_;
-        // container_ = nullptr;
+        if (scrollView1_ != nullptr)
+        {
+            scrollView1_->RemoveAll();
+            delete scrollView1_;
+            scrollView1_ = nullptr;
+        }
+        if (list1_ != nullptr)
+        {
+            delete list1_;
+            list1_ = nullptr;
+        }
+        if (list1adapter_ != nullptr)
+        {
+            delete list1adapter_;
+            list1adapter_ = nullptr;
+        }
+        if (list1data_ != nullptr)
+        {
+            delete list1data_;
+            list1data_ = nullptr;
+        }
+        if (button1_ != nullptr)
+        {
+            delete button1_;
+            button1_ = nullptr;
+        }
+        if (button2_ != nullptr)
+        {
+            delete button2_;
+            button2_ = nullptr;
+        }
+        if (button3_ != nullptr)
+        {
+            delete button3_;
+            button3_ = nullptr;
+        }
+        if (button4_ != nullptr)
+        {
+            delete button4_;
+            button4_ = nullptr;
+        }
+        if (image1_ != nullptr)
+        {
+            delete image1_;
+            image1_ = nullptr;
+        }
+        if (image2_ != nullptr)
+        {
+            delete image2_;
+            image2_ = nullptr;
+        }
+        if (image3_ != nullptr)
+        {
+            delete image3_;
+            image3_ = nullptr;
+        }
+        if (image4_ != nullptr)
+        {
+            delete image4_;
+            image4_ = nullptr;
+        }
+        if (label1_ != nullptr)
+        {
+            delete label1_;
+            label1_ = nullptr;
+        }
+        if (label2_ != nullptr)
+        {
+            delete label2_;
+            label2_ = nullptr;
+        }
+        if (label3_ != nullptr)
+        {
+            delete label3_;
+            label3_ = nullptr;
+        }
+        if (label4_ != nullptr)
+        {
+            delete label4_;
+            label4_ = nullptr;
+        }
+        if (label5_ != nullptr)
+        {
+            delete label5_;
+            label5_ = nullptr;
+        }
     }
 
     void TraingGPSsetView::PreLoad(void)
@@ -173,22 +245,7 @@ namespace OHOS
     }
     void TraingGPSsetView::OnStart()
     {
-
-
-        // 创建 draglistener 实例并设置为拖动监听器
-        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(TraingGPSsetPresenter::GetInstance());
-        if (draglistener == nullptr)
-        {
-            return;
-        }
-        GetRootContainer()->SetOnDragListener(draglistener);
-
-        GetRootContainer()->SetTouchable(true);
-        GetRootContainer()->SetDraggable(true);
-
         PreLoad();
-
     }
 
-
 }
index 30a9397..5907737 100644 (file)
@@ -852,7 +852,7 @@ void TraingCardView::ShowEndView() {
   back->SetImageSrc(YES_IMAGE, YES_IMAGE);\r
   endView->Add(exit);\r
   endView->Add(back);\r
-  GetRootContainer()->Add(endView);\r
+  AddViewToRootContainer(endView);\r
   endView->SetDraggable(false);\r
   endView->SetTouchable(true);\r
   endView->SetVisible(false); // 界面隐藏\r
@@ -897,7 +897,7 @@ void TraingCardView::ShowGetTagView() {
   getView->Add(buttonok_);\r
 \r
   InitImageAnimator();\r
-  GetRootContainer()->Add(getView);\r
+  AddViewToRootContainer(getView);\r
   getView->SetDraggable(false);\r
   getView->SetTouchable(true);\r
   getView->SetVisible(false); // 界面隐藏\r
@@ -943,7 +943,7 @@ void TraingCardView::ShowHeartView() {
       TraingCardPresenter::GetInstance()));\r
   heartView->Add(buttonnote_);\r
 \r
-  GetRootContainer()->Add(heartView);\r
+  AddViewToRootContainer(heartView);\r
   heartView->SetDraggable(false);\r
   heartView->SetTouchable(true);\r
   heartView->SetVisible(false); // 界面隐藏\r