聆听中和思考中动画修改 2091/1 2091/head 2094/target/1 2095/target/1
authorluozheng <1732036298@qq.com>
Sat, 16 Aug 2025 03:57:33 +0000 (11:57 +0800)
committerluozheng <1732036298@qq.com>
Sat, 16 Aug 2025 03:57:33 +0000 (11:57 +0800)
code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceListeningView.h
code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceThinkingView.h
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceListeningView.cpp
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceThinkingView.cpp

index 8c35c3b..c620e77 100644 (file)
@@ -88,7 +88,6 @@ namespace OHOS
         UIButton *finishSpeakButton{nullptr};
         UIImageAnimatorView *AiVoiceListeningImageAnimatorView{nullptr};
         ImageAnimatorInfo AiVoiceListeningImageInfo[AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES];
-        const ImageInfo **AiVoiceListeningPathsArray{nullptr};
         UILabelExt *showtimeout{nullptr};
     };
 }
index 9f4bbd9..9bfdd78 100644 (file)
@@ -81,7 +81,6 @@ namespace OHOS
         UIButton *cancelThinkButton{nullptr};
         UIImageAnimatorView *AiVoiceThinkingImageAnimatorView{nullptr};
         ImageAnimatorInfo AiVoiceThinkingImageInfo[AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES];
-        const ImageInfo **AiVoiceThinkingPathsArray{nullptr};
     };
 }
 #endif
