From fc033d85bd9b3f4451b4f9c59d25ff1dd73209a5 Mon Sep 17 00:00:00 2001 From: Caisking <3449750381@qq.com> Date: Sat, 10 Aug 2024 11:52:26 +0800 Subject: [PATCH] =?utf8?q?=E8=AE=AD=E7=BB=83=E8=AE=B0=E5=BD=95=E4=BF=AE?= =?utf8?q?=E6=94=B9=E6=9E=90=E6=9E=84=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../traingrecord/src/TraingRecordView.cpp | 46 +++++++++---------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordView.cpp index b91e8da50..3b8a85d8b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordView.cpp @@ -29,7 +29,10 @@ namespace OHOS TraingRecordView::~TraingRecordView() { - DeInit(); + // DeInit(); + UIViewGroup *tmpGroup = dynamic_cast(container_); + UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup); + g_pTraingRecordView = nullptr; } @@ -63,6 +66,7 @@ namespace OHOS /* DeInit:删除组件 */ void TraingRecordView::DeInit() { + lackView->RemoveAll(); recordView->RemoveAll(); @@ -127,7 +131,10 @@ namespace OHOS lackView->Add(imagerecord); lackView->Add(buttongo); - RootView::GetInstance()->Add(lackView); + // RootView::GetInstance()->lackView + container_->Add(lackView); + printf("lackView Add\r\n"); + lackView->SetDraggable(true); lackView->SetTouchable(true); @@ -150,7 +157,7 @@ namespace OHOS return; } recordView->SetPosition(0, 0); - recordView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); + recordView->Resize(466, 466); recordView->SetScrollBlankSize(20); recordView->SetReboundSize(50); recordView->SetDirection(1); @@ -192,27 +199,19 @@ namespace OHOS void TraingRecordView::SetPopupViewStatus(PopupRecord view, bool status) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetPopupViewStatus %d", view); - UIView *popupView = nullptr; + if (view == PopupRecord::LackPopup) { TraingRecordModel::GetInstance().SetPopupView(false); // 设置状态为无训练记录 - popupView = lackView; + lackView->SetVisible(true); // 隐藏界面 + recordView->SetVisible(false); // 隐藏界面 } else if (view == PopupRecord::RecordPopup) { TraingRecordModel::GetInstance().SetPopupView(true); // 设置状态为有训练记录 - popupView = recordView; - } - if (popupView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PopupView is NULL"); - return; - } - if (container_ != nullptr) - { - container_->SetVisible(!status); + lackView->SetVisible(false); // 隐藏界面 + recordView->SetVisible(true); // 隐藏界面 } - popupView->SetVisible(status); } // 获取目前的view void TraingRecordView::OnStart() @@ -226,13 +225,8 @@ namespace OHOS return; } container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - // 创建 draglistener 实例并设置为拖动监听器 - UIView::OnDragListener *draglistener = static_cast(TraingRecordPresenter::GetInstance()); - if (draglistener == nullptr) - { - return; - } - container_->SetOnDragListener(draglistener); + + container_->SetOnDragListener(presenter_); container_->SetTouchable(true); container_->SetDraggable(true); container_->SetStyle(STYLE_BACKGROUND_COLOR, BACK_GROUND_COLOR); @@ -241,8 +235,9 @@ namespace OHOS ShowLackView(); ShowRecordView(); PreLoad(); - RootView::GetInstance()->Add(container_); + SetContainerView(container_); + // 增加按键监听 RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::TraingRecordPresenter::GetInstance(); RootView::GetInstance()->SetOnKeyActListener(keyactListener); @@ -258,7 +253,8 @@ namespace OHOS { recordView->Add(TraingRecordList); recordView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - RootView::GetInstance()->Add(recordView); + container_->Add(recordView); + printf("recordView Add\r\n"); TraingRecordList->SetAdapter(p_TraingRecordAdapter); } Draw(); -- 2.17.1