From: Caisking <3449750381@qq.com> Date: Sat, 7 Sep 2024 09:38:55 +0000 (+0800) Subject: #443运动-类别界面-上滑会有短暂回弹 X-Git-Tag: release_V1.2.70_20241020_135402~524^2~1^2~10 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=475581bf0a54c0b9f477b3fab7241397d7802560;p=mirrors%2FFD230.git #443运动-类别界面-上滑会有短暂回弹 --- 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