From: luozheng <1732036298@qq.com> Date: Mon, 26 May 2025 08:24:53 +0000 (+0800) Subject: 1.解决上次对话的问题会拼接到下次对话的问题中bug X-Git-Url: http://git.snicker.com.cn/css/html/static/gitweb.css?a=commitdiff_plain;h=refs%2Fchanges%2F1800%2Ftarget%2F1;p=mirrors%2FFD230.git 1.解决上次对话的问题会拼接到下次对话的问题中bug 2.解决滑动切换模型问题 --- 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; } }