index 0e9186d..41e1b2b 100644 (file)
 // #include "common/image_cache_manager.h"
 namespace OHOS
 {
+    const char *listening_path_array[] = {
+        "/user/res/AIVoice/AIVoiceListening/1.bin",
+        "/user/res/AIVoice/AIVoiceListening/2.bin",
+        "/user/res/AIVoice/AIVoiceListening/3.bin",
+        "/user/res/AIVoice/AIVoiceListening/4.bin",
+        "/user/res/AIVoice/AIVoiceListening/5.bin",
+        "/user/res/AIVoice/AIVoiceListening/6.bin",
+        "/user/res/AIVoice/AIVoiceListening/7.bin",
+        "/user/res/AIVoice/AIVoiceListening/8.bin",
+        "/user/res/AIVoice/AIVoiceListening/9.bin",
+        "/user/res/AIVoice/AIVoiceListening/10.bin",
+        "/user/res/AIVoice/AIVoiceListening/11.bin",
+        "/user/res/AIVoice/AIVoiceListening/12.bin",
+        "/user/res/AIVoice/AIVoiceListening/13.bin",
+        "/user/res/AIVoice/AIVoiceListening/14.bin",
+        "/user/res/AIVoice/AIVoiceListening/15.bin",
+        "/user/res/AIVoice/AIVoiceListening/16.bin",
+        "/user/res/AIVoice/AIVoiceListening/17.bin",
+        "/user/res/AIVoice/AIVoiceListening/18.bin",
+        "/user/res/AIVoice/AIVoiceListening/19.bin",
+        "/user/res/AIVoice/AIVoiceListening/20.bin",
+        "/user/res/AIVoice/AIVoiceListening/21.bin",
+        "/user/res/AIVoice/AIVoiceListening/22.bin",
+        "/user/res/AIVoice/AIVoiceListening/23.bin",
+        "/user/res/AIVoice/AIVoiceListening/24.bin",
+        "/user/res/AIVoice/AIVoiceListening/25.bin",
+        "/user/res/AIVoice/AIVoiceListening/26.bin",
+        "/user/res/AIVoice/AIVoiceListening/27.bin",
+        "/user/res/AIVoice/AIVoiceListening/28.bin",
+        "/user/res/AIVoice/AIVoiceListening/29.bin",
+        "/user/res/AIVoice/AIVoiceListening/30.bin",
+        "/user/res/AIVoice/AIVoiceListening/31.bin",
+        "/user/res/AIVoice/AIVoiceListening/32.bin",
+        "/user/res/AIVoice/AIVoiceListening/33.bin",
+        "/user/res/AIVoice/AIVoiceListening/34.bin",
+        "/user/res/AIVoice/AIVoiceListening/35.bin",
+        "/user/res/AIVoice/AIVoiceListening/36.bin",
+        "/user/res/AIVoice/AIVoiceListening/37.bin",
+        "/user/res/AIVoice/AIVoiceListening/38.bin",
+        "/user/res/AIVoice/AIVoiceListening/39.bin",
+        "/user/res/AIVoice/AIVoiceListening/40.bin",
+    };
 
     static AivoiceListeningView *g_pAivoiceListeningView{nullptr};
 
@@ -53,8 +95,10 @@ namespace OHOS
                 AiVoiceListeningImageAnimatorView->Stop();
                 delete AiVoiceListeningImageAnimatorView;
                 AiVoiceListeningImageAnimatorView = nullptr;
-
-                FreeImageInfoArray(AiVoiceListeningPathsArray, AIVoiceListeningImagePaths, AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+                for (int i = 0; i < AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES; i++)
+                {
+                    ImageCacheManager::GetInstance().UnloadSingleRes(listening_path_array[i]);
+                }
             }
 
             if (showtimeout != nullptr)
@@ -252,32 +296,30 @@ namespace OHOS
     bool AivoiceListeningView::CreateAivoiceListeningImageAnimator(void)
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AivoiceListeningView::CreateAivoiceListeningImageAnimator");
-        AiVoiceListeningPathsArray = CreateImageInfoArray(AIVoiceListeningImagePaths, AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
-        if (AiVoiceListeningPathsArray == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceListeningView::AiVoiceListeningPathsArray  is nullptr!!");
-            return false;
-        }
-
-        ImageAnimatorConfig imageanimatorconfig = {
-            .x = AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_X,
-            .y = AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_Y,
-            .width = AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_W,
-            .height = AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_H,
-            .imageInfoArray = AiVoiceListeningImageInfo,
-            .pathsArray = AiVoiceListeningPathsArray,
-            .numFrames = AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES,
-            .delay = AIVOICE_LISTENING_IMAGE_ANIMATOR_DELAY,
-        };
         if (AiVoiceListeningImageAnimatorView == nullptr)
         {
-            AiVoiceListeningImageAnimatorView = AivoiceListeningImageAnimatorInit(imageanimatorconfig);
+            AiVoiceListeningImageAnimatorView = new UIImageAnimatorView();
             if (AiVoiceListeningImageAnimatorView == nullptr)
             {
-                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceListeningImageAnimatorView::AiVoiceListeningImageAnimatorView  new fail");
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlipayBindAni::AlipayInitImageAni new AI4GImageAni fail");
                 return false;
             }
         }
+        for (uint8_t i = 0; i < AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES; i++)
+        {
+            AiVoiceListeningImageInfo[i].imageInfo = ImageCacheManager::GetInstance().LoadSingleRes(listening_path_array[i]);
+            AiVoiceListeningImageInfo[i].imageType = IMG_SRC_IMAGE_INFO;
+            AiVoiceListeningImageInfo[i].pos.x = AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_X;
+            AiVoiceListeningImageInfo[i].pos.y = AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_Y;
+            AiVoiceListeningImageInfo[i].width = AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_W;
+            AiVoiceListeningImageInfo[i].height = AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_H;
+        }
+        AiVoiceListeningImageAnimatorView->SetPosition(AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_X, AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_Y,
+                                            AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_W, AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_H);
+        AiVoiceListeningImageAnimatorView->SetImageAnimatorSrc(AiVoiceListeningImageInfo, AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES, AIVOICE_LISTENING_IMAGE_ANIMATOR_DELAY);
+        AiVoiceListeningImageAnimatorView->SetRepeat(true);
+        AiVoiceListeningImageAnimatorView->SetAutoEnable(false);
+        AiVoiceListeningImageAnimatorView->SetResizeMode(UIImageView::FILL);
 
         return true;
     }
index a9c6021..c16e893 100644 (file)
 namespace OHOS
 {
 
+    const char *thinking_path_array[] = {
+        "/user/res/AIVoice/AIVoiceThinking/1.bin",
+        "/user/res/AIVoice/AIVoiceThinking/2.bin",
+        "/user/res/AIVoice/AIVoiceThinking/3.bin",
+        "/user/res/AIVoice/AIVoiceThinking/4.bin",
+        "/user/res/AIVoice/AIVoiceThinking/5.bin",
+        "/user/res/AIVoice/AIVoiceThinking/6.bin",
+        "/user/res/AIVoice/AIVoiceThinking/7.bin",
+        "/user/res/AIVoice/AIVoiceThinking/8.bin",
+        "/user/res/AIVoice/AIVoiceThinking/9.bin",
+        "/user/res/AIVoice/AIVoiceThinking/10.bin",
+        "/user/res/AIVoice/AIVoiceThinking/11.bin",
+        "/user/res/AIVoice/AIVoiceThinking/12.bin",
+        "/user/res/AIVoice/AIVoiceThinking/13.bin",
+        "/user/res/AIVoice/AIVoiceThinking/14.bin",
+        "/user/res/AIVoice/AIVoiceThinking/15.bin",
+        "/user/res/AIVoice/AIVoiceThinking/16.bin",
+        "/user/res/AIVoice/AIVoiceThinking/17.bin",
+        "/user/res/AIVoice/AIVoiceThinking/18.bin",
+        "/user/res/AIVoice/AIVoiceThinking/19.bin",
+        "/user/res/AIVoice/AIVoiceThinking/20.bin",
+        "/user/res/AIVoice/AIVoiceThinking/21.bin",
+        "/user/res/AIVoice/AIVoiceThinking/22.bin",
+        "/user/res/AIVoice/AIVoiceThinking/23.bin",
+        "/user/res/AIVoice/AIVoiceThinking/24.bin",
+        "/user/res/AIVoice/AIVoiceThinking/25.bin",
+        "/user/res/AIVoice/AIVoiceThinking/26.bin",
+        "/user/res/AIVoice/AIVoiceThinking/27.bin",
+        "/user/res/AIVoice/AIVoiceThinking/28.bin",
+        "/user/res/AIVoice/AIVoiceThinking/29.bin",
+        "/user/res/AIVoice/AIVoiceThinking/30.bin",
+        "/user/res/AIVoice/AIVoiceThinking/31.bin",
+        "/user/res/AIVoice/AIVoiceThinking/32.bin",
+        "/user/res/AIVoice/AIVoiceThinking/33.bin",
+        "/user/res/AIVoice/AIVoiceThinking/34.bin",
+        "/user/res/AIVoice/AIVoiceThinking/35.bin",
+        "/user/res/AIVoice/AIVoiceThinking/36.bin",
+        "/user/res/AIVoice/AIVoiceThinking/37.bin",
+        "/user/res/AIVoice/AIVoiceThinking/38.bin",
+        "/user/res/AIVoice/AIVoiceThinking/39.bin",
+        "/user/res/AIVoice/AIVoiceThinking/40.bin",
+    };
+
     static AivoiceThinkingView *g_pAivoiceThinkingView{nullptr};
 
     AivoiceThinkingView::AivoiceThinkingView()
@@ -54,8 +97,11 @@ namespace OHOS
                 delete AiVoiceThinkingImageAnimatorView;
                 AiVoiceThinkingImageAnimatorView = nullptr;
 
-                // FreeImagePathsArray(AiVoiceThinkingPathsArray, AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
-                FreeImageInfoArray(AiVoiceThinkingPathsArray, AIVoiceThinkingImagePaths, AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+                for (int i = 0; i < AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES; i++)
+                {
+                    ImageCacheManager::GetInstance().UnloadSingleRes(thinking_path_array[i]);
+                }
+
             }
 
             if (cancelThink != nullptr)
@@ -235,29 +281,30 @@ namespace OHOS
     bool AivoiceThinkingView::CreateAivoiceThinkingImageAnimator(void)
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AivoiceThinkingView::CreateAivoiceThinkingImageAnimator");
-        AiVoiceThinkingPathsArray = CreateImageInfoArray(AIVoiceThinkingImagePaths, AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
-        if (AiVoiceThinkingPathsArray == nullptr)
+        if (AiVoiceThinkingImageAnimatorView == nullptr)
         {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceThinkingView::AiVoiceThinkingPathsArray  is nullptr!!");
-            return false;
+            AiVoiceThinkingImageAnimatorView = new UIImageAnimatorView();
+            if (AiVoiceThinkingImageAnimatorView == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceThinkingView::AivoiceThinkingImageAnimatorView  new fail");
+                return false;
+            }
         }
-
-        ImageAnimatorConfig imageanimatorconfig = {
-            .x = AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_X,
-            .y = AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_Y,
-            .width = AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_W,
-            .height = AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_H,
-            .imageInfoArray = AiVoiceThinkingImageInfo,
-            .pathsArray = AiVoiceThinkingPathsArray,
-            .numFrames = AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES,
-            .delay = AIVOICE_THINKING_IMAGE_ANIMATOR_DELAY,
-        };
-        AiVoiceThinkingImageAnimatorView = AivoiceThinkingImageAnimatorInit(imageanimatorconfig);
-        if (AiVoiceThinkingImageAnimatorView == nullptr)
+        for (uint8_t i = 0; i < AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES; i++)
         {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceThinkingImageAnimatorView::AiVoiceThinkingImageAnimatorView  new fail");
-            return false;
+            AiVoiceThinkingImageInfo[i].imageInfo = ImageCacheManager::GetInstance().LoadSingleRes(thinking_path_array[i]);
+            AiVoiceThinkingImageInfo[i].imageType = IMG_SRC_IMAGE_INFO;
+            AiVoiceThinkingImageInfo[i].pos.x = AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_X;
+            AiVoiceThinkingImageInfo[i].pos.y = AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_Y;
+            AiVoiceThinkingImageInfo[i].width = AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_W;
+            AiVoiceThinkingImageInfo[i].height = AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_H;
         }
+        AiVoiceThinkingImageAnimatorView->SetPosition(AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_X, AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_Y,
+                                                      AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_W, AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_H);
+        AiVoiceThinkingImageAnimatorView->SetImageAnimatorSrc(AiVoiceThinkingImageInfo, AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES, AIVOICE_THINKING_IMAGE_ANIMATOR_DELAY);
+        AiVoiceThinkingImageAnimatorView->SetRepeat(true);
+        AiVoiceThinkingImageAnimatorView->SetAutoEnable(false);
+        AiVoiceThinkingImageAnimatorView->SetResizeMode(UIImageView::FILL);
 
         return true;
     }