From: Caisking <3449750381@qq.com> Date: Sat, 7 Sep 2024 09:39:43 +0000 (+0800) Subject: #444运动类界面-右滑返回上一级界面有界面晃动 X-Git-Tag: release_V1.2.70_20241020_135402~524^2~1^2~9 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=61b7cfbac43b58997a3c1bb9e8add9e6fbe84542;p=mirrors%2FFD230.git #444运动类界面-右滑返回上一级界面有界面晃动 --- 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