4gAi:聆听中,思考中,连接中界面采用直接先创建方式 2255/1 2255/head 2256/target/1
authorcheng <chengyf@zhihuishixun.com>
Tue, 16 Sep 2025 06:39:48 +0000 (14:39 +0800)
committercheng <chengyf@zhihuishixun.com>
Tue, 16 Sep 2025 06:39:48 +0000 (14:39 +0800)
code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/include/AiVoiceConnectingView.h
code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/include/Aivoice4gServiceConView.h
code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AiVoiceConnectingView.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AiVoiceView.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/Aivoice4gServiceConView.cpp

index 2042f7f..d044ac0 100644 (file)
@@ -63,6 +63,7 @@ namespace OHOS
         static AiVoiceConnectingView *GetInstance(void);
         UIScrollView *CreateAiVoiceConnectingView(void);
         UIScrollView *CreateAiVoiceConnectingView(uint8_t);
+        void StartOrStopAiVoiceConnectingImageAnimatorView(bool val);
 
     private:
         UIImageAnimatorView *connectingImageAnimatorInit(ImageAnimatorConfig &imageanimatorconfig);
index 495e68a..1e451de 100644 (file)
@@ -14,6 +14,7 @@ namespace OHOS
         ~AiVoice4gServiceConView();
         static AiVoice4gServiceConView *GetInstance(void);
         UIScrollView *CreateAiVoice4gServiceConView(void);
+        void StartOrStopAiVoice4gServiceConImageAnimatorView(bool val);
 
     private:
         void ClearAll(void);
index 542b308..2b328cf 100644 (file)
@@ -201,7 +201,7 @@ namespace OHOS
         animatorView->SetSizeFixed(true);
         // animatorView->SetAutoEnable(false);
         // animatorView->SetResizeMode(UIImageAnimatorView::FILL);
-        animatorView->Start();
+        // animatorView->Start();
 
         return animatorView;
     }
@@ -310,11 +310,22 @@ namespace OHOS
         connectingAnimatorView->SetRepeat(true);
         connectingAnimatorView->SetAutoEnable(false);
         connectingAnimatorView->SetResizeMode(UIImageView::FILL);
-        connectingAnimatorView->Start();
+        // connectingAnimatorView->Start();
 
         return true;
     }
 
+    void AiVoiceConnectingView::StartOrStopAiVoiceConnectingImageAnimatorView(bool val)
+    {
+        if (connectingAnimatorView != nullptr)
+        {
+            if (val)
+                connectingAnimatorView->Start();
+            else
+                connectingAnimatorView->Stop();
+        }
+    }
+
     bool AiVoiceConnectingView::CreateAiVoiceConnectingScrollView(void)
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAiVoiceConnectingScrollView");
index dbcee4b..7f5ea7c 100644 (file)
@@ -522,6 +522,12 @@ namespace OHOS
     void AiVoiceView::OnStart()
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceView::OnStart");
+        ChangeView(MAX_AIVOICE_VIEWID, AIVOICE_AIMODE_CONNECTING);
+        GetAiVoiceScrollView(AIVOICE_AIMODE_CONNECTING)->SetVisible(false);
+        ChangeView(MAX_AIVOICE_VIEWID, AIVOICE_LISTENING_VIEWID);
+        GetAiVoiceScrollView(AIVOICE_LISTENING_VIEWID)->SetVisible(false);
+        ChangeView(MAX_AIVOICE_VIEWID, AIVOICE_THINKING_VIEWID);
+        GetAiVoiceScrollView(AIVOICE_THINKING_VIEWID)->SetVisible(false);
         ChangeView(MAX_AIVOICE_VIEWID, AIVOICE_STARTCHAT_VIEWID);
 #if defined(AI_VOICE_FD230) || defined(AI_VOICE_N9)
         CreateAiVoiceVoiceView();
@@ -824,6 +830,10 @@ namespace OHOS
             AiVoiceScrollView[thisView] = scrollview;
             AddViewToRootContainer(AiVoiceScrollView[thisView]);
         }
+        if(p_AiVoiceConnectingView)
+        {
+            p_AiVoiceConnectingView->StartOrStopAiVoiceConnectingImageAnimatorView(true);
+        }
         return true;
     }
 
@@ -870,6 +880,10 @@ namespace OHOS
             AiVoiceScrollView[thisView] = scrollview;
             AddViewToRootContainer(AiVoiceScrollView[thisView]);
         }
+        if(p_Aivoice4gServiceConView)
+        {
+            p_Aivoice4gServiceConView->StartOrStopAiVoice4gServiceConImageAnimatorView(true);
+        }
         return true;
     }
 
@@ -957,10 +971,10 @@ namespace OHOS
     }
 
     static const int16 AiVoiceDestroyMapper[] = {
-        AIVOICE_AIMODE_CONNECTING,
+        // AIVOICE_AIMODE_CONNECTING,
         AIVOICE_4GSERVICECON_VIEW,
-        AIVOICE_LISTENING_VIEWID,
-        AIVOICE_THINKING_VIEWID,
+        // AIVOICE_LISTENING_VIEWID,
+        // AIVOICE_THINKING_VIEWID,
         AIVOICE_SELECT_VIEW,
         AIVOICE_CONNECT_TIMEOUT_VIEWID,
         AIVOICE_AIMODEL_CONNECT_FAILED_VIEWID,
@@ -985,13 +999,15 @@ namespace OHOS
                 break;
             }
         }
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DestroyTempView:%d",hideView);
         switch (hideView)
         {
         case AIVOICE_AIMODE_CONNECTING:
             if (p_AiVoiceConnectingView)
             {
-                delete p_AiVoiceConnectingView;
-                p_AiVoiceConnectingView = nullptr;
+                // delete p_AiVoiceConnectingView;
+                // p_AiVoiceConnectingView = nullptr;
+                p_AiVoiceConnectingView->StartOrStopAiVoiceConnectingImageAnimatorView(false);
             }
             break;
         case AIVOICE_4GSERVICECON_VIEW:
@@ -999,20 +1015,23 @@ namespace OHOS
             {
                 delete p_Aivoice4gServiceConView;
                 p_Aivoice4gServiceConView = nullptr;
+                // p_Aivoice4gServiceConView->StartOrStopAiVoice4gServiceConImageAnimatorView(false);
             }
             break;
         case AIVOICE_LISTENING_VIEWID:
             if (p_AivoiceListeningView)
             {
-                delete p_AivoiceListeningView;
-                p_AivoiceListeningView = nullptr;
+                // delete p_AivoiceListeningView;
+                // p_AivoiceListeningView = nullptr;
+                p_AivoiceListeningView->StartOrStopAivoiceListeningImageAnimatorView(false);
             }
             break;
         case AIVOICE_THINKING_VIEWID:
             if (p_AivoiceThinkingView)
             {
-                delete p_AivoiceThinkingView;
-                p_AivoiceThinkingView = nullptr;
+                // delete p_AivoiceThinkingView;
+                // p_AivoiceThinkingView = nullptr;
+                p_AivoiceThinkingView->StartOrStopAiVoiceThinkingImageAnimatorView(false);
             }
             break;
         case AIVOICE_SELECT_VIEW:
index f51a412..2089b30 100644 (file)
@@ -131,4 +131,15 @@ namespace OHOS
 
         return scrollView;
     }
+
+    void AiVoice4gServiceConView::StartOrStopAiVoice4gServiceConImageAnimatorView(bool val)
+    {
+        if (AI4GImageAni != nullptr)
+        {
+            if (val)
+                AI4GImageAni->Start();
+            else
+                AI4GImageAni->Stop();
+        }
+    }
 }