From 48b5189b75a339b06369b8e223c12cb11f2fffd4 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Mon, 26 May 2025 16:24:53 +0800 Subject: [PATCH] =?utf8?q?1.=E8=A7=A3=E5=86=B3=E4=B8=8A=E6=AC=A1=E5=AF=B9?= =?utf8?q?=E8=AF=9D=E7=9A=84=E9=97=AE=E9=A2=98=E4=BC=9A=E6=8B=BC=E6=8E=A5?= =?utf8?q?=E5=88=B0=E4=B8=8B=E6=AC=A1=E5=AF=B9=E8=AF=9D=E7=9A=84=E9=97=AE?= =?utf8?q?=E9=A2=98=E4=B8=ADbug=202.=E8=A7=A3=E5=86=B3=E6=BB=91=E5=8A=A8?= =?utf8?q?=E5=88=87=E6=8D=A2=E6=A8=A1=E5=9E=8B=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/aivoice/include/AiVoiceModel.h | 2 +- .../fd230app/nativeui/aivoice/src/AiVoiceModel.cpp | 13 ++++++++++--- .../nativeui/aivoice/src/AiVoicePresenter.cpp | 14 +++++++------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h index 027fc8cf9..a5bd0a1a1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h @@ -66,7 +66,7 @@ namespace OHOS uint8_t GetChatContentListCount(void); // 更新和清空问题及回答 - void RemoveLastTwoItemsOrClear(); + bool RemoveLastTwoItemsOrClear(); bool UpdateUserQuestionStr(void); bool UpdateAiAnswerStr(void); void ClearQuestionAndAiAnswerStr(void); diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp index 0ec96aa08..128cbcf4f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp @@ -298,14 +298,14 @@ namespace OHOS } // 函数定义:移除列表的最后两项或清空列表 - void AiVoiceModel::RemoveLastTwoItemsOrClear() + bool AiVoiceModel::RemoveLastTwoItemsOrClear() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceModel::RemoveLastTwoItemsOrClear"); AivoiceReturnResultTextView *p_AivoiceReturnResultTextView = AivoiceReturnResultTextView::GetInstance(); if (p_AivoiceReturnResultTextView == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceReturnResultTextView::GetInstance fail!!"); - return; + return false; } // 获取适配器 AivoiceChatContentListAdapter *adapter = p_AivoiceReturnResultTextView->GetAivoiceChatContentListAdapter(); @@ -329,6 +329,10 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "listSize = %d", listSize); ChatContentListCount -= (listSize < 2 ? listSize : 2); } + { + return false; + } + return true; } /* 更新用户问题字符串 */ @@ -336,7 +340,10 @@ namespace OHOS { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceModel::UpdateUserQuestionStr"); - RemoveLastTwoItemsOrClear(); + if(!RemoveLastTwoItemsOrClear()) + { + return false; + } if (!AddUserQuestionToChatItems()) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AddUserQuestionToChatItems fail!!"); diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp index c8afeb073..4e2be2598 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp @@ -184,10 +184,10 @@ namespace OHOS { if(view_->GetAiVoiceScrollView(AIVOICE_STARTCHAT_VIEWID) && view_->GetAiVoiceScrollView(AIVOICE_STARTCHAT_VIEWID)->IsVisible() == true) { - int index = model->GetSelectAiModel() + 1; - if (index >= AIMODES_MAX_NUM) + int index = model->GetSelectAiModel() - 1; + if (index < 0) { - index = 0; + index = AIMODES_CHATGPT; } WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiModelsPresenter::index = %d", index); model->SetSelectAiModel(index); @@ -201,10 +201,10 @@ namespace OHOS { if(view_->GetAiVoiceScrollView(AIVOICE_STARTCHAT_VIEWID) && view_->GetAiVoiceScrollView(AIVOICE_STARTCHAT_VIEWID)->IsVisible() == true) { - int index = model->GetSelectAiModel() - 1; - if (index < 0) + int index = model->GetSelectAiModel() + 1; + if (index >= AIMODES_MAX_NUM) { - index = AIMODES_CHATGPT; + index = 0; } WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiModelsPresenter::index = %d", index); model->SetSelectAiModel(index); @@ -565,7 +565,7 @@ namespace OHOS if (isScroll) { // 监听,让List实现滚动 - AivoiceReturnResultTextView::GetInstance()->GetChatContentList()->ScrollBy(-150); + AivoiceReturnResultTextView::GetInstance()->GetChatContentList()->ScrollBy(-120); isScroll = false; } } -- 2.17.1