* @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"
.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 = {
.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;
}
.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<UIView::OnTouchListener *>(AiVoicePresenter::GetInstance());
if (touchListener == nullptr)
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 = {
.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;
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<UIView::OnDragListener *>(AiVoicePresenter::GetInstance());
if (dragListener == nullptr)
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);
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!!");
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!!");
}
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