From 1c9c7ce4f747958ee5e1a140a73f13b7dd2f4d90 Mon Sep 17 00:00:00 2001 From: Caisking <3449750381@qq.com> Date: Tue, 9 Jul 2024 10:29:26 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A0=E8=AF=BB=E5=8F=96=E4=BF=A1?= =?utf8?q?=E6=81=AF=E9=94=99=E8=AF=AF=E7=9A=84=E9=BB=98=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../fd230app/nativeui/message/src/MessageModel.cpp | 7 +++++-- .../msg_center/src/notify/message_notification.cpp | 12 +++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageModel.cpp index 2b7499db0..0dfc1a595 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageModel.cpp @@ -290,8 +290,11 @@ namespace OHOS std::vector messageVector = LoadMessageData(); numberOfItems = messageVector.size(); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "the numberOfItems is %d", numberOfItems); - - return &messageVector[numberOfItems - 1]; + if (numberOfItems >= 0) + { + return &messageVector[numberOfItems - 1]; + } + return nullptr; } // 设置当前项 void MessageModel::SetCurrentIndex(uint8_t index) diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/message_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/message_notification.cpp index 0ccbe24f7..e4b1463e9 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/message_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/message_notification.cpp @@ -93,7 +93,7 @@ namespace OHOS return nullptr; } MessageGroupView->SetOnDragListener(dragListener); - #ifdef FD230 +#ifdef FD230 /*获取最新message*/ MessageData *data = MessageModel::GetInstance().GetNewestData(); if (data != nullptr) @@ -102,7 +102,13 @@ namespace OHOS timeStr = data->labelTime; messageStr = data->labelDetails; } - #endif + else + { + titleStr = "--"; + timeStr = "--"; + messageStr = "--"; + } +#endif /*初始化label*/ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitView"); /* -------------------------------------------------------------------------- */ @@ -164,7 +170,7 @@ namespace OHOS return nullptr; // 内存分配失败,返回 } deleteButton->SetPosition(0, 366); - deleteButton->Resize(466,100); + deleteButton->Resize(466, 100); deleteButton->SetViewId(DELETEBUTTON); deleteButton->SetText("Close"); deleteButton->SetStyle(STYLE_TEXT_FONT, 30); -- 2.17.1