1.解决上次对话的问题会拼接到下次对话的问题中bug 1791/1 1791/head 1800/target/1
authorluozheng <1732036298@qq.com>
Mon, 26 May 2025 08:24:53 +0000 (16:24 +0800)
committerluozheng <1732036298@qq.com>
Mon, 26 May 2025 08:24:53 +0000 (16:24 +0800)
2.解决滑动切换模型问题

code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp

index 027fc8c..a5bd0a1 100644 (file)
@@ -66,7 +66,7 @@ namespace OHOS
         uint8_t GetChatContentListCount(void);
 
         // 更新和清空问题及回答
-        void RemoveLastTwoItemsOrClear();
+        bool RemoveLastTwoItemsOrClear();
         bool UpdateUserQuestionStr(void);
         bool UpdateAiAnswerStr(void);
         void ClearQuestionAndAiAnswerStr(void);
index 0ec96aa..128cbcf 100644 (file)
@@ -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!!");
index c8afeb0..4e2be25 100644 (file)
@@ -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;
             }
         }