From: Caisking Date: Mon, 28 Apr 2025 08:34:24 +0000 (+0800) Subject: 修复设置黑屏问题 X-Git-Tag: leiniao_debug_1.0.0_20250922_020716~339 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=5dc76c7a45fbd29260d523ffba6657571a75088d;p=mirrors%2FFD230.git 修复设置黑屏问题 --- diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/saveele/src/SaveBatView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/saveele/src/SaveBatView.cpp index 96410bfd5..dab7179f9 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/saveele/src/SaveBatView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/saveele/src/SaveBatView.cpp @@ -334,8 +334,6 @@ namespace OHOS /* 关闭省电模式 */ uapi_exit_power_saving_mode(); - // UIViewGroup *tmpGroup = dynamic_cast(container_); - // UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup); // 释放所有动态分配的成员变量 if (timelabel) { @@ -631,7 +629,7 @@ namespace OHOS backprogress->SetRadius(90); backprogress->SetEndAngle(359); backprogress->SetValue(0); - container_->Add(backprogress); + AddViewToRootContainer(backprogress); backprogress->SetVisible(false); // 手表image @@ -645,7 +643,7 @@ namespace OHOS wathchiamge->Resize(100, 100); wathchiamge->SetViewId("image1"); wathchiamge->SetSrc(SAVE_WATHCH); - container_->Add(wathchiamge); + AddViewToRootContainer(wathchiamge); wathchiamge->SetVisible(false); // 倒计时 @@ -664,7 +662,7 @@ namespace OHOS countlabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); countlabel->SetRollSpeed(0); countlabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 40); - container_->Add(countlabel); + AddViewToRootContainer(countlabel); countlabel->SetVisible(false); #else if (canvas_ == nullptr) @@ -847,8 +845,7 @@ namespace OHOS Draw(); - //SetContainerView(container_); - //RootView::GetInstance()->SetOnKeyActListener(presenter_); + //GetRootContainer()->SetOnKeyActListener(presenter_); } diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/saveele/src/SaveEleView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/saveele/src/SaveEleView.cpp index 2bf54c6ad..74524024c 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/saveele/src/SaveEleView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/saveele/src/SaveEleView.cpp @@ -31,16 +31,10 @@ SaveEleView::SaveEleView() { g_pSaveEleView = this; } SaveEleView::~SaveEleView() { - // UIViewGroup *tmpGroup = dynamic_cast(container_); - // UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup); if (scrollview_ != nullptr) { scrollview_->RemoveAll(); - delete scrollview_; - scrollview_ = nullptr; - } - RootView::GetInstance()->RemoveAll(); - + if (labeltitle) { delete labeltitle; labeltitle = nullptr; @@ -65,7 +59,10 @@ SaveEleView::~SaveEleView() { delete buttonok; buttonok = nullptr; } - + delete scrollview_; + scrollview_ = nullptr; + } + g_pSaveEleView = nullptr; } @@ -125,11 +122,15 @@ void SaveEleView::OnStart() { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "scrollview_ new fail"); return; } - scrollview_->SetScrollBlankSize(35); - scrollview_->SetReboundSize(50); + // scrollview_->SetScrollBlankSize(35); + // scrollview_->SetReboundSize(50); scrollview_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + + scrollview_->SetHorizontalScrollState(false); // 设置水平滚动失效 + scrollview_->SetDirection(1); + scrollview_->SetOnDragListener(presenter_); scrollview_->SetOnRotateListener(presenter_); scrollview_->SetRotateFactor(2); diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/settings/include/SettingView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/settings/include/SettingView.h index a1ef83847..54a758868 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/settings/include/SettingView.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/settings/include/SettingView.h @@ -31,6 +31,13 @@ namespace OHOS void AddSettingItemToList(const SettingItem &item); + UIList *GetSettingList(void) + { + return contentList; + } + + void RefreshSettingList(const SettingItem *item); + private: void CreateSettingView(void); void ClearAll(void); diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/settings/src/SettingPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/settings/src/SettingPresenter.cpp index c4b2e6277..d8b276316 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/settings/src/SettingPresenter.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/settings/src/SettingPresenter.cpp @@ -76,23 +76,22 @@ namespace OHOS void SettingPresenter::OnStart() { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnStart"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnStart"); Presenter::OnStart(); settingModel->InitSettingItem(); - } - void SettingPresenter::OnResume(void) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnResume"); if (view_ == nullptr) { return; } const SettingItem *itemInfo = settingModel->GetSettinglistItems(); - for (uint8_t i = 0; i < settingModel->GetSettingListNum(); i++) - { - view_->AddSettingItemToList(itemInfo[i]); - } + + view_->RefreshSettingList(itemInfo); + } + + void SettingPresenter::OnResume(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnResume"); } // 页面准备切换到后台前执行的逻辑 @@ -105,7 +104,6 @@ namespace OHOS void SettingPresenter::OnStop(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnStop"); - Presenter::OnPause(); return; } @@ -148,10 +146,13 @@ namespace OHOS bool SettingPresenter::OnClick(UIView &view, const ClickEvent &event) { UNUSED(event); + WEARABLE_LOGE(WEOFABLE_LOG_MODULE_APP, "SettingPresenter::OnClick"); + SettingItemView *settingItemView = static_cast(&view); AppViewId viewId = settingItemView->GetViewId(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "%d\n", viewId); - NativeAbility::GetInstance().EnterSlice(viewId); + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%d\n", viewId); + NativeAbility::GetInstance().ChangeSlice(viewId); return true; } } diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/settings/src/SettingView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/settings/src/SettingView.cpp index 590a5306b..e8fe9f7d2 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/settings/src/SettingView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/settings/src/SettingView.cpp @@ -39,7 +39,7 @@ namespace OHOS { settingListOnStop(); ClearAll(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::~SettingView"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SettingView::~SettingView"); } void SettingView::ClearAll(void) @@ -132,7 +132,7 @@ namespace OHOS CreateSettingView(); viewInitStatus = true; } - + settingListOnSetUpView(); // 增加按键监听 RootView::GetInstance()->SetOnKeyActListener(presenter_); } @@ -192,11 +192,22 @@ namespace OHOS void SettingView::settingListOnStop(void) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::settingListOnStop"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SettingView::settingListOnStop"); int16_t listHeadY = contentList->GetChildrenHead()->GetY(); int16_t listHeadIndex = contentList->GetChildrenHead()->GetViewIndex(); presenter_->SetHeadItemY(listHeadY); presenter_->SetStartIndex(listHeadIndex); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "listHeadY = %d,listHeadIndex = %d", listHeadY, listHeadIndex); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "listHeadY = %d,listHeadIndex = %d", listHeadY, listHeadIndex); + } + + + void SettingView:: RefreshSettingList(const SettingItem *item){ + for (uint8_t i = 0; i < SettingModel::GetInstance().GetSettingListNum(); i++) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnStart itemInfo[i].itemName:%d", i); + AddSettingItemToList(item[i]); + } + contentList->SetAdapter(listAdapter); + contentList->RefreshList(); } }