From b597a387d1f5cf68dc28eedd81814d5913ca48f8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E8=A2=81=E6=B8=85=E6=A2=A6?= <3449750381@qq.com> Date: Sat, 7 Sep 2024 09:52:51 +0000 Subject: [PATCH] Merge #908 into sdk602patch0626 from refs/changes/908/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from 袁清梦 * refs/changes/908/head: (15 commits squashed) - 增加多国语言自动翻译脚本:待完善 - 修复心率测量发生的死机 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - #440运动-健身类-少了循环训练 - #439运动-健身类 排序问题 室外走路,跑步,骑行不在顶部,需要把常用的放在顶部 - #445 运动-休闲运动-少了对战游戏 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - #447 运动结束界面添加提示语 - #441运动-健身类有遮挡 - #442运动-所有类底部有遮挡 - #443运动-类别界面-上滑会有短暂回弹 - #444运动类界面-右滑返回上一级界面有界面晃动 - #207运动界面进行触摸进出操作,界面会抖动,卡顿 - #438运动-健身类上下滑动,健身运动会跟着跳动 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 Signed-off-by: Caisking <3449750381@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/908 --- .../nativeui/traing/Training_UiConfig.h | 4 +- .../src/TraingAquaticView.cpp | 103 +++++++++------- .../training_list_ball/src/TraingBallView.cpp | 109 +++++++++-------- .../src/TraingDanceView.cpp | 111 +++++++++-------- .../src/TraingFitnessView.cpp | 111 +++++++++-------- .../training_list_ice/src/TraingIceView.cpp | 111 +++++++++-------- .../src/TraingLimitView.cpp | 111 +++++++++-------- .../training_list_more/src/TraingMoreView.cpp | 39 +++--- .../src/TraingOtherView.cpp | 110 +++++++++-------- .../training_list_rest/src/TraingRestView.cpp | 113 ++++++++++-------- 10 files changed, 496 insertions(+), 426 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/Training_UiConfig.h b/code/sdk/application/wearable/fd230app/nativeui/traing/Training_UiConfig.h index 228b8dac6..181207c2b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/Training_UiConfig.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/Training_UiConfig.h @@ -9,7 +9,6 @@ namespace OHOS { - // Paths for different icons in the Training folder #define ICON36 "/user/res/Training/icon_36x36" #define ICON60 "/user/res/Training/icon_60x60" @@ -17,7 +16,8 @@ namespace OHOS #define ICON54 "user/res/Training/icon_54x79" #define MODULES "/user/res/Training/modules" #define TRAINING_GIF "/user/res/Training/training_GIF" - + static constexpr int16_t MAX_SCROLL_DIS = 1000; + static constexpr int16 ROTATE_FACTOR_2 = 2; // Icons in the icon_36x36 folder static constexpr const char *BALL_IMAGE = ICON36 "/Ball.bin"; static constexpr const char *DANCE_IMAGE = ICON36 "/Dance.bin"; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_aquatic/src/TraingAquaticView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_aquatic/src/TraingAquaticView.cpp index db9f09055..bc20daa32 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_aquatic/src/TraingAquaticView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_aquatic/src/TraingAquaticView.cpp @@ -55,47 +55,53 @@ namespace OHOS { if (scrollView == nullptr) { - scrollView = new UIScrollView(); + scrollView = new UIScrollView(); + if (scrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "scrollView new fail!"); + return; + } + scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + scrollView->SetScrollBlankSize(50); + // scrollView->SetReboundSize(35); + scrollView->SetHorizontalScrollState(false); + scrollView->RequestFocus(); + scrollView->SetRotateFactor(1.0); + scrollView->SetMaxScrollDistance(1000); + scrollView->SetDragACCLevel(5); + scrollView->SetSwipeACCLevel(800); /*设置手指抬起屏幕后的补偿距离。*/ + scrollView->SetTouchable(true); + scrollView->SetDraggable(true); + container_->Add(scrollView); } - scrollView->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - // scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - // scrollView->SetScrollBlankSize(52); - scrollView->SetReboundSize(50); - scrollView->SetTouchable(true); - scrollView->SetDraggable(true); - scrollView->SetDirection(1); - draglistener = static_cast(TraingAquaticPresenter::GetInstance()); - scrollView->SetOnDragListener(draglistener); - /* -------------------------------------------------------------------------- */ - // 初始化Lable - InitLabelExt(title, 135, 52, 200, 60, "label1", STR_WATER_LIST, DEFAULT_VECTOR_FONT_FILENAME, 30); - title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full); - scrollView->Add(title); + // 初始化Lable 暂时不添加 + if (title == nullptr) + { + InitLabelExt(title, 135, 52, 200, 60, "label1", STR_WATER_LIST, DEFAULT_VECTOR_FONT_FILENAME, 30); + title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full); + scrollView->Add(title); + } // UIList 的适配器 - p_TraingAquaticListAdapter = new TraingAquaticAdapter(); - p_TraingAquaticListAdapter->SetItemClickListener(presenter_); + if (p_TraingAquaticListAdapter == nullptr) + { + p_TraingAquaticListAdapter = new TraingAquaticAdapter(); + p_TraingAquaticListAdapter->SetItemClickListener(presenter_); + } + // 初始化列表 if (TraingAquaticList == nullptr) { TraingAquaticList = new UIList(); + TraingAquaticList->SetPosition(43, 120, 466, 466); + TraingAquaticList->SetThrowDrag(true); + TraingAquaticList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); + TraingAquaticList->SetMaxScrollDistance(1000); + TraingAquaticList->SetSwipeACCLevel(800); + TraingAquaticList->SetDragACCLevel(5); + // 增加表冠控制 + TraingAquaticList->SetRotateFactor(2); + TraingAquaticList->RequestFocus(); } - TraingAquaticList->SetPosition(Aquatic_LIST_POSITION_X, Aquatic_LIST_POSITION_Y); - TraingAquaticList->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - TraingAquaticList->SetScrollBlankSize(Aquatic_SCROLLBLANKSIZE); - TraingAquaticList->SetSelectPosition(HORIZONTAL_RESOLUTION / SNUM_2); // middle position - TraingAquaticList->SetReboundSize(50); - TraingAquaticList->SetDraggable(true); - TraingAquaticList->SetThrowDrag(true); - TraingAquaticList->EnableAutoAlign(true); - TraingAquaticList->SetElastic(true); // 设置回弹效果 - TraingAquaticList->SetMaxScrollDistance(MAX_SCR_DIS); - TraingAquaticList->SetYScrollBarVisible(true); // 设置滑动滚动条 - - // 增加表冠控制 - TraingAquaticList->SetRotateFactor(2); - TraingAquaticList->RequestFocus(); - - SetKeyActListener(); } UIList *TraingAquaticView::GetList() { @@ -132,19 +138,26 @@ namespace OHOS { View::OnStart(); BaseView::RootView(Color::Black().full); + SetContainerView(new UIViewGroup()); + container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + container_->SetOnDragListener(presenter_); + container_->SetTouchable(true); + container_->SetDraggable(true); PreLoad(); + RootView::GetInstance()->SetOnKeyActListener(presenter_); } /// @brief 创建页面的视图。 void TraingAquaticView::OnSetUpView() { View::OnSetUpView(); - scrollView->Add(title); - scrollView->Add(TraingAquaticList); - scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - RootView::GetInstance()->Add(scrollView); - TraingAquaticList->SetAdapter(p_TraingAquaticListAdapter); - // TraingAquaticList->RefreshList(); // 刷新列表 + if (TraingAquaticList != nullptr && p_TraingAquaticListAdapter != nullptr) + { + scrollView->Add(TraingAquaticList); + scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); + RootView::GetInstance()->Add(scrollView); + TraingAquaticList->SetAdapter(p_TraingAquaticListAdapter); + } Draw(); } @@ -159,12 +172,14 @@ namespace OHOS void TraingAquaticView::OnStop() { View::OnStop(); - - + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } RootView::GetInstance()->ClearOnKeyActListener(); - //FocusManager::GetInstance()->ClearFocus(); RootView::GetInstance()->RemoveAll(); - // RootView::GetInstance()->ClearFocus(); return; } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_ball/src/TraingBallView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_ball/src/TraingBallView.cpp index 9d0ac0861..af442310e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_ball/src/TraingBallView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_ball/src/TraingBallView.cpp @@ -56,55 +56,53 @@ namespace OHOS if (scrollView == nullptr) { scrollView = new UIScrollView(); + if (scrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "scrollView new fail!"); + return; + } + scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + scrollView->SetScrollBlankSize(50); + // scrollView->SetReboundSize(35); + scrollView->SetHorizontalScrollState(false); + scrollView->RequestFocus(); + scrollView->SetRotateFactor(1.0); + scrollView->SetMaxScrollDistance(1000); + scrollView->SetDragACCLevel(5); + scrollView->SetSwipeACCLevel(800); /*设置手指抬起屏幕后的补偿距离。*/ + scrollView->SetTouchable(true); + scrollView->SetDraggable(true); + container_->Add(scrollView); + } - scrollView->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - // scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - // scrollView->SetScrollBlankSize(52); - scrollView->SetReboundSize(50); - scrollView->SetTouchable(true); - scrollView->SetDraggable(true); - scrollView->SetDirection(1); - draglistener = static_cast(TraingBallPresenter::GetInstance()); - scrollView->SetOnDragListener(draglistener); - /* -------------------------------------------------------------------------- */ - // 初始化Lable - InitLabelExt(title, 135, 52, 200, 60, "label1", STR_BALL_LIST, DEFAULT_VECTOR_FONT_FILENAME, 30); - title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full); - scrollView->Add(title); + // 初始化Lable 暂时不添加 + if (title == nullptr) + { + InitLabelExt(title, 135, 52, 200, 60, "label1", STR_BALL_LIST_TITLE, DEFAULT_VECTOR_FONT_FILENAME, 30); + title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full); + scrollView->Add(title); + } // UIList 的适配器 - p_TraingBallListAdapter = new TraingBallAdapter(); - p_TraingBallListAdapter->SetItemClickListener(presenter_); + if (p_TraingBallListAdapter == nullptr) + { + p_TraingBallListAdapter = new TraingBallAdapter(); + p_TraingBallListAdapter->SetItemClickListener(presenter_); + } + // 初始化列表 if (TraingBallList == nullptr) { TraingBallList = new UIList(); + TraingBallList->SetPosition(43, 120, 466, 466); + TraingBallList->SetThrowDrag(true); + TraingBallList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); + TraingBallList->SetMaxScrollDistance(1000); + TraingBallList->SetSwipeACCLevel(800); + TraingBallList->SetDragACCLevel(5); + // 增加表冠控制 + TraingBallList->SetRotateFactor(2); + TraingBallList->RequestFocus(); } -#if 0 - TraingBallList->SetPosition(Ball_LIST_POSITION_X, Ball_LIST_POSITION_Y); - TraingBallList->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - TraingBallList->SetScrollBlankSize(Ball_SCROLLBLANKSIZE); - TraingBallList->SetSelectPosition(HORIZONTAL_RESOLUTION / SNUM_2); // middle position - TraingBallList->SetReboundSize(50); - TraingBallList->SetDraggable(true); - TraingBallList->SetThrowDrag(true); - TraingBallList->EnableAutoAlign(true); - TraingBallList->SetElastic(true); // 设置回弹效果 - TraingBallList->SetMaxScrollDistance(MAX_SCR_DIS); - TraingBallList->SetYScrollBarVisible(true); // 设置滑动滚动条 -#endif - - TraingBallList->SetPosition(Ball_LIST_POSITION_X, Ball_LIST_POSITION_Y, 466, 466); - TraingBallList->SetThrowDrag(true); - TraingBallList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - TraingBallList->SetMaxScrollDistance(1000); - TraingBallList->SetSwipeACCLevel(800); - TraingBallList->SetDragACCLevel(5); - - // 增加表冠控制 - TraingBallList->SetRotateFactor(2); - TraingBallList->RequestFocus(); - - SetKeyActListener(); } UIList *TraingBallView::GetList() { @@ -141,19 +139,26 @@ namespace OHOS { View::OnStart(); BaseView::RootView(Color::Black().full); + SetContainerView(new UIViewGroup()); + container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + container_->SetOnDragListener(presenter_); + container_->SetTouchable(true); + container_->SetDraggable(true); PreLoad(); + RootView::GetInstance()->SetOnKeyActListener(presenter_); } /// @brief 创建页面的视图。 void TraingBallView::OnSetUpView() { View::OnSetUpView(); - scrollView->Add(title); - scrollView->Add(TraingBallList); - scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - RootView::GetInstance()->Add(scrollView); - TraingBallList->SetAdapter(p_TraingBallListAdapter); - // TraingBallList->RefreshList(); // 刷新列表 + if (TraingBallList != nullptr && p_TraingBallListAdapter != nullptr) + { + scrollView->Add(TraingBallList); + scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); + RootView::GetInstance()->Add(scrollView); + TraingBallList->SetAdapter(p_TraingBallListAdapter); + } Draw(); } @@ -169,10 +174,14 @@ namespace OHOS { View::OnStop(); + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } RootView::GetInstance()->ClearOnKeyActListener(); - // FocusManager::GetInstance()->ClearFocus(); RootView::GetInstance()->RemoveAll(); - // RootView::GetInstance()->ClearFocus(); return; } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_dance/src/TraingDanceView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_dance/src/TraingDanceView.cpp index 3e44f6919..f43871a87 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_dance/src/TraingDanceView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_dance/src/TraingDanceView.cpp @@ -56,55 +56,55 @@ namespace OHOS if (scrollView == nullptr) { scrollView = new UIScrollView(); + if (scrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "scrollView new fail!"); + return; + } + scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + scrollView->SetScrollBlankSize(50); + // scrollView->SetReboundSize(35); + scrollView->SetHorizontalScrollState(false); + scrollView->RequestFocus(); + scrollView->SetRotateFactor(1.0); + scrollView->SetMaxScrollDistance(1000); + scrollView->SetDragACCLevel(5); + scrollView->SetSwipeACCLevel(800); /*设置手指抬起屏幕后的补偿距离。*/ + scrollView->SetTouchable(true); + scrollView->SetDraggable(true); + container_->Add(scrollView); } - scrollView->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - // scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - // scrollView->SetScrollBlankSize(52); - scrollView->SetReboundSize(50); - scrollView->SetTouchable(true); - scrollView->SetDraggable(true); - scrollView->SetDirection(1); - draglistener = static_cast(TraingDancePresenter::GetInstance()); - scrollView->SetOnDragListener(draglistener); - /* -------------------------------------------------------------------------- */ - // 初始化Lable - InitLabelExt(title, 135, 52, 200, 60, "label1", STR_DANCING_TITLE, DEFAULT_VECTOR_FONT_FILENAME, 30); - title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full); - scrollView->Add(title); + // 初始化Lable 暂时不添加 + if (title == nullptr) + { + InitLabelExt(title, 135, 52, 200, 60, "label1", STR_DANCING_TITLE, DEFAULT_VECTOR_FONT_FILENAME, 30); + title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full); + scrollView->Add(title); + + title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full); + scrollView->Add(title); + } // UIList 的适配器 - p_TraingDanceListAdapter = new TraingDanceAdapter(); - p_TraingDanceListAdapter->SetItemClickListener(presenter_); + if (p_TraingDanceListAdapter == nullptr) + { + p_TraingDanceListAdapter = new TraingDanceAdapter(); + p_TraingDanceListAdapter->SetItemClickListener(presenter_); + } + // 初始化列表 if (TraingDanceList == nullptr) { TraingDanceList = new UIList(); + TraingDanceList->SetPosition(43, 120, 466, 466); + TraingDanceList->SetThrowDrag(true); + TraingDanceList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); + TraingDanceList->SetMaxScrollDistance(1000); + TraingDanceList->SetSwipeACCLevel(800); + TraingDanceList->SetDragACCLevel(5); + // 增加表冠控制 + TraingDanceList->SetRotateFactor(2); + TraingDanceList->RequestFocus(); } -#if 0 - TraingDanceList->SetPosition(Dance_LIST_POSITION_X, Dance_LIST_POSITION_Y); - TraingDanceList->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - TraingDanceList->SetScrollBlankSize(Dance_SCROLLBLANKSIZE); - TraingDanceList->SetSelectPosition(HORIZONTAL_RESOLUTION / SNUM_2); // middle position - TraingDanceList->SetReboundSize(50); - TraingDanceList->SetDraggable(true); - TraingDanceList->SetThrowDrag(true); - TraingDanceList->EnableAutoAlign(true); - TraingDanceList->SetElastic(true); // 设置回弹效果 - TraingDanceList->SetMaxScrollDistance(MAX_SCR_DIS); - TraingDanceList->SetYScrollBarVisible(true); // 设置滑动滚动条 -#endif - - TraingDanceList->SetPosition(Dance_LIST_POSITION_X, Dance_LIST_POSITION_Y, 466, 466); - TraingDanceList->SetThrowDrag(true); - TraingDanceList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - TraingDanceList->SetMaxScrollDistance(1000); - TraingDanceList->SetSwipeACCLevel(800); - TraingDanceList->SetDragACCLevel(5); - - // 增加表冠控制 - TraingDanceList->SetRotateFactor(2); - TraingDanceList->RequestFocus(); - - SetKeyActListener(); } UIList *TraingDanceView::GetList() { @@ -141,19 +141,26 @@ namespace OHOS { View::OnStart(); BaseView::RootView(Color::Black().full); + SetContainerView(new UIViewGroup()); + container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + container_->SetOnDragListener(presenter_); + container_->SetTouchable(true); + container_->SetDraggable(true); PreLoad(); + RootView::GetInstance()->SetOnKeyActListener(presenter_); } /// @brief 创建页面的视图。 void TraingDanceView::OnSetUpView() { View::OnSetUpView(); - // scrollView->Add(title); - scrollView->Add(TraingDanceList); - scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - RootView::GetInstance()->Add(scrollView); - TraingDanceList->SetAdapter(p_TraingDanceListAdapter); - // TraingDanceList->RefreshList(); // 刷新列表 + if (TraingDanceList != nullptr && p_TraingDanceListAdapter != nullptr) + { + scrollView->Add(TraingDanceList); + scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); + RootView::GetInstance()->Add(scrollView); + TraingDanceList->SetAdapter(p_TraingDanceListAdapter); + } Draw(); } @@ -169,10 +176,14 @@ namespace OHOS { View::OnStop(); + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } RootView::GetInstance()->ClearOnKeyActListener(); - // FocusManager::GetInstance()->ClearFocus(); RootView::GetInstance()->RemoveAll(); - // RootView::GetInstance()->ClearFocus(); return; } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_fitness/src/TraingFitnessView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_fitness/src/TraingFitnessView.cpp index 0f9e83170..c05f827a9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_fitness/src/TraingFitnessView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_fitness/src/TraingFitnessView.cpp @@ -54,56 +54,53 @@ namespace OHOS { if (scrollView == nullptr) { - scrollView = new UIScrollView(); + scrollView = new UIScrollView(); + if (scrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "scrollView new fail!"); + return; + } + scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + scrollView->SetScrollBlankSize(50); + // scrollView->SetReboundSize(35); + scrollView->SetHorizontalScrollState(false); + scrollView->RequestFocus(); + scrollView->SetRotateFactor(1.0); + scrollView->SetMaxScrollDistance(1000); + scrollView->SetDragACCLevel(5); + scrollView->SetSwipeACCLevel(800); /*设置手指抬起屏幕后的补偿距离。*/ + scrollView->SetTouchable(true); + scrollView->SetDraggable(true); + container_->Add(scrollView); } - scrollView->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - // scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - // scrollView->SetScrollBlankSize(52); - scrollView->SetReboundSize(50); - scrollView->SetTouchable(true); - scrollView->SetDraggable(true); - scrollView->SetDirection(1); - draglistener = static_cast(TraingFitnessPresenter::GetInstance()); - scrollView->SetOnDragListener(draglistener); - /* -------------------------------------------------------------------------- */ - // 初始化Lable - InitLabelExt(title, 135, 52, 200, 60, "label1", STR_EXERCISE_TITLE, DEFAULT_VECTOR_FONT_FILENAME, 30); - title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full); - scrollView->Add(title); + // 初始化Lable 暂时不添加 + if (title == nullptr) + { + InitLabelExt(title, 135, 52, 200, 60, "label1", STR_EXERCISE_TITLE, DEFAULT_VECTOR_FONT_FILENAME, 30); + title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full); + scrollView->Add(title); + } // UIList 的适配器 - p_TraingFitnessListAdapter = new TraingFitnessAdapter(); - p_TraingFitnessListAdapter->SetItemClickListener(presenter_); + if (p_TraingFitnessListAdapter == nullptr) + { + p_TraingFitnessListAdapter = new TraingFitnessAdapter(); + p_TraingFitnessListAdapter->SetItemClickListener(presenter_); + } + // 初始化列表 if (TraingFitnessList == nullptr) { TraingFitnessList = new UIList(); + TraingFitnessList->SetPosition(43, 120, 466, 466); + TraingFitnessList->SetThrowDrag(true); + TraingFitnessList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); + TraingFitnessList->SetMaxScrollDistance(1000); + TraingFitnessList->SetSwipeACCLevel(800); + TraingFitnessList->SetDragACCLevel(5); + // 增加表冠控制 + TraingFitnessList->SetRotateFactor(2); + TraingFitnessList->RequestFocus(); } -#if 0 - TraingFitnessList->SetPosition(Fitness_LIST_POSITION_X, Fitness_LIST_POSITION_Y); - TraingFitnessList->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - TraingFitnessList->SetScrollBlankSize(Fitness_SCROLLBLANKSIZE); - TraingFitnessList->SetSelectPosition(HORIZONTAL_RESOLUTION / SNUM_2); // middle position - TraingFitnessList->SetReboundSize(50); - TraingFitnessList->SetDraggable(true); - TraingFitnessList->SetThrowDrag(true); - TraingFitnessList->EnableAutoAlign(true); - TraingFitnessList->SetElastic(true); // 设置回弹效果 - TraingFitnessList->SetMaxScrollDistance(MAX_SCR_DIS); - TraingFitnessList->SetYScrollBarVisible(true); // 设置滑动滚动条 -#endif - - TraingFitnessList->SetPosition(Fitness_LIST_POSITION_X, Fitness_LIST_POSITION_Y, 466, 466); - TraingFitnessList->SetThrowDrag(true); - TraingFitnessList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - TraingFitnessList->SetMaxScrollDistance(1000); - TraingFitnessList->SetSwipeACCLevel(800); - TraingFitnessList->SetDragACCLevel(5); - - // 增加表冠控制 - TraingFitnessList->SetRotateFactor(2); - TraingFitnessList->RequestFocus(); - - SetKeyActListener(); } UIList *TraingFitnessView::GetList() { @@ -145,19 +142,26 @@ namespace OHOS { View::OnStart(); BaseView::RootView(Color::Black().full); + SetContainerView(new UIViewGroup()); + container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + container_->SetOnDragListener(presenter_); + container_->SetTouchable(true); + container_->SetDraggable(true); PreLoad(); + RootView::GetInstance()->SetOnKeyActListener(presenter_); } /// @brief 创建页面的视图。 void TraingFitnessView::OnSetUpView() { View::OnSetUpView(); - // scrollView->Add(title); - scrollView->Add(TraingFitnessList); - scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - RootView::GetInstance()->Add(scrollView); - TraingFitnessList->SetAdapter(p_TraingFitnessListAdapter); - // TraingFitnessList->RefreshList(); // 刷新列表 + if (TraingFitnessList != nullptr && p_TraingFitnessListAdapter != nullptr) + { + scrollView->Add(TraingFitnessList); + scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); + RootView::GetInstance()->Add(scrollView); + TraingFitnessList->SetAdapter(p_TraingFitnessListAdapter); + } Draw(); } @@ -172,11 +176,14 @@ namespace OHOS void TraingFitnessView::OnStop() { View::OnStop(); - + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } RootView::GetInstance()->ClearOnKeyActListener(); - // FocusManager::GetInstance()->ClearFocus(); RootView::GetInstance()->RemoveAll(); - // RootView::GetInstance()->ClearFocus(); return; } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_ice/src/TraingIceView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_ice/src/TraingIceView.cpp index a2fb057ec..15cdc48fe 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_ice/src/TraingIceView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_ice/src/TraingIceView.cpp @@ -63,56 +63,53 @@ namespace OHOS { if (scrollView == nullptr) { - scrollView = new UIScrollView(); + scrollView = new UIScrollView(); + if (scrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "scrollView new fail!"); + return; + } + scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + scrollView->SetScrollBlankSize(50); + // scrollView->SetReboundSize(35); + scrollView->SetHorizontalScrollState(false); + scrollView->RequestFocus(); + scrollView->SetRotateFactor(1.0); + scrollView->SetMaxScrollDistance(1000); + scrollView->SetDragACCLevel(5); + scrollView->SetSwipeACCLevel(800); /*设置手指抬起屏幕后的补偿距离。*/ + scrollView->SetTouchable(true); + scrollView->SetDraggable(true); + container_->Add(scrollView); } - scrollView->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - // scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - // scrollView->SetScrollBlankSize(52); - scrollView->SetReboundSize(50); - scrollView->SetTouchable(true); - scrollView->SetDraggable(true); - scrollView->SetDirection(1); - draglistener = static_cast(TraingIcePresenter::GetInstance()); - scrollView->SetOnDragListener(draglistener); - /* -------------------------------------------------------------------------- */ - // 初始化Lable - InitLabelExt(title, 135, 52, 200, 60, "label1", STR_ICE_LIST, DEFAULT_VECTOR_FONT_FILENAME, 30); - title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full); - scrollView->Add(title); + // 初始化Lable 暂时不添加 + if (title == nullptr) + { + InitLabelExt(title, 135, 52, 200, 60, "label1", STR_ICE_LIST, DEFAULT_VECTOR_FONT_FILENAME, 30); + title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full); + scrollView->Add(title); + } // UIList 的适配器 - p_TraingIceListAdapter = new TraingIceAdapter(); - p_TraingIceListAdapter->SetItemClickListener(presenter_); + if (p_TraingIceListAdapter == nullptr) + { + p_TraingIceListAdapter = new TraingIceAdapter(); + p_TraingIceListAdapter->SetItemClickListener(presenter_); + } + // 初始化列表 if (TraingIceList == nullptr) { TraingIceList = new UIList(); + TraingIceList->SetPosition(43, 120, 466, 466); + TraingIceList->SetThrowDrag(true); + TraingIceList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); + TraingIceList->SetMaxScrollDistance(1000); + TraingIceList->SetSwipeACCLevel(800); + TraingIceList->SetDragACCLevel(5); + // 增加表冠控制 + TraingIceList->SetRotateFactor(2); + TraingIceList->RequestFocus(); } -#if 0 - TraingIceList->SetPosition(Ice_LIST_POSITION_X, Ice_LIST_POSITION_Y); - TraingIceList->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - TraingIceList->SetScrollBlankSize(Ice_SCROLLBLANKSIZE); - TraingIceList->SetSelectPosition(HORIZONTAL_RESOLUTION / SNUM_2); // middle position - TraingIceList->SetDraggable(true); - TraingIceList->SetThrowDrag(true); - TraingIceList->EnableAutoAlign(true); - TraingIceList->SetReboundSize(50); - TraingIceList->SetElastic(true); // 设置回弹效果 - TraingIceList->SetMaxScrollDistance(MAX_SCR_DIS); - TraingIceList->SetYScrollBarVisible(true); // 设置滑动滚动条 -#endif - - TraingIceList->SetPosition(Ice_LIST_POSITION_X, Ice_LIST_POSITION_Y, 466, 466); - TraingIceList->SetThrowDrag(true); - TraingIceList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - TraingIceList->SetMaxScrollDistance(1000); - TraingIceList->SetSwipeACCLevel(800); - TraingIceList->SetDragACCLevel(5); - - // 增加表冠控制 - scrollView->SetRotateFactor(2); - scrollView->RequestFocus(); - - SetKeyActListener(); } UIList *TraingIceView::GetList() { @@ -149,19 +146,26 @@ namespace OHOS { View::OnStart(); BaseView::RootView(Color::Black().full); + SetContainerView(new UIViewGroup()); + container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + container_->SetOnDragListener(presenter_); + container_->SetTouchable(true); + container_->SetDraggable(true); PreLoad(); + RootView::GetInstance()->SetOnKeyActListener(presenter_); } /// @brief 创建页面的视图。 void TraingIceView::OnSetUpView() { View::OnSetUpView(); - // scrollView->Add(title); - scrollView->Add(TraingIceList); - scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - RootView::GetInstance()->Add(scrollView); - TraingIceList->SetAdapter(p_TraingIceListAdapter); - // TraingIceList->RefreshList(); // 刷新列表 + if (TraingIceList != nullptr && p_TraingIceListAdapter != nullptr) + { + scrollView->Add(TraingIceList); + scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); + RootView::GetInstance()->Add(scrollView); + TraingIceList->SetAdapter(p_TraingIceListAdapter); + } Draw(); } @@ -176,11 +180,14 @@ namespace OHOS void TraingIceView::OnStop() { View::OnStop(); - + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } RootView::GetInstance()->ClearOnKeyActListener(); - // FocusManager::GetInstance()->ClearFocus(); RootView::GetInstance()->RemoveAll(); - // RootView::GetInstance()->ClearFocus(); return; } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_limit/src/TraingLimitView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_limit/src/TraingLimitView.cpp index 415ee6479..93855a843 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_limit/src/TraingLimitView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_limit/src/TraingLimitView.cpp @@ -56,56 +56,53 @@ namespace OHOS { if (scrollView == nullptr) { - scrollView = new UIScrollView(); + scrollView = new UIScrollView(); + if (scrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "scrollView new fail!"); + return; + } + scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + scrollView->SetScrollBlankSize(50); + // scrollView->SetReboundSize(35); + scrollView->SetHorizontalScrollState(false); + scrollView->RequestFocus(); + scrollView->SetRotateFactor(1.0); + scrollView->SetMaxScrollDistance(1000); + scrollView->SetDragACCLevel(5); + scrollView->SetSwipeACCLevel(800); /*设置手指抬起屏幕后的补偿距离。*/ + scrollView->SetTouchable(true); + scrollView->SetDraggable(true); + container_->Add(scrollView); } - scrollView->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - // scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - // scrollView->SetScrollBlankSize(52); - scrollView->SetReboundSize(50); - scrollView->SetTouchable(true); - scrollView->SetDraggable(true); - scrollView->SetDirection(1); - draglistener = static_cast(TraingLimitPresenter::GetInstance()); - scrollView->SetOnDragListener(draglistener); - /* -------------------------------------------------------------------------- */ - // 初始化Lable - InitLabelExt(title, 135, 52, 200, 60, "label1", STR_EXTREME_LIST, DEFAULT_VECTOR_FONT_FILENAME, 30); - title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full); - scrollView->Add(title); + // 初始化Lable 暂时不添加 + if (title == nullptr) + { + InitLabelExt(title, 135, 52, 200, 60, "label1", STR_EXTREME_LIST, DEFAULT_VECTOR_FONT_FILENAME, 30); + title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full); + scrollView->Add(title); + } // UIList 的适配器 - p_TraingLimitListAdapter = new TraingLimitAdapter(); - p_TraingLimitListAdapter->SetItemClickListener(presenter_); + if (p_TraingLimitListAdapter == nullptr) + { + p_TraingLimitListAdapter = new TraingLimitAdapter(); + p_TraingLimitListAdapter->SetItemClickListener(presenter_); + } + // 初始化列表 if (TraingLimitList == nullptr) { TraingLimitList = new UIList(); + TraingLimitList->SetPosition(43, 120, 466, 466); + TraingLimitList->SetThrowDrag(true); + TraingLimitList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); + TraingLimitList->SetMaxScrollDistance(1000); + TraingLimitList->SetSwipeACCLevel(800); + TraingLimitList->SetDragACCLevel(5); + // 增加表冠控制 + TraingLimitList->SetRotateFactor(2); + TraingLimitList->RequestFocus(); } -#if 0 - TraingLimitList->SetPosition(Limit_LIST_POSITION_X, Limit_LIST_POSITION_Y); - TraingLimitList->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - TraingLimitList->SetScrollBlankSize(Limit_SCROLLBLANKSIZE); - TraingLimitList->SetSelectPosition(HORIZONTAL_RESOLUTION / SNUM_2); // middle position - TraingLimitList->SetReboundSize(50); - TraingLimitList->SetDraggable(true); - TraingLimitList->SetThrowDrag(true); - TraingLimitList->EnableAutoAlign(true); - TraingLimitList->SetElastic(true); // 设置回弹效果 - TraingLimitList->SetMaxScrollDistance(MAX_SCR_DIS); - TraingLimitList->SetYScrollBarVisible(true); // 设置滑动滚动条 -#endif - - TraingLimitList->SetPosition(Limit_LIST_POSITION_X, Limit_LIST_POSITION_Y, 466, 466); - TraingLimitList->SetThrowDrag(true); - TraingLimitList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - TraingLimitList->SetMaxScrollDistance(1000); - TraingLimitList->SetSwipeACCLevel(800); - TraingLimitList->SetDragACCLevel(5); - - // 增加表冠控制 - TraingLimitList->SetRotateFactor(2); - TraingLimitList->RequestFocus(); - - SetKeyActListener(); } UIList *TraingLimitView::GetList() { @@ -142,19 +139,26 @@ namespace OHOS { View::OnStart(); BaseView::RootView(Color::Black().full); + SetContainerView(new UIViewGroup()); + container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + container_->SetOnDragListener(presenter_); + container_->SetTouchable(true); + container_->SetDraggable(true); PreLoad(); + RootView::GetInstance()->SetOnKeyActListener(presenter_); } /// @brief 创建页面的视图。 void TraingLimitView::OnSetUpView() { View::OnSetUpView(); - // scrollView->Add(title); - scrollView->Add(TraingLimitList); - scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - RootView::GetInstance()->Add(scrollView); - TraingLimitList->SetAdapter(p_TraingLimitListAdapter); - // TraingLimitList->RefreshList(); // 刷新列表 + if (TraingLimitList != nullptr && p_TraingLimitListAdapter != nullptr) + { + scrollView->Add(TraingLimitList); + scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); + RootView::GetInstance()->Add(scrollView); + TraingLimitList->SetAdapter(p_TraingLimitListAdapter); + } Draw(); } @@ -169,11 +173,14 @@ namespace OHOS void TraingLimitView::OnStop() { View::OnStop(); - + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } RootView::GetInstance()->ClearOnKeyActListener(); - // FocusManager::GetInstance()->ClearFocus(); RootView::GetInstance()->RemoveAll(); - // RootView::GetInstance()->ClearFocus(); return; } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_more/src/TraingMoreView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_more/src/TraingMoreView.cpp index 273aca637..6625ec982 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_more/src/TraingMoreView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_more/src/TraingMoreView.cpp @@ -58,41 +58,38 @@ namespace OHOS } void TraingMoreView::InitView() { + // 初始化 UIScrollView if (scrollView == nullptr) { scrollView = new UIScrollView(); } - scrollView->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - // scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - // scrollView->SetScrollBlankSize(52); - scrollView->SetReboundSize(50); + + // 设置 UIScrollView 属性 + scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); scrollView->SetTouchable(true); scrollView->SetDraggable(true); scrollView->SetDirection(1); - draglistener = static_cast(TraingMorePresenter::GetInstance()); - scrollView->SetOnDragListener(draglistener); + // scrollView->SetReboundSize(50); // 设置空白大小 + scrollView->SetScrollBlankSize(75); + scrollView->SetHorizontalScrollState(false); // 设置横向不可滑动 + + // 设置拖动监听器 + scrollView->SetOnDragListener(presenter_); - /* -------------------------------------------------------------------------- */ - // 初始化Lable + // 初始化 label InitLabelExt(title, 125, 52, 200, 60, "label1", STR_TRAINING, DEFAULT_VECTOR_FONT_FILENAME, 30); scrollView->Add(title); - // UIList 的适配器 + + // 初始化适配器 p_TraingMoreListAdapter = new TraingMoreAdapter(); p_TraingMoreListAdapter->SetItemClickListener(presenter_); + + // 初始化 UIList if (TraingMoreList == nullptr) { TraingMoreList = new UIList(); } - // TraingMoreList->SetScrollBlankSize(More_SCROLLBLANKSIZE); - // TraingMoreList->SetReboundSize(50); - // TraingMoreList->SetSelectPosition(HORIZONTAL_RESOLUTION / SNUM_2); // middle position - // TraingMoreList->SetDraggable(true); - // TraingMoreList->SetThrowDrag(true); - // TraingMoreList->EnableAutoAlign(true); - // TraingMoreList->SetElastic(true); // 设置回弹效果 - // TraingMoreList->SetMaxScrollDistance(MAX_SCR_DIS); - TraingMoreList->SetPosition(More_LIST_POSITION_X, More_LIST_POSITION_Y, 466, 466); TraingMoreList->SetThrowDrag(true); TraingMoreList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); @@ -100,12 +97,14 @@ namespace OHOS TraingMoreList->SetSwipeACCLevel(800); TraingMoreList->SetDragACCLevel(5); - scrollView->SetYScrollBarVisible(true); // 设置滑动滚动条 + // 设置滚动条可见性 + scrollView->SetYScrollBarVisible(true); // 增加表冠控制 TraingMoreList->SetRotateFactor(2); TraingMoreList->RequestFocus(); + // 设置键盘事件监听 SetKeyActListener(); } UIList *TraingMoreView::GetList() @@ -155,7 +154,7 @@ namespace OHOS scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); RootView::GetInstance()->Add(scrollView); TraingMoreList->SetAdapter(p_TraingMoreListAdapter); - TraingMoreList->SetIntercept(true); + // TraingMoreList->SetIntercept(true); // TraingMoreList->RefreshList(); // 刷新列表 Draw(); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_other/src/TraingOtherView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_other/src/TraingOtherView.cpp index 7e2b2118f..f2169771e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_other/src/TraingOtherView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_other/src/TraingOtherView.cpp @@ -57,55 +57,53 @@ namespace OHOS if (scrollView == nullptr) { scrollView = new UIScrollView(); + scrollView = new UIScrollView(); + if (scrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "scrollView new fail!"); + return; + } + scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + scrollView->SetScrollBlankSize(50); + // scrollView->SetReboundSize(35); + scrollView->SetHorizontalScrollState(false); + scrollView->RequestFocus(); + scrollView->SetRotateFactor(1.0); + scrollView->SetMaxScrollDistance(1000); + scrollView->SetDragACCLevel(5); + scrollView->SetSwipeACCLevel(800); /*设置手指抬起屏幕后的补偿距离。*/ + scrollView->SetTouchable(true); + scrollView->SetDraggable(true); + container_->Add(scrollView); } - scrollView->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - // scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - // scrollView->SetScrollBlankSize(52); - scrollView->SetReboundSize(50); - scrollView->SetTouchable(true); - scrollView->SetDraggable(true); - scrollView->SetDirection(1); - draglistener = static_cast(TraingOtherPresenter::GetInstance()); - scrollView->SetOnDragListener(draglistener); - /* -------------------------------------------------------------------------- */ - // 初始化Lable - InitLabelExt(title, 125, 52, 200, 60, "label1", STR_OTHER_TITLE, DEFAULT_VECTOR_FONT_FILENAME, 30); - title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full); - scrollView->Add(title); + // 初始化Lable 暂时不添加 + if (title == nullptr) + { + InitLabelExt(title, 135, 52, 200, 60, "label1", STR_OTHER_LIST, DEFAULT_VECTOR_FONT_FILENAME, 30); + title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full); + scrollView->Add(title); + } // UIList 的适配器 - p_TraingOtherListAdapter = new TraingOtherAdapter(); - p_TraingOtherListAdapter->SetItemClickListener(presenter_); + if (p_TraingOtherListAdapter == nullptr) + { + p_TraingOtherListAdapter = new TraingOtherAdapter(); + p_TraingOtherListAdapter->SetItemClickListener(presenter_); + } + // 初始化列表 if (TraingOtherList == nullptr) { TraingOtherList = new UIList(); + TraingOtherList->SetPosition(43, 120, 466, 466); + TraingOtherList->SetThrowDrag(true); + TraingOtherList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); + TraingOtherList->SetMaxScrollDistance(1000); + TraingOtherList->SetSwipeACCLevel(800); + TraingOtherList->SetDragACCLevel(5); + // 增加表冠控制 + TraingOtherList->SetRotateFactor(2); + TraingOtherList->RequestFocus(); } -#if 0 - TraingOtherList->SetPosition(Other_LIST_POSITION_X, Other_LIST_POSITION_Y); - TraingOtherList->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - TraingOtherList->SetScrollBlankSize(Other_SCROLLBLANKSIZE); - TraingOtherList->SetSelectPosition(HORIZONTAL_RESOLUTION / SNUM_2); // middle position - TraingOtherList->SetReboundSize(50); - TraingOtherList->SetDraggable(true); - TraingOtherList->SetThrowDrag(true); - TraingOtherList->EnableAutoAlign(true); - TraingOtherList->SetElastic(true); // 设置回弹效果 - TraingOtherList->SetMaxScrollDistance(MAX_SCR_DIS); - TraingOtherList->SetYScrollBarVisible(true); // 设置滑动滚动条 -#endif - - TraingOtherList->SetPosition(Other_LIST_POSITION_X, Other_LIST_POSITION_Y, 466, 466); - TraingOtherList->SetThrowDrag(true); - TraingOtherList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - TraingOtherList->SetMaxScrollDistance(1000); - TraingOtherList->SetSwipeACCLevel(800); - TraingOtherList->SetDragACCLevel(5); - - // 增加表冠控制 - TraingOtherList->SetRotateFactor(2); - TraingOtherList->RequestFocus(); - - SetKeyActListener(); } UIList *TraingOtherView::GetList() { @@ -142,19 +140,26 @@ namespace OHOS { View::OnStart(); BaseView::RootView(Color::Black().full); + SetContainerView(new UIViewGroup()); + container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + container_->SetOnDragListener(presenter_); + container_->SetTouchable(true); + container_->SetDraggable(true); PreLoad(); + RootView::GetInstance()->SetOnKeyActListener(presenter_); } /// @brief 创建页面的视图。 void TraingOtherView::OnSetUpView() { View::OnSetUpView(); - scrollView->Add(title); - scrollView->Add(TraingOtherList); - scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - RootView::GetInstance()->Add(scrollView); - TraingOtherList->SetAdapter(p_TraingOtherListAdapter); - // TraingOtherList->RefreshList(); // 刷新列表 + if (TraingOtherList != nullptr && p_TraingOtherListAdapter != nullptr) + { + scrollView->Add(TraingOtherList); + scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); + RootView::GetInstance()->Add(scrollView); + TraingOtherList->SetAdapter(p_TraingOtherListAdapter); + } Draw(); } @@ -169,11 +174,14 @@ namespace OHOS void TraingOtherView::OnStop() { View::OnStop(); - + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } RootView::GetInstance()->ClearOnKeyActListener(); - // FocusManager::GetInstance()->ClearFocus(); RootView::GetInstance()->RemoveAll(); - // RootView::GetInstance()->ClearFocus(); return; } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_rest/src/TraingRestView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_rest/src/TraingRestView.cpp index 149c7ec36..de18deec7 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_rest/src/TraingRestView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_rest/src/TraingRestView.cpp @@ -54,58 +54,55 @@ namespace OHOS } void TraingRestView::InitView() { - if (scrollView == nullptr) + if (scrollView == nullptr) { - scrollView = new UIScrollView(); + scrollView = new UIScrollView(); + if (scrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "scrollView new fail!"); + return; + } + scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + scrollView->SetScrollBlankSize(50); + // scrollView->SetReboundSize(35); + scrollView->SetHorizontalScrollState(false); + scrollView->RequestFocus(); + scrollView->SetRotateFactor(1.0); + scrollView->SetMaxScrollDistance(1000); + scrollView->SetDragACCLevel(5); + scrollView->SetSwipeACCLevel(800); /*设置手指抬起屏幕后的补偿距离。*/ + scrollView->SetTouchable(true); + scrollView->SetDraggable(true); + container_->Add(scrollView); } - scrollView->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - // scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - // scrollView->SetScrollBlankSize(52); - scrollView->SetReboundSize(50); - scrollView->SetTouchable(true); - scrollView->SetDraggable(true); - scrollView->SetDirection(1); - draglistener = static_cast(TraingRestPresenter::GetInstance()); - scrollView->SetOnDragListener(draglistener); - /* -------------------------------------------------------------------------- */ - // 初始化Lable - InitLabelExt(title, 125, 52, 200, 60, "label1", STR_RECREATIONAL_LIST, DEFAULT_VECTOR_FONT_FILENAME, 30); - title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full); - scrollView->Add(title); + // 初始化Lable 暂时不添加 + if (title == nullptr) + { + InitLabelExt(title, 135, 52, 200, 60, "label1", STR_RECREATIONAL_LIST, DEFAULT_VECTOR_FONT_FILENAME, 30); + title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full); + scrollView->Add(title); + } // UIList 的适配器 - p_TraingRestListAdapter = new TraingRestAdapter(); - p_TraingRestListAdapter->SetItemClickListener(presenter_); + if (p_TraingRestListAdapter == nullptr) + { + p_TraingRestListAdapter = new TraingRestAdapter(); + p_TraingRestListAdapter->SetItemClickListener(presenter_); + } + // 初始化列表 if (TraingRestList == nullptr) { TraingRestList = new UIList(); + TraingRestList->SetPosition(43, 120, 466, 466); + TraingRestList->SetThrowDrag(true); + TraingRestList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); + TraingRestList->SetMaxScrollDistance(1000); + TraingRestList->SetSwipeACCLevel(800); + TraingRestList->SetDragACCLevel(5); + // 增加表冠控制 + TraingRestList->SetRotateFactor(2); + TraingRestList->RequestFocus(); } -#if 0 - TraingRestList->SetPosition(Rest_LIST_POSITION_X, Rest_LIST_POSITION_Y); - TraingRestList->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - TraingRestList->SetScrollBlankSize(Rest_SCROLLBLANKSIZE); - TraingRestList->SetSelectPosition(HORIZONTAL_RESOLUTION / SNUM_2); // middle position - TraingRestList->SetReboundSize(50); - TraingRestList->SetDraggable(true); - TraingRestList->SetThrowDrag(true); - TraingRestList->EnableAutoAlign(true); - TraingRestList->SetElastic(true); // 设置回弹效果 - TraingRestList->SetMaxScrollDistance(MAX_SCR_DIS); - TraingRestList->SetYScrollBarVisible(true); // 设置滑动滚动条 -#endif - - TraingRestList->SetPosition(Rest_LIST_POSITION_X, Rest_LIST_POSITION_Y, 466, 466); - TraingRestList->SetThrowDrag(true); - TraingRestList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - TraingRestList->SetMaxScrollDistance(1000); - TraingRestList->SetSwipeACCLevel(800); - TraingRestList->SetDragACCLevel(5); - - // 增加表冠控制 - TraingRestList->SetRotateFactor(2); - TraingRestList->RequestFocus(); - - SetKeyActListener(); } UIList *TraingRestView::GetList() { @@ -142,19 +139,26 @@ namespace OHOS { View::OnStart(); BaseView::RootView(Color::Black().full); + SetContainerView(new UIViewGroup()); + container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + container_->SetOnDragListener(presenter_); + container_->SetTouchable(true); + container_->SetDraggable(true); PreLoad(); + RootView::GetInstance()->SetOnKeyActListener(presenter_); } /// @brief 创建页面的视图。 void TraingRestView::OnSetUpView() { View::OnSetUpView(); - // scrollView->Add(title); - scrollView->Add(TraingRestList); - scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - RootView::GetInstance()->Add(scrollView); - TraingRestList->SetAdapter(p_TraingRestListAdapter); - // TraingRestList->RefreshList(); // 刷新列表 + if (TraingRestList != nullptr && p_TraingRestListAdapter != nullptr) + { + scrollView->Add(TraingRestList); + scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); + RootView::GetInstance()->Add(scrollView); + TraingRestList->SetAdapter(p_TraingRestListAdapter); + } Draw(); } @@ -169,11 +173,14 @@ namespace OHOS void TraingRestView::OnStop() { View::OnStop(); - + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } RootView::GetInstance()->ClearOnKeyActListener(); - // FocusManager::GetInstance()->ClearFocus(); RootView::GetInstance()->RemoveAll(); - // RootView::GetInstance()->ClearFocus(); return; } } \ No newline at end of file -- 2.17.1