/* --------------------------------- 主界面卡片功能 -------------------------------- */
void MainPresenterSample::Notify(void)
{
+ if (view_ == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Notify: view_ is nullptr");
+ return;
+ }
CardId currentCardId = view_->GetHorCurrentCard();
// 从心率卡片变为其他卡片时关闭心率检测
{
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);
}
if(WeatherControlView::GetInstance())
{
auto weatherSwipView = WeatherControlView::GetInstance()->GetWeatherSwipView();
- if (weatherSwipView->GetCurrentPage() != 0)
+ if (weatherSwipView != nullptr && weatherSwipView->GetCurrentPage() != 0)
{
weatherSwipView->SetCurrentPage(0);
}
if(goalControlView::GetInstance())
{
auto goalSwipView = goalControlView::GetInstance()->GetGoalControlSwipView();
- if (goalSwipView->GetCurrentPage() != 0)
+ if (goalSwipView != nullptr && goalSwipView->GetCurrentPage() != 0)
{
goalSwipView->SetCurrentPage(0);
}
{
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<DialViewGroup *>(view_->GetViewById(WATCH_FACE))->UpdateViewsByPeriodicUpdateData();
+ auto dialViewGroup = dynamic_cast<DialViewGroup *>(watchFace);
+ if (dialViewGroup == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpdateWatchFace: DialViewGroup cast failed");
+ return;
+ }
+ dialViewGroup->UpdateViewsByPeriodicUpdateData();
}
else
{
- dynamic_cast<MainClockView *>(view_->GetViewById(WATCH_FACE))->UpdateTime();
+ auto mainClockView = dynamic_cast<MainClockView *>(watchFace);
+ if (mainClockView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpdateWatchFace: MainClockView cast failed");
+ return;
+ }
+ mainClockView->UpdateTime();
}
}