From: Caisking <3449750381@qq.com> Date: Sat, 7 Sep 2024 09:40:25 +0000 (+0800) Subject: #207运动界面进行触摸进出操作,界面会抖动,卡顿 X-Git-Tag: release_V1.2.70_20241020_135402~524^2~1^2~8 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=b057b8555d43e074c6f4fbceaa59f43ca1323964;p=mirrors%2FFD230.git #207运动界面进行触摸进出操作,界面会抖动,卡顿 --- 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