From 0c21fa86bced0bb866390eb8dc6bf9cf9bb2301b Mon Sep 17 00:00:00 2001 From: Caisking <3449750381@qq.com> Date: Mon, 15 Jul 2024 17:11:45 +0800 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E5=A4=8D=E4=B8=BB=E7=95=8C=E9=9D=A2?= =?utf8?q?=E4=B8=8A=E6=8B=89=E6=B6=88=E6=81=AFitem=E7=9A=84index=E8=8E=B7?= =?utf8?q?=E5=8F=96=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../message/src/MessageControlPresenter.cpp | 28 ++++++++---------- .../nativeui/message/src/MessageModel.cpp | 4 ++- .../nativeui/message/src/MessagePresenter.cpp | 29 ++++--------------- .../message/src/MessageShowPresenter.cpp | 7 ++++- 4 files changed, 26 insertions(+), 42 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageControlPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageControlPresenter.cpp index f2b1c5526..494fd2bfb 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageControlPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageControlPresenter.cpp @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-06-22 11:36:16 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-07-15 16:53:35 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageControlPresenter.cpp + */ /*** * @Date: 2024-06-22 11:36:16 * @LastEditors: Caisking 3449750381@qq.com @@ -44,11 +50,6 @@ namespace OHOS { UNUSED(event); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MessageControlView::OnClick %s", view.GetViewId()); - if (strcmp(view.GetViewId(), MAINMESSAGEVIEW) != 0) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Error: View is not List"); - return false; - } if (!MessageModel::GetInstance().HasDataVector()) { @@ -69,18 +70,13 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Error: Invalid view type."); return false; } - - int index1 = MessageCardView::GetInstance()->GetList()->GetViewIndex(); - int index2 = p_MessageItemView->GetMessageListIndex(); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "index1 is %d, index2 is %d", index1, index2); - if (index2 > -1 && index2 < 11) - { - MessageModel::GetInstance().SetCurrentIndex(index2); - // 切换到详情界面 - NativeAbility::GetInstance().ChangeSlice(VIEW_MESSAGE_SHOW); - } + int index = p_MessageItemView->GetMessageListIndex(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "index is %d", index); - return true; // 返回 true 表示点击事件处理成功 + MessageModel::GetInstance().SetCurrentIndex(index); + MessageModel::GetInstance().SetMessageAsRead(); + NativeAbility::GetInstance().ChangeSlice(VIEW_MESSAGE_SHOW); // 切换到详情界面 + return true; } } // namespace OHOS \ No newline at end of file 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 f417b0bc7..8f4c1a856 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageModel.cpp @@ -209,7 +209,7 @@ namespace OHOS data.labelDetails = labelDetails->valuestring; data.labelTitle = labelTitle->valuestring; data.timestamp = timestamp->valuedouble; - + char labelTime[20]; if (uapi_get_TIME_STR(data.timestamp, labelTime, '.', ':', DATE_Y_M_D_H_M) != ERRCODE_SUCC) { @@ -304,6 +304,8 @@ namespace OHOS // 设置当前项[数组下标] void MessageModel::SetCurrentIndex(uint8_t index) { + if (index < 0 || index > MaxMessageListCount) + return; numberOfItems = MessageVector.size(); currentIndex_ = numberOfItems - index - 1; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessagePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessagePresenter.cpp index 0de31f895..51924c7fd 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessagePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessagePresenter.cpp @@ -1,21 +1,4 @@ -/*** - * @Date: 2024-04-15 10:55:58 - * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-06-18 17:26:05 - * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/message/src/MessagePresenter.cpp - */ -/*** - * @Date: 2024-04-15 10:55:58 - * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-06-15 15:56:50 - * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/message/src/MessagePresenter.cpp - */ -/*** - * @Date: 2024-04-15 10:55:58 - * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-04-23 15:38:33 - * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/message/src/MessagePresenter.cpp - */ + #include "AppViewIDs.h" #include "components/ui_label_ext.h" @@ -94,14 +77,12 @@ namespace OHOS { NativeAbility::GetInstance().Back(); } - if (!MessageModel::GetInstance().GetPopupViewState()) + // 向下回到主界面 + if (event.GetDragDirection() == DragEvent::DIRECTION_TOP_TO_BOTTOM) { - // 向下回到主界面 - if (event.GetDragDirection() == DragEvent::DIRECTION_TOP_TO_BOTTOM) - { - NativeAbility::GetInstance().EnterSlice(VIEW_MAIN); - } + NativeAbility::GetInstance().EnterSlice(VIEW_MAIN); } + return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageShowPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageShowPresenter.cpp index 692688cfa..25860de82 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageShowPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageShowPresenter.cpp @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-06-17 19:39:36 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-07-15 17:05:36 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageShowPresenter.cpp + */ /*** * @Date: 2024-06-17 19:39:36 * @LastEditors: Caisking 3449750381@qq.com @@ -80,7 +86,6 @@ namespace OHOS { NativeAbility::GetInstance().ChangeSlice(VIEW_MESSAGE); } - return true; } -- 2.17.1