From b04fd6e2a325a4527c274956383c1e722cac88e9 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Thu, 7 Aug 2025 19:22:29 +0800 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E6=94=B9ai=E8=BF=9E=E6=8E=A5=E4=B8=AD?= =?utf8?q?=E5=8A=A8=E7=94=BB=E9=80=BB=E8=BE=91=EF=BC=8C=E5=9B=BE=E7=89=87?= =?utf8?q?=E8=B7=AF=E5=BE=84=E4=BD=BF=E7=94=A8=E5=AD=97=E7=AC=A6=E6=95=B0?= =?utf8?q?=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../aivoice/include/AiVoiceConnectingView.h | 1 - .../aivoice/src/AiVoiceConnectingView.cpp | 109 ++++++++++++++---- 2 files changed, 86 insertions(+), 24 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceConnectingView.h b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceConnectingView.h index 4f69a4e44..2042f7f7b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceConnectingView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceConnectingView.h @@ -80,7 +80,6 @@ namespace OHOS UIButton *cancelButton{nullptr}; UIImageAnimatorView *connectingAnimatorView{nullptr}; ImageAnimatorInfo connectingImageInfo[AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES]; - const ImageInfo **connectingPathsArray{nullptr}; }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceConnectingView.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceConnectingView.cpp index 98b314e63..76bace2fc 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceConnectingView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceConnectingView.cpp @@ -21,6 +21,69 @@ namespace OHOS static constexpr int16_t AIVOICE_CONNECTING_IMAGE_ANIMATOR_DELAY = 50; // 图片更新间隔 static constexpr const char *AIVoiceListeningImagePaths = "/user/res/connect/"; + const char *connecting_path_array[] = { + "/user/res/connect/1.bin", + "/user/res/connect/2.bin", + "/user/res/connect/3.bin", + "/user/res/connect/4.bin", + "/user/res/connect/5.bin", + "/user/res/connect/6.bin", + "/user/res/connect/7.bin", + "/user/res/connect/8.bin", + "/user/res/connect/9.bin", + "/user/res/connect/10.bin", + "/user/res/connect/11.bin", + "/user/res/connect/12.bin", + "/user/res/connect/13.bin", + "/user/res/connect/14.bin", + "/user/res/connect/15.bin", + "/user/res/connect/16.bin", + "/user/res/connect/17.bin", + "/user/res/connect/18.bin", + "/user/res/connect/19.bin", + "/user/res/connect/20.bin", + "/user/res/connect/21.bin", + "/user/res/connect/22.bin", + "/user/res/connect/23.bin", + "/user/res/connect/24.bin", + "/user/res/connect/25.bin", + "/user/res/connect/26.bin", + "/user/res/connect/27.bin", + "/user/res/connect/28.bin", + "/user/res/connect/29.bin", + "/user/res/connect/30.bin", + "/user/res/connect/31.bin", + "/user/res/connect/32.bin", + "/user/res/connect/33.bin", + "/user/res/connect/34.bin", + "/user/res/connect/35.bin", + "/user/res/connect/36.bin", + "/user/res/connect/37.bin", + "/user/res/connect/38.bin", + "/user/res/connect/39.bin", + "/user/res/connect/40.bin", + "/user/res/connect/41.bin", + "/user/res/connect/42.bin", + "/user/res/connect/43.bin", + "/user/res/connect/44.bin", + "/user/res/connect/45.bin", + "/user/res/connect/46.bin", + "/user/res/connect/47.bin", + "/user/res/connect/48.bin", + "/user/res/connect/49.bin", + "/user/res/connect/50.bin", + "/user/res/connect/51.bin", + "/user/res/connect/52.bin", + "/user/res/connect/53.bin", + "/user/res/connect/54.bin", + "/user/res/connect/55.bin", + "/user/res/connect/56.bin", + "/user/res/connect/57.bin", + "/user/res/connect/58.bin", + "/user/res/connect/59.bin", + "/user/res/connect/60.bin", + }; + static AiVoiceConnectingView *g_pAiVoiceConnecting{nullptr}; AiVoiceConnectingView::AiVoiceConnectingView() { @@ -50,7 +113,10 @@ namespace OHOS connectingAnimatorView->Stop(); delete connectingAnimatorView; connectingAnimatorView = nullptr; - FreeImageInfoArray(connectingPathsArray, AIVoiceListeningImagePaths, AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); + for (int i = 0; i < AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES; i++) + { + ImageCacheManager::GetInstance().UnloadSingleRes(connecting_path_array[i]); + } } if (cancelLabel) { @@ -220,35 +286,32 @@ namespace OHOS bool AiVoiceConnectingView::CreateAivoiceConnectingImageAnimator(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAivoiceConnectingImageAnimator"); - if (connectingPathsArray == nullptr) - { - connectingPathsArray = CreateImageInfoArray(AIVoiceListeningImagePaths, AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); - if (connectingPathsArray == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::connectingPathsArray is nullptr!!"); - return false; - } - } - - ImageAnimatorConfig imageanimatorconfig = { - .x = AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_X, - .y = AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_Y, - .width = AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_W, - .height = AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_H, - .imageInfoArray = connectingImageInfo, - .pathsArray = connectingPathsArray, - .numFrames = AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES, - .delay = AIVOICE_CONNECTING_IMAGE_ANIMATOR_DELAY, - }; if (connectingAnimatorView == nullptr) { - connectingAnimatorView = connectingImageAnimatorInit(imageanimatorconfig); + connectingAnimatorView = new UIImageAnimatorView(); if (connectingAnimatorView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::connectingAnimatorView new fail"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAivoiceConnectingImageAnimator new connectingAnimatorView fail"); return false; } } + for (uint8_t i = 0; i < AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES; i++) + { + connectingImageInfo[i].imageInfo = ImageCacheManager::GetInstance().LoadSingleRes(connecting_path_array[i]); + connectingImageInfo[i].imageType = IMG_SRC_IMAGE_INFO; + connectingImageInfo[i].pos.x = AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_X; + connectingImageInfo[i].pos.y = AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_Y; + connectingImageInfo[i].width = AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_W; + connectingImageInfo[i].height = AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_H; + } + connectingAnimatorView->SetPosition(AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_X, AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_Y, + AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_W, AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_H); + connectingAnimatorView->SetImageAnimatorSrc(connectingImageInfo, AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES, AIVOICE_CONNECTING_IMAGE_ANIMATOR_DELAY); + connectingAnimatorView->SetRepeat(true); + connectingAnimatorView->SetAutoEnable(false); + connectingAnimatorView->SetResizeMode(UIImageView::FILL); + scrollView->Add(connectingAnimatorView); + connectingAnimatorView->Start(); return true; } -- 2.17.1