1.解决ai界面重复添加组件问题 1917/1
authorluozheng <1732036298@qq.com>
Thu, 3 Jul 2025 01:41:47 +0000 (09:41 +0800)
committerluozheng <1732036298@qq.com>
Thu, 3 Jul 2025 01:41:47 +0000 (09:41 +0800)
2.解决同一个子界面切换黑屏问题

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

index ad97b1c..200e397 100644 (file)
@@ -982,9 +982,10 @@ namespace OHOS
         {
             AiVoiceModel::GetInstance().StopListenAndRecordingUserQuestion(); // 停止聆听用户问题
             AiVoiceModel::GetInstance().stop_listening_timer();               // 停止聆听定时器
-            if (AiVoiceView::GetInstance() && AivoiceListeningView::GetInstance())
+            AiVoicePresenter *p_AiVoicePresenter = AiVoicePresenter::GetInstance();
+            if (AiVoicePresenter::GetInstance() && AivoiceListeningView::GetInstance())
             {
-                AiVoiceView::GetInstance()->ChangeView(AIVOICE_LISTENING_VIEWID, AIVOICE_THINKING_VIEWID); // 切换到思考中界面
+                AiVoicePresenter::GetInstance()->ChangeViewAndLogicOperator(AIVOICE_LISTENING_VIEWID, AIVOICE_THINKING_VIEWID); // 切换到思考中界面
             }
         }
         else
index 01ffa30..5d3af13 100644 (file)
@@ -282,7 +282,12 @@ namespace OHOS
     bool AiVoicePresenter::ChangeViewAndLogicOperator(int16_t hideView, int16_t showView)
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::ChangeViewOperator");
-
+        bool isSameView = (hideView == showView);
+        if (isSameView)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Same view no need to change");
+            return false;
+        }
         if (hideView > MAX_AIVOICE_VIEWID)
         {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Overstep ones bounds");
@@ -412,7 +417,8 @@ namespace OHOS
             {
                 if (model->GetSelect4gorbt() == AI_SELECT_4G)
                 {
-                    model->cancel_tts_play();
+                    // model->cancel_tts_play();
+                    dinit_ai_task();
                     usleep(50000);
                 }
             }
@@ -771,7 +777,7 @@ namespace OHOS
     bool AiVoicePresenter::OnRotate(UIView &view, const RotateEvent &event)
     {
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::OnRotateEnd");
-        ChangeVolume(view,event);
+        ChangeVolume(view, event);
         return true;
     }
 
index d26ea4e..de29cd9 100644 (file)
@@ -485,22 +485,22 @@ namespace OHOS
                 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VolumeProcess new fail");
                 return false;
             }
+            VolumeProcess->SetSliderColor(Color::Gray(), Color::Silver());
+            VolumeProcess->SetPosition(-200, 77, 130, 310);
+            VolumeProcess->SetDirection(UISlider::Direction::DIR_BOTTOM_TO_TOP);
+            VolumeProcess->SetRange(100, 0);
+            VolumeProcess->SetStyle(STYLE_BORDER_RADIUS, 100);
+            VolumeProcess->SetBackgroundStyle(STYLE_LINE_CAP, CapType::CAP_ROUND);
+            VolumeProcess->SetForegroundStyle(STYLE_LINE_CAP, CapType::CAP_ROUND);
+            VolumeProcess->SetSliderColor(Color::GetColorFromRGBA(0x19, 0x19, 0x19, 0xff), Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff));
+            VolumeProcess->SetForegroundStyle(STYLE_BACKGROUND_OPA, 0xff);
+            VolumeProcess->SetKnobStyle(StyleDefault::GetSliderKnobStyle());
+            VolumeProcess->RequestFocus();
+            VolumeProcess->SetRotateFactor(1.0);
+            // VolumeProcess->SetVisible(false);
+            VolumeProcess->SetOnRotateListener(presenter_);
+            container_->Add(VolumeProcess);
         }
-        VolumeProcess->SetSliderColor(Color::Gray(), Color::Silver());
-        VolumeProcess->SetPosition(-200, 77, 130, 310);
-        VolumeProcess->SetDirection(UISlider::Direction::DIR_BOTTOM_TO_TOP);
-        VolumeProcess->SetRange(100, 0);
-        VolumeProcess->SetStyle(STYLE_BORDER_RADIUS, 100);
-        VolumeProcess->SetBackgroundStyle(STYLE_LINE_CAP, CapType::CAP_ROUND);
-        VolumeProcess->SetForegroundStyle(STYLE_LINE_CAP, CapType::CAP_ROUND);
-        VolumeProcess->SetSliderColor(Color::GetColorFromRGBA(0x19, 0x19, 0x19, 0xff), Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff));
-        VolumeProcess->SetForegroundStyle(STYLE_BACKGROUND_OPA, 0xff);
-        VolumeProcess->SetKnobStyle(StyleDefault::GetSliderKnobStyle());
-        VolumeProcess->RequestFocus();
-        VolumeProcess->SetRotateFactor(1.0);
-        // VolumeProcess->SetVisible(false);
-        VolumeProcess->SetOnRotateListener(presenter_);
-        container_->Add(VolumeProcess);
         return true;
     }