From 387022ff90dfe109e1dd7641cabc70d1fc247a79 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Fri, 16 Jan 2026 14:24:15 +0800 Subject: [PATCH] =?utf8?q?=E8=A7=A3=E5=86=B3=E6=98=9F=E5=8E=86=E4=B8=8B?= =?utf8?q?=E8=BD=BD=E7=95=8C=E9=9D=A2=E6=81=AF=E5=B1=8F=E6=BB=91=E5=8A=A8?= =?utf8?q?=E7=9B=91=E5=90=AC=E5=A4=B1=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/callerlog/src/CallerLogView.cpp | 6 +-- .../include/EphemerisDownloadPresenter.h | 1 - .../include/EphemerisDownloadView.h | 1 + .../src/EphemerisDownloadPresenter.cpp | 3 -- .../src/EphemerisDownloadView.cpp | 44 +++++++++++++------ 5 files changed, 34 insertions(+), 21 deletions(-) diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/callerlog/src/CallerLogView.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/callerlog/src/CallerLogView.cpp index bc0d0a1c7..ed0a37c46 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/callerlog/src/CallerLogView.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/callerlog/src/CallerLogView.cpp @@ -125,7 +125,7 @@ void CallerLogView::InitBluetoothHintsGroup() hintsImageView->SetSrc(PNG_BLUETOOTH_HINTS_PATH); hintsGroup->Add(hintsImageView); - GetRootContainer()->Add(hintsGroup); + AddViewToRootContainer(hintsGroup); hintsGroup->SetVisible(false); return; } @@ -208,7 +208,7 @@ void CallerLogView::OnStart() WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerLogView::CreateNoDataCallerLogViewGroup error"); return; } - GetRootContainer()->Add(group); + AddViewToRootContainer(group); if (!CreateCallerLogViewGroup()) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerLogView::CreateCallerLogViewGroup error"); @@ -256,7 +256,7 @@ void CallerLogView::OnStart() return; } - GetRootContainer()->Add(scrollview); + AddViewToRootContainer(scrollview); if (num == 0) { group->SetVisible(true); diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/include/EphemerisDownloadPresenter.h b/code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/include/EphemerisDownloadPresenter.h index f498e7d9b..e76296e6d 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/include/EphemerisDownloadPresenter.h +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/include/EphemerisDownloadPresenter.h @@ -29,7 +29,6 @@ namespace OHOS EphemerisDownloadPresenter(const EphemerisDownloadPresenter &) = delete; EphemerisDownloadPresenter &operator=(const EphemerisDownloadPresenter &) = delete; void OnResume() override; - void OnStop() override; bool OnClick(UIView &view, const ClickEvent &event) override; bool OnDrag(UIView &view, const DragEvent &event) override; bool OnKeyAct(UIView &view, const KeyEvent &event) override; diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/include/EphemerisDownloadView.h b/code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/include/EphemerisDownloadView.h index 876caf0e8..c7a1b5441 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/include/EphemerisDownloadView.h +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/include/EphemerisDownloadView.h @@ -43,6 +43,7 @@ public: void UpdateDownloadButton(); private: + UIViewGroup*group{nullptr}; UILabelExt *labelTitle_{nullptr}; UILabelExt *labelStatus_{nullptr}; UILabelExt *labelStatusValue_{nullptr}; // 新增:状态值标签 diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/src/EphemerisDownloadPresenter.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/src/EphemerisDownloadPresenter.cpp index 9e06dd2e1..0fc58b3ec 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/src/EphemerisDownloadPresenter.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/src/EphemerisDownloadPresenter.cpp @@ -35,9 +35,6 @@ void EphemerisDownloadPresenter::OnResume() { RootView::GetInstance()->SetOnKeyActListener(this); } -void EphemerisDownloadPresenter::OnStop() { -} - EphemerisDownloadPresenter* EphemerisDownloadPresenter::GetInstance() { return g_instance; } diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/src/EphemerisDownloadView.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/src/EphemerisDownloadView.cpp index d3f7a6b8c..40c3bc2a5 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/src/EphemerisDownloadView.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/src/EphemerisDownloadView.cpp @@ -20,6 +20,14 @@ EphemerisDownloadView::EphemerisDownloadView() { } EphemerisDownloadView::~EphemerisDownloadView() { + + if (group!=nullptr) + { + group->RemoveAll(); + delete group; + group = nullptr; + } + if (labelTitle_!=nullptr) { delete labelTitle_; @@ -69,12 +77,6 @@ void EphemerisDownloadView::OnStart() { if (!EphemerisDownloadInit()) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "EphemerisDownloadView::EphemerisDownloadInit fail"); } - - GetRootContainer()->SetDraggable(true); - GetRootContainer()->SetPosition(0, 0, 466, 466); - GetRootContainer()->SetOnDragListener(presenter_); - - GetRootContainer()->SetTouchable(true); } EphemerisDownloadView *EphemerisDownloadView::GetInstance() { @@ -82,6 +84,20 @@ EphemerisDownloadView *EphemerisDownloadView::GetInstance() { } bool EphemerisDownloadView::EphemerisDownloadInit() { + + group = new UIViewGroup(); + if (group == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[FindPhoneViewInit_BlueToothConnected] group new fail!!"); + return false; + } + group->SetPosition(0, 0, 466, 466); + group->SetStyle(STYLE_BACKGROUND_OPA, 0); + group->SetTouchable(true); + group->SetDraggable(true); + group->SetOnDragListener(presenter_); + AddViewToRootContainer(group); + // 初始化标题 - 居中显示 labelTitle_ = new UILabelExt(); if (labelTitle_ == nullptr) { @@ -94,7 +110,7 @@ bool EphemerisDownloadView::EphemerisDownloadInit() { labelTitle_->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); labelTitle_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); labelTitle_->SetTextColor(Color::White()); - AddViewToRootContainer(labelTitle_); + group->Add(labelTitle_); // 初始化状态标签 - 左对齐,带圆点前缀 labelStatus_ = new UILabelExt(); @@ -107,7 +123,7 @@ bool EphemerisDownloadView::EphemerisDownloadInit() { labelStatus_->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); labelStatus_->SetText("● 下载状态:"); labelStatus_->SetTextColor(Color::Yellow());//黄色 - AddViewToRootContainer(labelStatus_); + group->Add(labelStatus_); // 初始化状态值标签 - 显示具体状态 labelStatusValue_ = new UILabelExt(); @@ -118,7 +134,7 @@ bool EphemerisDownloadView::EphemerisDownloadInit() { labelStatusValue_->SetPosition(220, 120, 360, 70); labelStatusValue_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 28); labelStatusValue_->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); - AddViewToRootContainer(labelStatusValue_); + group->Add(labelStatusValue_); // 初始化有效期标签 - 左对齐,带圆点前缀 labelValidity_ = new UILabelExt(); @@ -131,7 +147,7 @@ bool EphemerisDownloadView::EphemerisDownloadInit() { labelValidity_->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); labelValidity_->SetText("● 有效期:"); labelValidity_->SetTextColor(Color::Green());//绿色 - AddViewToRootContainer(labelValidity_); + group->Add(labelValidity_); // 初始化有效期值标签 - 显示具体有效期 labelValidityValue_ = new UILabelExt(); @@ -142,7 +158,7 @@ bool EphemerisDownloadView::EphemerisDownloadInit() { labelValidityValue_->SetPosition(220, 170, 360, 70); labelValidityValue_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 28); labelValidityValue_->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); - AddViewToRootContainer(labelValidityValue_); + group->Add(labelValidityValue_); // 初始化说明标签 - 居中显示,灰色文字 labelNote_ = new UILabelExt(); @@ -157,7 +173,7 @@ bool EphemerisDownloadView::EphemerisDownloadInit() { labelNote_->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); // 灰色 //修改为靠左对齐 labelNote_->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); - AddViewToRootContainer(labelNote_); + group->Add(labelNote_); InitButtonExt(btnDownload_, 58, 320, 170, 90, DOWNLOAD_ID, STR_EPHEMERIS_DOWNLOAD, 30); btnDownload_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); // 设置按键颜色 @@ -166,8 +182,8 @@ bool EphemerisDownloadView::EphemerisDownloadInit() { InitButtonExt(btnBack_, 238, 320, 170, 90, BACK_ID, STR_CANCEL, 30); btnBack_->SetStyle(STYLE_BACKGROUND_COLOR, 0xffFF8A36); // 设置按键颜色 btnBack_->SetOnClickListener(presenter_); - AddViewToRootContainer(btnDownload_); - AddViewToRootContainer(btnBack_); + group->Add(btnDownload_); + group->Add(btnBack_); // 初始化完成后更新所有状态 UpdateDownloadStatus(); -- 2.17.1