From: Caisking Date: Fri, 20 Mar 2026 06:44:43 +0000 (+0800) Subject: 修复主界面notify的刷新 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=refs%2Fchanges%2F3298%2Fhead;p=mirrors%2FFD230.git 修复主界面notify的刷新 --- diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/main/src/MainPresenterSample.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/main/src/MainPresenterSample.cpp index b2bad82b1..9680dd378 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/main/src/MainPresenterSample.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/main/src/MainPresenterSample.cpp @@ -431,6 +431,11 @@ /* --------------------------------- 主界面卡片功能 -------------------------------- */ void MainPresenterSample::Notify(void) { + if (view_ == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Notify: view_ is nullptr"); + return; + } CardId currentCardId = view_->GetHorCurrentCard(); // 从心率卡片变为其他卡片时关闭心率检测 @@ -510,8 +515,8 @@ { if (SleepCardView::GetInstance() != nullptr) { - auto sleepCardView = SleepCardView::GetInstance()->GetSleepCardView(); - if (sleepCardView->GetCurrentPage() != 0) + auto sleepCardView = SleepCardView::GetInstance()->GetSleepCardView(); + if (sleepCardView != nullptr && sleepCardView->GetCurrentPage() != 0) { sleepCardView->SetCurrentPage(0); } @@ -525,7 +530,7 @@ if(WeatherControlView::GetInstance()) { auto weatherSwipView = WeatherControlView::GetInstance()->GetWeatherSwipView(); - if (weatherSwipView->GetCurrentPage() != 0) + if (weatherSwipView != nullptr && weatherSwipView->GetCurrentPage() != 0) { weatherSwipView->SetCurrentPage(0); } @@ -537,7 +542,7 @@ if(goalControlView::GetInstance()) { auto goalSwipView = goalControlView::GetInstance()->GetGoalControlSwipView(); - if (goalSwipView->GetCurrentPage() != 0) + if (goalSwipView != nullptr && goalSwipView->GetCurrentPage() != 0) { goalSwipView->SetCurrentPage(0); } @@ -564,16 +569,34 @@ { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "view_ is nullptr"); return; + } + UIView *watchFace = view_->GetViewById(WATCH_FACE); + if (watchFace == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpdateWatchFace: watchFace is nullptr"); + return; } DialSetting &setting = GetDialSetting(); if (setting.dialFlag) { DialModelTime::GetInstance()->UpdateTime(); - dynamic_cast(view_->GetViewById(WATCH_FACE))->UpdateViewsByPeriodicUpdateData(); + auto dialViewGroup = dynamic_cast(watchFace); + if (dialViewGroup == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpdateWatchFace: DialViewGroup cast failed"); + return; + } + dialViewGroup->UpdateViewsByPeriodicUpdateData(); } else { - dynamic_cast(view_->GetViewById(WATCH_FACE))->UpdateTime(); + auto mainClockView = dynamic_cast(watchFace); + if (mainClockView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpdateWatchFace: MainClockView cast failed"); + return; + } + mainClockView->UpdateTime(); } }