From a2d0b0dfbbe2b6d32fbfe08037486053cc25c109 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Wed, 25 Sep 2024 11:06:19 +0800 Subject: [PATCH] =?utf8?q?=E8=BF=9E=E6=8E=A5=E5=8A=A8=E7=94=BB=E6=B7=BB?= =?utf8?q?=E5=8A=A0=E5=88=A4=E6=96=AD=EF=BC=8C=E8=8B=A5=E5=8A=A8=E7=94=BB?= =?utf8?q?=E7=B1=BB=E4=B8=BA=E7=A9=BA=E5=88=99=E4=B8=8D=E6=B7=BB=E5=8A=A0?= =?utf8?q?=E5=88=B0=E5=85=B6=E7=88=B6=E8=A7=86=E5=9B=BEscrollview=E4=B8=8A?= =?utf8?q?=EF=BC=8C=E7=A1=AE=E4=BF=9D=E4=B8=8D=E4=BC=9A=E6=AD=BB=E6=9C=BA?= =?utf8?q?=20=E4=BF=AE=E6=94=B9=E9=80=9A=E7=94=A8=E5=8A=A8=E7=94=BB?= =?utf8?q?=E6=8E=A5=E5=8F=A3=EF=BC=8C=E8=8B=A5=E5=8A=A8=E7=94=BB=E8=B5=84?= =?utf8?q?=E6=BA=90=E5=9B=BE=E7=89=87=E7=BC=BA=E5=B0=91=E9=83=A8=E5=88=86?= =?utf8?q?=EF=BC=8C=E4=B8=8D=E5=BD=B1=E5=93=8D=E6=95=B4=E4=BD=93=E5=8A=A8?= =?utf8?q?=E7=94=BB=E6=92=AD=E6=94=BE=EF=BC=8C=E9=98=B2=E6=AD=A2=E5=9B=A0?= =?utf8?q?=E7=BC=BA=E5=B0=91=E4=B8=80=E5=BC=A0=E5=9B=BE=E7=89=87=E5=AF=BC?= =?utf8?q?=E8=87=B4=E6=AD=BB=E6=9C=BA=EF=BC=8C=E5=B7=B2=E9=AA=8C=E8=AF=81?= =?utf8?q?=E4=B8=8D=E4=BC=9A=E6=AD=BB=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../uicomponents/UIComponents.cpp | 11 +- .../aivoice/src/AiVoiceConnectingView.cpp | 148 +++++++++++++++--- 2 files changed, 129 insertions(+), 30 deletions(-) diff --git a/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.cpp b/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.cpp index c803f5ada..53343285e 100644 --- a/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.cpp +++ b/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.cpp @@ -737,11 +737,12 @@ namespace OHOS char buffer[256] = {0}; snprintf(buffer, sizeof(buffer), "%s%d.%s", basePath, i + 1, fileExtension); imageinfo_array[i] = ImageCacheManager::GetInstance().LoadSingleRes(buffer); - if (imageinfo_array[i] == nullptr) - { - UIFree(imageinfo_array); - return nullptr; // 检查内存分配是否成功 - } + // imageinfo_array[i] = ImageCacheManager::GetInstance().LoadSingleRes(buffer); + // if (imageinfo_array[i] == nullptr) + // { + // UIFree(imageinfo_array); + // return nullptr; // 检查内存分配是否成功 + // } } return imageinfo_array; } 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 c7ba00106..bba87193d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceConnectingView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceConnectingView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-08-03 11:10:08 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-09-03 19:06:26 + * @LastEditTime: 2024-09-25 10:42:10 * @FilePath: /xts_origin/FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceConnectingView.cpp */ #include "aivoice/include/AiVoiceConnectingView.h" @@ -152,11 +152,14 @@ namespace OHOS .textId = STR_CONNECTING, .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; - title = AiVoiceConnectingViewLabelInit(labelConfig); if (title == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "title new fail!"); - return false; + title = AiVoiceConnectingViewLabelInit(labelConfig); + if (title == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "title new fail!"); + return false; + } } /* -------------------------------------------------------------------------- */ labelConfig = { @@ -169,13 +172,16 @@ namespace OHOS .textId = STR_CANCEL, .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; - cancelLabel = AiVoiceConnectingViewLabelInit(labelConfig); if (cancelLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceBluetoothFailedStartView::cancelLabel is nullptr!"); - return false; + cancelLabel = AiVoiceConnectingViewLabelInit(labelConfig); + if (cancelLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceBluetoothFailedStartView::cancelLabel is nullptr!"); + return false; + } + cancelLabel->SetTextColor(Color::GetColorFromRGBA(0xfd, 0x52, 0x13, 0xff)); } - cancelLabel->SetTextColor(Color::GetColorFromRGBA(0xfd, 0x52, 0x13, 0xff)); return true; } @@ -190,11 +196,14 @@ namespace OHOS .h = 90, .viewId = AIVOICECONNECTINGVIEW_CANCEL_BUTTON_VIEW_ID, }; - cancelButton = AiVoiceConnectingViewButtonInit(buttonconfig); if (cancelButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cancelButton new fail!"); - return false; + cancelButton = AiVoiceConnectingViewButtonInit(buttonconfig); + if (cancelButton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cancelButton new fail!"); + return false; + } } UIView::OnTouchListener *touchListener = static_cast(AiVoicePresenter::GetInstance()); if (touchListener == nullptr) @@ -210,11 +219,14 @@ namespace OHOS bool AiVoiceConnectingView::CreateAivoiceConnectingImageAnimator(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAivoiceConnectingImageAnimator"); - 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; + 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 = { @@ -227,11 +239,14 @@ namespace OHOS .numFrames = AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES, .delay = AIVOICE_CONNECTING_IMAGE_ANIMATOR_DELAY, }; - connectingAnimatorView = connectingImageAnimatorInit(imageanimatorconfig); if (connectingAnimatorView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::connectingAnimatorView new fail"); - return false; + connectingAnimatorView = connectingImageAnimatorInit(imageanimatorconfig); + if (connectingAnimatorView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::connectingAnimatorView new fail"); + return false; + } } return true; @@ -240,11 +255,14 @@ namespace OHOS bool AiVoiceConnectingView::CreateAiVoiceConnectingScrollView(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAiVoiceConnectingScrollView"); - scrollView = new UIScrollView(); if (scrollView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceConnectTimeoutView::scrollView new fail!"); - return false; + scrollView = new UIScrollView(); + if (scrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceConnectTimeoutView::scrollView new fail!"); + return false; + } } UIView::OnDragListener *dragListener = static_cast(AiVoicePresenter::GetInstance()); if (dragListener == nullptr) @@ -263,11 +281,14 @@ namespace OHOS bool AiVoiceConnectingView::CreateAiVoiceConnectingScrollView(uint8_t type) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAiVoiceConnectingScrollView"); - scrollView = new UIScrollView(); if (scrollView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceConnectTimeoutView::scrollView new fail!"); - return false; + scrollView = new UIScrollView(); + if (scrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceConnectTimeoutView::scrollView new fail!"); + return false; + } } scrollView->SetPosition(0, 0, 466, 466); scrollView->SetTouchable(true); @@ -279,6 +300,7 @@ namespace OHOS UIScrollView *AiVoiceConnectingView::CreateAiVoiceConnectingView(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAiVoiceConnectingView"); +#if 0 if (!CreateAiVoiceConnectingScrollView() || !CreateAivoiceConnectingImageAnimator() || !CreateAiVoiceConnectingViewLabel() || !CreateAiVoiceConnectingViewButton()) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAiVoiceConnectingView fail!!"); @@ -290,11 +312,55 @@ namespace OHOS scrollView->Add(cancelLabel); return scrollView; +#else + if (!CreateAiVoiceConnectingScrollView()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAiVoiceConnectingScrollView fail!!"); + } + if (!CreateAivoiceConnectingImageAnimator()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAivoiceConnectingImageAnimator fail!!"); + } + if (!CreateAiVoiceConnectingViewLabel()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAiVoiceConnectingViewLabel fail!!"); + } + if (!CreateAiVoiceConnectingViewButton()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAiVoiceConnectingViewButton fail!!"); + } + +#endif + if (scrollView == nullptr) + { + return nullptr; + } + else + { + if (title) + { + scrollView->Add(title); + } + if (connectingAnimatorView) + { + scrollView->Add(connectingAnimatorView); + } + if (cancelButton) + { + scrollView->Add(cancelButton); + } + if (cancelLabel) + { + scrollView->Add(cancelLabel); + } + return scrollView; + } } UIScrollView *AiVoiceConnectingView::CreateAiVoiceConnectingView(uint8_t type) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAiVoiceConnectingView"); +#if 0 if (!CreateAiVoiceConnectingScrollView(type) || !CreateAivoiceConnectingImageAnimator() || !CreateAiVoiceConnectingViewLabel()) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAiVoiceConnectingView fail!!"); @@ -302,9 +368,41 @@ namespace OHOS } connectingAnimatorView->SetPosition(183, 183); connectingAnimatorView->Invalidate(); - ScreenTurnOn(30*1000);//亮屏30s + ScreenTurnOn(30 * 1000); // 亮屏30s scrollView->Add(connectingAnimatorView); - return scrollView; +#else + if (!CreateAiVoiceConnectingScrollView(type)) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAiVoiceConnectingScrollView fail!!"); + } + if (!CreateAivoiceConnectingImageAnimator()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAivoiceConnectingImageAnimator fail!!"); + } + if (!CreateAiVoiceConnectingViewLabel()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAiVoiceConnectingViewLabel fail!!"); + } + if (scrollView == nullptr) + { + return nullptr; + } + else + { + if (title) + { + scrollView->Add(title); + } + if (connectingAnimatorView) + { + connectingAnimatorView->SetPosition(183, 183); + connectingAnimatorView->Invalidate(); + scrollView->Add(connectingAnimatorView); + } + ScreenTurnOn(30 * 1000); // 亮屏30s + return scrollView; + } +#endif } } \ No newline at end of file -- 2.17.1