From 8fbef837f3fbf030543b151b6cd751d18900c436 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Wed, 14 Jan 2026 14:40:30 +0800 Subject: [PATCH] =?utf8?q?=E8=A7=A3=E5=86=B3=E7=A6=85=E9=81=93=EF=BC=8C692?= =?utf8?q?=E6=89=8B=E8=A1=A8-=E5=9C=A8=E8=BF=90=E5=8A=A8=E5=88=97=E8=A1=A8?= =?utf8?q?=E9=A1=B5=E7=86=84=E5=B1=8F=E5=90=8E=E5=86=8D=E7=9F=AD=E6=8C=89?= =?utf8?q?=E4=BE=A7=E9=94=AE=E4=BA=AE=E5=B1=8F=EF=BC=8C=E5=86=8D=E6=AC=A1?= =?utf8?q?=E7=9F=AD=E6=8C=89=E4=BE=A7=E9=94=AE/=E5=8F=B3=E6=BB=91=E5=8A=A8?= =?utf8?q?=E6=97=A0=E6=95=88=EF=BC=88OTA123)=EF=BC=89bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/traing/include/TraingPresenter.h | 2 - .../nativeui/traing/include/TraingView.h | 1 + .../nativeui/traing/src/TraingPresenter.cpp | 12 ++-- .../nativeui/traing/src/TraingView.cpp | 55 ++++++++++--------- 4 files changed, 37 insertions(+), 33 deletions(-) diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/include/TraingPresenter.h b/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/include/TraingPresenter.h index 87fcd1449..1328565ee 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/include/TraingPresenter.h +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/include/TraingPresenter.h @@ -32,9 +32,7 @@ namespace OHOS virtual ~TraingPresenter(); void OnStart() override; - void OnPause() override; void OnResume() override; - void OnStop() override; void NavigateBack(); static TraingPresenter *GetInstance(); diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/include/TraingView.h b/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/include/TraingView.h index 61b9ca244..dce2a0f06 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/include/TraingView.h +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/include/TraingView.h @@ -37,6 +37,7 @@ 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/fd272/nativeapp/nativeui/traing/src/TraingPresenter.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/src/TraingPresenter.cpp index 7887a3d45..a3d1b3028 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/src/TraingPresenter.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/src/TraingPresenter.cpp @@ -47,17 +47,17 @@ TraingPresenter::~TraingPresenter() { TraingPresenter *TraingPresenter::GetInstance() { return g_pTraingPresenter; } -void TraingPresenter::OnStart() { Presenter::OnStart(); } +void TraingPresenter::OnStart() { } -void TraingPresenter::OnPause(void) { Presenter::OnPause(); } - -void TraingPresenter::OnResume(void) { Presenter::OnResume(); } +void TraingPresenter::OnResume(void) +{ + RootView::GetInstance()->SetOnKeyActListener(this); +} -void TraingPresenter::OnStop(void) { Presenter::OnStop(); } // 回退函数 [ Slice 的 traingview {右滑只能回到applist}] void TraingPresenter::NavigateBack() { NativeAbility::GetInstance().ChangeSlice( - VIEW_APPLIST, TransitionType::TRANSITION_BACK_TO_HEXAGONS); + VIEW_APPLIST, TransitionType::TRANSITION_INVALID); NativeAbility::GetInstance().ClearSliceIdStack(); // 清空所有SLiceId栈元素 } bool TraingPresenter::OnDrag(UIView &view, const DragEvent &event) { diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/src/TraingView.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/src/TraingView.cpp index b79ec68bb..e633b0188 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/src/TraingView.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/src/TraingView.cpp @@ -142,27 +142,34 @@ void TraingView::InitView() { // 初始化图片 AddImageView(); - AddViewToRootContainer(button1_); - AddViewToRootContainer(button2_); - AddViewToRootContainer(button3_); - AddViewToRootContainer(buttonmore_); - - AddViewToRootContainer(title_label); - AddViewToRootContainer(btn1_label); - AddViewToRootContainer(btn2_label); - AddViewToRootContainer(btn3_label); - AddViewToRootContainer(btnmore_label); - - AddViewToRootContainer(btn1_image); - AddViewToRootContainer(btn2_image); - AddViewToRootContainer(btn3_image); - AddViewToRootContainer(btnmore_image); + group->Add(button1_); + group->Add(button2_); + group->Add(button3_); + group->Add(buttonmore_); + + group->Add(title_label); + group->Add(btn1_label); + group->Add(btn2_label); + group->Add(btn3_label); + group->Add(btnmore_label); + + group->Add(btn1_image); + group->Add(btn2_image); + group->Add(btn3_image); + group->Add(btnmore_image); + AddViewToRootContainer(group); 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; @@ -235,17 +242,15 @@ void TraingView::OnStart() { printf(" data--training3_Image: %s\n", data->training3_Image.c_str()); #endif + // 创建group容器 + group = new UIViewGroup(); + group->SetPosition(0, 0); + group->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - // 创建 draglistener 实例并设置为拖动监听器 - UIView::OnDragListener *draglistener = - static_cast(TraingPresenter::GetInstance()); - if (draglistener == nullptr) { - return; - } - GetRootContainer()->SetOnDragListener(draglistener); - GetRootContainer()->SetTouchable(true); - GetRootContainer()->SetDraggable(true); - + // 设置拖拽监听器 + group->SetDraggable(true); + group->SetTouchable(true); + group->SetOnDragListener(presenter_); InitView(); -- 2.17.1