From: luozheng <1732036298@qq.com> Date: Thu, 7 Aug 2025 11:22:29 +0000 (+0800) Subject: 修改ai连接中动画逻辑,图片路径使用字符数组 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=refs%2Fchanges%2F2058%2Fhead;p=mirrors%2FFD230.git 修改ai连接中动画逻辑,图片路径使用字符数组 --- 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; }