From: luozheng <1732036298@qq.com> Date: Thu, 3 Jul 2025 01:41:47 +0000 (+0800) Subject: 1.解决ai界面重复添加组件问题 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=b4c14f88b3bcc9063cde583854daa26b6188ea62;p=mirrors%2FFD230.git 1.解决ai界面重复添加组件问题 2.解决同一个子界面切换黑屏问题 --- 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 ad97b1cb7..200e39739 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp @@ -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 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 01ffa305e..5d3af13da 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp @@ -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; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp index d26ea4e0f..de29cd93a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp @@ -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; }