From e18ffbfe1e299ece5da5141cf51660edca9fc541 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Mon, 16 Mar 2026 17:16:37 +0800 Subject: [PATCH] =?utf8?q?=E7=95=8C=E9=9D=A2=E4=BC=98=E5=8C=96=E8=A7=A3?= =?utf8?q?=E5=86=B3=E6=81=AF=E5=B1=8F=E6=BB=91=E5=8A=A8=E7=9B=91=E5=90=AC?= =?utf8?q?=E5=A4=B1=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativelauncher/include/AppViewIDs.h | 1 - .../nativeui/callerlog/src/CallerLogView.cpp | 6 +- .../nativeui/goal/src/Maingoalview.cpp | 8 - .../nativeui/health/CheckAbnormalView.cpp | 40 +++-- .../nativeui/health/CheckAbnormalView.h | 1 + .../heartrate/include/HeartDetectionView.h | 1 + .../heartrate/include/HeartResultView.h | 1 + .../heartrate/src/HeartDetectionView.cpp | 35 ++-- .../heartrate/src/HeartResultView.cpp | 28 ++- .../src/MotionRecognitionView.cpp | 7 - .../networkandcall/src/NetworkAndCallView.cpp | 9 +- .../nativeui/set_aod/src/SetAodDialView.cpp | 4 - .../set_desktop/include/SetDesktopModel.h | 37 ---- .../set_desktop/include/SetDesktopPresenter.h | 36 ---- .../set_desktop/include/SetDesktopView.h | 57 ------ .../set_desktop/src/SetDesktopModel.cpp | 54 ------ .../set_desktop/src/SetDesktopPresenter.cpp | 66 ------- .../set_desktop/src/SetDesktopView.cpp | 162 ------------------ .../set_dial_style/include/SetDialStyleView.h | 1 + .../set_dial_style/src/SetDialStyleView.cpp | 32 ++-- .../include/SetTimeFormatView.h | 1 + .../set_time_format/src/SetTimeFormatView.cpp | 27 +-- .../nativeui/sleep/include/SleepControlView.h | 1 + .../nativeui/sleep/src/SleepControlView.cpp | 31 +++- .../nativeui/sleepmode/src/SleepModeView.cpp | 5 - .../systemupdate/src/SystemUpdateView.cpp | 3 +- .../nativeui/traing/include/TraingNomalView.h | 1 + .../nativeui/traing/include/TraingView.h | 2 + .../nativeui/traing/src/TraingEnddataView.cpp | 4 - .../nativeui/traing/src/TraingNomalView.cpp | 52 +++--- .../nativeui/traing/src/TraingSetView.cpp | 13 +- .../nativeui/traing/src/TraingView.cpp | 81 ++++----- .../training_GPS/include/TraingGPSView.h | 1 + .../training_GPS/include/TraingGPSbackView.h | 1 + .../training_GPS/include/TraingGPSlackView.h | 2 +- .../training_GPS/include/TraingGPSlostView.h | 1 + .../training_GPS/include/TraingGPSnoteView.h | 3 - .../training_GPS/include/TraingGPSsetView.h | 2 - .../traing/training_GPS/src/TraingGPSView.cpp | 25 +-- .../training_GPS/src/TraingGPSbackView.cpp | 89 +++++----- .../training_GPS/src/TraingGPSlackView.cpp | 99 ++++++----- .../training_GPS/src/TraingGPSlostView.cpp | 85 +++++---- .../training_GPS/src/TraingGPSnoteView.cpp | 38 +--- .../training_GPS/src/TraingGPSsetView.cpp | 147 +++++++++++----- .../training_card/src/TraingCardView.cpp | 6 +- 45 files changed, 494 insertions(+), 812 deletions(-) delete mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/set_desktop/include/SetDesktopModel.h delete mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/set_desktop/include/SetDesktopPresenter.h delete mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/set_desktop/include/SetDesktopView.h delete mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/set_desktop/src/SetDesktopModel.cpp delete mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/set_desktop/src/SetDesktopPresenter.cpp delete mode 100644 code/sdk/application/wearable/n9/nativeapp/nativeui/set_desktop/src/SetDesktopView.cpp diff --git a/code/sdk/application/wearable/n9/nativeapp/nativelauncher/include/AppViewIDs.h b/code/sdk/application/wearable/n9/nativeapp/nativelauncher/include/AppViewIDs.h index b105dcfc0..b92743c9c 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativelauncher/include/AppViewIDs.h @@ -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 合并 ---------------------------- */ diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/callerlog/src/CallerLogView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/callerlog/src/CallerLogView.cpp index bc0d0a1c7..ed0a37c46 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/callerlog/src/CallerLogView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/callerlog/src/CallerLogView.cpp @@ -125,7 +125,7 @@ void CallerLogView::InitBluetoothHintsGroup() hintsImageView->SetSrc(PNG_BLUETOOTH_HINTS_PATH); hintsGroup->Add(hintsImageView); - GetRootContainer()->Add(hintsGroup); + AddViewToRootContainer(hintsGroup); hintsGroup->SetVisible(false); return; } @@ -208,7 +208,7 @@ void CallerLogView::OnStart() WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerLogView::CreateNoDataCallerLogViewGroup error"); return; } - GetRootContainer()->Add(group); + AddViewToRootContainer(group); if (!CreateCallerLogViewGroup()) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerLogView::CreateCallerLogViewGroup error"); @@ -256,7 +256,7 @@ void CallerLogView::OnStart() return; } - GetRootContainer()->Add(scrollview); + AddViewToRootContainer(scrollview); if (num == 0) { group->SetVisible(true); diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/goal/src/Maingoalview.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/goal/src/Maingoalview.cpp index 9e52ac710..00d32510f 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/goal/src/Maingoalview.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/goal/src/Maingoalview.cpp @@ -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); - /* -------------------------------------------------------------------------- */ } diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/health/CheckAbnormalView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/health/CheckAbnormalView.cpp index 347e2b40c..5798136fb 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/health/CheckAbnormalView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/health/CheckAbnormalView.cpp @@ -63,8 +63,8 @@ namespace OHOS ReButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffFF8A36); // 设置按键颜色 ReButton->SetOnClickListener(presenter_); - AddViewToRootContainer(StButton); - AddViewToRootContainer(ReButton); + group->Add(StButton); + group->Add(ReButton); return true; } /*** @@ -81,8 +81,8 @@ namespace OHOS noteLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); noteLabel->SetRollSpeed(23); - AddViewToRootContainer(titleLabel); - AddViewToRootContainer(noteLabel); + group->Add(titleLabel); + group->Add(noteLabel); return true; } /*** @@ -96,7 +96,7 @@ namespace OHOS noteimage->SetPosition(193, 120, 80, 80); noteimage->SetSrc(BLOOD_PATH_NOTE); - AddViewToRootContainer(noteimage); + group->Add(noteimage); return true; } /*** @@ -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_); } } diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/health/CheckAbnormalView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/health/CheckAbnormalView.h index a6e7e77d8..b17125f90 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/health/CheckAbnormalView.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/health/CheckAbnormalView.h @@ -56,6 +56,7 @@ namespace OHOS bool Initbackground(); private: + UIViewGroup *group = nullptr; // 提醒图标 UIImageView *noteimage = nullptr; // 按键 diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/heartrate/include/HeartDetectionView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/heartrate/include/HeartDetectionView.h index 2cc29217d..cf53cad75 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/heartrate/include/HeartDetectionView.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/heartrate/include/HeartDetectionView.h @@ -40,6 +40,7 @@ namespace OHOS void UpShowHeartText(void); private: + UIViewGroup *group{nullptr}; UIImageAnimatorView *imageAnimator{nullptr}; UILabelExt *titleLabel{nullptr}; UILabel *HeartText{nullptr}; diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/heartrate/include/HeartResultView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/heartrate/include/HeartResultView.h index 62b37382a..213b27cc7 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/heartrate/include/HeartResultView.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/heartrate/include/HeartResultView.h @@ -38,6 +38,7 @@ namespace OHOS bool Initbackground(); private: + UIViewGroup *group = nullptr; UIImageView *background = nullptr; UILabelExt *titleLabel = nullptr; UILabelExt *timeLabel = nullptr; diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/heartrate/src/HeartDetectionView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/heartrate/src/HeartDetectionView.cpp index d71284969..3dec4390d 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/heartrate/src/HeartDetectionView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/heartrate/src/HeartDetectionView.cpp @@ -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(); diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/heartrate/src/HeartResultView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/heartrate/src/HeartResultView.cpp index 29e654e48..f37246d2c 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/heartrate/src/HeartResultView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/heartrate/src/HeartResultView.cpp @@ -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_); } } diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/motionrecognition/src/MotionRecognitionView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/motionrecognition/src/MotionRecognitionView.cpp index 255d73aad..c9d5f45d6 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/motionrecognition/src/MotionRecognitionView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/motionrecognition/src/MotionRecognitionView.cpp @@ -169,18 +169,11 @@ namespace OHOS void MotionRecognitionView::OnStart() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MotionRecognitionView::OnStart"); - View::OnStart(); - - - if (!viewInitStatus) { MotionRecognitionViewInit(); } - // 增加按键监听 - // GetRootContainer()->SetOnKeyActListener(presenter_); - scrollView->Add(Title); scrollView->Add(MotionRecognitionImage); scrollView->Add(MotionRecognitionLabel); diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/networkandcall/src/NetworkAndCallView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/networkandcall/src/NetworkAndCallView.cpp index f9efdb922..68a4bc341 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/networkandcall/src/NetworkAndCallView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/networkandcall/src/NetworkAndCallView.cpp @@ -219,7 +219,6 @@ namespace OHOS void NetworkAndCallView::OnStart() { - View::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; } diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/set_aod/src/SetAodDialView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/set_aod/src/SetAodDialView.cpp index 170c33229..ded52eb4b 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/set_aod/src/SetAodDialView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/set_aod/src/SetAodDialView.cpp @@ -173,16 +173,12 @@ namespace OHOS void SetAodDialView::OnStart() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetAodDialView::OnStart"); - View::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 index 723a0c30d..000000000 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/set_desktop/include/SetDesktopModel.h +++ /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 -#include -#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 index b098142bb..000000000 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/set_desktop/include/SetDesktopPresenter.h +++ /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, - 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 index 8de637987..000000000 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/set_desktop/include/SetDesktopView.h +++ /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 { -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 index fb6243278..000000000 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/set_desktop/src/SetDesktopModel.cpp +++ /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 index ab8f0bd55..000000000 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/set_desktop/src/SetDesktopPresenter.cpp +++ /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 index 69bc411b5..000000000 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/set_desktop/src/SetDesktopView.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: SetDesktopView.cpp - * Author: - * Create: 2021-11-23 - */ - -#include -#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(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(); -} -} diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/set_dial_style/include/SetDialStyleView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/set_dial_style/include/SetDialStyleView.h index 4b3476cd8..c736bff27 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/set_dial_style/include/SetDialStyleView.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/set_dial_style/include/SetDialStyleView.h @@ -26,6 +26,7 @@ namespace OHOS void OnClick(UIView &view); private: + UIViewGroup group; UILabelExt labelTitle_; UILabelExt labelCover_; diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/set_dial_style/src/SetDialStyleView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/set_dial_style/src/SetDialStyleView.cpp index d0fc99191..964c0d24c 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/set_dial_style/src/SetDialStyleView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/set_dial_style/src/SetDialStyleView.cpp @@ -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]); diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/set_time_format/include/SetTimeFormatView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/set_time_format/include/SetTimeFormatView.h index 7c6cf2887..15e38370c 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/set_time_format/include/SetTimeFormatView.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/set_time_format/include/SetTimeFormatView.h @@ -28,6 +28,7 @@ public: void OnClick(UIView &view); private: + UIViewGroup group; UILabelExt labelTitle_; UILabelExt labelFormat24H_; UIToggleButton btnFormat24H_; diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/set_time_format/src/SetTimeFormatView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/set_time_format/src/SetTimeFormatView.cpp index 16f094dd9..d3a16c0a6 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/set_time_format/src/SetTimeFormatView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/set_time_format/src/SetTimeFormatView.cpp @@ -17,20 +17,22 @@ 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) { diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/sleep/include/SleepControlView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/sleep/include/SleepControlView.h index 47d2efe61..b959ccc8b 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/sleep/include/SleepControlView.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/sleep/include/SleepControlView.h @@ -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}; diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/sleep/src/SleepControlView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/sleep/src/SleepControlView.cpp index c4f93a972..4b1591fe9 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/sleep/src/SleepControlView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/sleep/src/SleepControlView.cpp @@ -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!"); diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/sleepmode/src/SleepModeView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/sleepmode/src/SleepModeView.cpp index 29a9d0e13..a53b0aa90 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/sleepmode/src/SleepModeView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/sleepmode/src/SleepModeView.cpp @@ -33,12 +33,7 @@ namespace OHOS void SleepModeView::OnStart() { - View::OnStart(); - GetRootContainer()->SetTouchable(true); - GetRootContainer()->SetDraggable(true); - ScrollView_ = InitScreen(); - AddViewToRootContainer(ScrollView_); } diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/systemupdate/src/SystemUpdateView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/systemupdate/src/SystemUpdateView.cpp index e52614459..37748d767 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/systemupdate/src/SystemUpdateView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/systemupdate/src/SystemUpdateView.cpp @@ -941,8 +941,7 @@ namespace OHOS updatasider->SetVisible(false); } - - GetRootContainer()->Add(SystemUpdateScrollView); + AddViewToRootContainer(SystemUpdateScrollView); } void SystemUpdateView::NoNeedUpdateViewInit(void) diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/include/TraingNomalView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/include/TraingNomalView.h index 310f59241..e9118e7c2 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/include/TraingNomalView.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/include/TraingNomalView.h @@ -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; diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/include/TraingView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/include/TraingView.h index 61b9ca244..05f026013 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/include/TraingView.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/include/TraingView.h @@ -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; diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/src/TraingEnddataView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/src/TraingEnddataView.cpp index a3c27c791..65d60d462 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/src/TraingEnddataView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/src/TraingEnddataView.cpp @@ -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"); diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/src/TraingNomalView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/src/TraingNomalView.cpp index 3f8ca1ed5..9e6e615dd 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/src/TraingNomalView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/src/TraingNomalView.cpp @@ -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(TraingNomalPresenter::GetInstance())); buttonSet_->SetOnClickListener(static_cast(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(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; } } diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/src/TraingSetView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/src/TraingSetView.cpp index 0b6b4a162..51cbe2343 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/src/TraingSetView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/src/TraingSetView.cpp @@ -244,7 +244,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingSetView:: new container[%d] fail", thisview); return false; } - GetRootContainer()->Add(SetTagScrollView[thisview]); + AddViewToRootContainer(SetTagScrollView[thisview]); } return true; } @@ -260,7 +260,7 @@ namespace OHOS return false; } SetTagScrollView[thisview] = setcalories->SetCaluliViewInit(); - GetRootContainer()->Add(SetTagScrollView[thisview]); + AddViewToRootContainer(SetTagScrollView[thisview]); } WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetTagScrollView[%d] is not null", thisview); return true; @@ -277,7 +277,7 @@ namespace OHOS return false; } SetTagScrollView[thisview] = settime->SetTimeViewInit(); - GetRootContainer()->Add(SetTagScrollView[thisview]); + AddViewToRootContainer(SetTagScrollView[thisview]); } WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetTagScrollView[%d] is not null", thisview); return true; @@ -294,7 +294,7 @@ namespace OHOS return false; } SetTagScrollView[thisview] = setmile->SetMileViewInit(); - GetRootContainer()->Add(SetTagScrollView[thisview]); + AddViewToRootContainer(SetTagScrollView[thisview]); } WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetTagScrollView[%d] is not null", thisview); return true; @@ -311,7 +311,7 @@ namespace OHOS return false; } SetTagScrollView[thisview] = setstep->SetStepViewInit(); - GetRootContainer()->Add(SetTagScrollView[thisview]); + AddViewToRootContainer(SetTagScrollView[thisview]); } WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetTagScrollView[%d] is not null", thisview); return true; @@ -425,13 +425,12 @@ namespace OHOS } SetKeyActListener(); - // GetRootContainer()->Add(SetTagScrollView[SET_VIEW]); // SetCurrentViewId(SET_VIEW); // 设置当前页面ID if (group != nullptr) { SetTagScrollView[SET_VIEW] = group; - GetRootContainer()->Add(SetTagScrollView[SET_VIEW]); + AddViewToRootContainer(SetTagScrollView[SET_VIEW]); SetCurrentViewId(SET_VIEW); } } diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/src/TraingView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/src/TraingView.cpp index b79ec68bb..cc4b56c1e 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/src/TraingView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/src/TraingView.cpp @@ -133,8 +133,6 @@ bool TraingView::AddImageView() { return true; } void TraingView::InitView() { - - // 初始化按键 AddButton(); // 初始化标签 @@ -142,27 +140,31 @@ void TraingView::InitView() { // 初始化图片 AddImageView(); - AddViewToRootContainer(button1_); - AddViewToRootContainer(button2_); - AddViewToRootContainer(button3_); - AddViewToRootContainer(buttonmore_); + group->Add(button1_); + group->Add(button2_); + group->Add(button3_); + group->Add(buttonmore_); - AddViewToRootContainer(title_label); - AddViewToRootContainer(btn1_label); - AddViewToRootContainer(btn2_label); - AddViewToRootContainer(btn3_label); - AddViewToRootContainer(btnmore_label); + group->Add(title_label); + group->Add(btn1_label); + group->Add(btn2_label); + group->Add(btn3_label); + group->Add(btnmore_label); - AddViewToRootContainer(btn1_image); - AddViewToRootContainer(btn2_image); - AddViewToRootContainer(btn3_image); - AddViewToRootContainer(btnmore_image); + group->Add(btn1_image); + group->Add(btn2_image); + group->Add(btn3_image); + group->Add(btnmore_image); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel::InitView"); } void TraingView::DeInitView() { + if (group != nullptr) { + group->RemoveAll(); + delete group; + group = nullptr; + } if (buttonmore_ != nullptr) { delete buttonmore_; buttonmore_ = nullptr; @@ -216,41 +218,26 @@ void TraingView::DeInitView() { btnmore_image = nullptr; } } - -// 设置按键监听 -static void SetKeyActListener() { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetKeyActListener"); - // 增加按键监听 - RootView::OnKeyActListener *keyactListener = - (RootView::OnKeyActListener *)OHOS::TraingPresenter::GetInstance(); - RootView::GetInstance()->SetOnKeyActListener(keyactListener); -} void TraingView::OnStart() { -#if 0 - printf(" data--training1_Text: %s\n", data->training1_Text.c_str()); - printf(" data--training1_Image: %s\n", data->training1_Image.c_str()); - printf(" data--training2_Text: %s\n", data->training2_Text.c_str()); - printf(" data--training2_Image: %s\n", data->training2_Image.c_str()); - printf(" data--training3_Text: %s\n", data->training3_Text.c_str()); - printf(" data--training3_Image: %s\n", data->training3_Image.c_str()); -#endif - - - // 创建 draglistener 实例并设置为拖动监听器 - UIView::OnDragListener *draglistener = - static_cast(TraingPresenter::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); InitView(); - - - // 增加按键监听 - SetKeyActListener(); + RootView::GetInstance()->SetOnKeyActListener(presenter_); } diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/include/TraingGPSView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/include/TraingGPSView.h index e5befee67..bd194b462 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/include/TraingGPSView.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/include/TraingGPSView.h @@ -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; diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/include/TraingGPSbackView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/include/TraingGPSbackView.h index d7428f6d3..7fa8dd06b 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/include/TraingGPSbackView.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/include/TraingGPSbackView.h @@ -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; diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/include/TraingGPSlackView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/include/TraingGPSlackView.h index d5d6090a2..f222c7346 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/include/TraingGPSlackView.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/include/TraingGPSlackView.h @@ -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; diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/include/TraingGPSlostView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/include/TraingGPSlostView.h index 3eca40139..01d607e3b 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/include/TraingGPSlostView.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/include/TraingGPSlostView.h @@ -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; diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/include/TraingGPSnoteView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/include/TraingGPSnoteView.h index c24c9026c..71878781c 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/include/TraingGPSnoteView.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/include/TraingGPSnoteView.h @@ -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}; diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/include/TraingGPSsetView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/include/TraingGPSsetView.h index b1e5c5416..bb91eff7b 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/include/TraingGPSsetView.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/include/TraingGPSsetView.h @@ -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; diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/src/TraingGPSView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/src/TraingGPSView.cpp index e91d9f839..36601a130 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/src/TraingGPSView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/src/TraingGPSView.cpp @@ -85,17 +85,22 @@ void TraingGPSView::PreLoad(void) { } } void TraingGPSView::OnStart() { - - // 创建 draglistener 实例并设置为拖动监听器 - UIView::OnDragListener *draglistener = - static_cast(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(); } diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/src/TraingGPSbackView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/src/TraingGPSbackView.cpp index 98c8101fb..797c9fc0f 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/src/TraingGPSbackView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/src/TraingGPSbackView.cpp @@ -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 @@ -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(TraingGPSbackPresenter::GetInstance())); button1_->SetImageSrc(BUTTONOK_IMAGE, BUTTONOK_IMAGE); - AddViewToRootContainer(button1_); - } - /* DeInit:删除组件*/ - void TraingGPSbackView::DeInit() - { - // UIView *view = static_cast(container_)->GetChildrenHead(); - // while (view != nullptr) - // { - // UIView *tempView = view; - // view = view->GetNextSibling(); - // if (tempView->GetParent()) - // { - // static_cast(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(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(); } - } diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/src/TraingGPSlackView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/src/TraingGPSlackView.cpp index 3f4ef1bb7..2a92eabaa 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/src/TraingGPSlackView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/src/TraingGPSlackView.cpp @@ -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 @@ -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(container_)->GetChildrenHead(); - // while (view != nullptr) - // { - // UIView *tempView = view; - // view = view->GetNextSibling(); - // if (tempView->GetParent()) - // { - // static_cast(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(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(); - } - } diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/src/TraingGPSlostView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/src/TraingGPSlostView.cpp index 6ad8848ad..e98f46ba3 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/src/TraingGPSlostView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/src/TraingGPSlostView.cpp @@ -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 @@ -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(container_)->GetChildrenHead(); - // while (view != nullptr) - // { - // UIView *tempView = view; - // view = view->GetNextSibling(); - // if (tempView->GetParent()) - // { - // static_cast(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(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(); } diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/src/TraingGPSnoteView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/src/TraingGPSnoteView.cpp index 8583e0922..4d7c9db2e 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/src/TraingGPSnoteView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/src/TraingGPSnoteView.cpp @@ -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 @@ -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(TraingGPSnotePresenter::GetInstance()); - if (draglistener == nullptr) - { - return; - } - GetRootContainer()->SetOnDragListener(draglistener); - - GetRootContainer()->SetTouchable(true); - GetRootContainer()->SetDraggable(true); - PreLoad(); - } } diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/src/TraingGPSsetView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/src/TraingGPSsetView.cpp index ead821ee5..86d501b39 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/src/TraingGPSsetView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_GPS/src/TraingGPSsetView.cpp @@ -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 @@ -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(container_)->GetChildrenHead(); - // while (view != nullptr) - // { - // UIView *tempView = view; - // view = view->GetNextSibling(); - // if (tempView->GetParent()) - // { - // static_cast(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(TraingGPSsetPresenter::GetInstance()); - if (draglistener == nullptr) - { - return; - } - GetRootContainer()->SetOnDragListener(draglistener); - - GetRootContainer()->SetTouchable(true); - GetRootContainer()->SetDraggable(true); - PreLoad(); - } - } diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_card/src/TraingCardView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_card/src/TraingCardView.cpp index 30a9397ad..590773720 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_card/src/TraingCardView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_card/src/TraingCardView.cpp @@ -852,7 +852,7 @@ void TraingCardView::ShowEndView() { back->SetImageSrc(YES_IMAGE, YES_IMAGE); endView->Add(exit); endView->Add(back); - GetRootContainer()->Add(endView); + AddViewToRootContainer(endView); endView->SetDraggable(false); endView->SetTouchable(true); endView->SetVisible(false); // 界面隐藏 @@ -897,7 +897,7 @@ void TraingCardView::ShowGetTagView() { getView->Add(buttonok_); InitImageAnimator(); - GetRootContainer()->Add(getView); + AddViewToRootContainer(getView); getView->SetDraggable(false); getView->SetTouchable(true); getView->SetVisible(false); // 界面隐藏 @@ -943,7 +943,7 @@ void TraingCardView::ShowHeartView() { TraingCardPresenter::GetInstance())); heartView->Add(buttonnote_); - GetRootContainer()->Add(heartView); + AddViewToRootContainer(heartView); heartView->SetDraggable(false); heartView->SetTouchable(true); heartView->SetVisible(false); // 界面隐藏 -- 2.17.1