From 5126453e856589bde395836ee8cc5340c45bd5dc Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Fri, 25 Oct 2024 18:28:05 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96=E5=80=92=E8=AE=A1=E6=97=B6?= =?utf8?q?=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91=EF=BC=8C=E5=87=8F=E5=B0=91?= =?utf8?q?=E8=AF=AF=E5=B7=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../bluetooth/src/BluetoothReconnectView.cpp | 4 +- .../nativeui/countdown/src/CountDownModel.cpp | 54 ++++++++----------- 2 files changed, 25 insertions(+), 33 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothReconnectView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothReconnectView.cpp index 382c093d8..34e79e2f1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothReconnectView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothReconnectView.cpp @@ -45,9 +45,11 @@ BluetoothReconnectView::~BluetoothReconnectView() bluetoothNameLabel = nullptr; } if(reconnectAnimator){ + reconnectAnimator->Stop(); delete reconnectAnimator; reconnectAnimator = nullptr; - FreeImageInfoArray(reconnectPathsArray, reconnectImagePaths, BLUETOOTH_RECONNECT_IMAGE_NUM); + if(reconnectPathsArray != nullptr) + FreeImageInfoArray(reconnectPathsArray, reconnectImagePaths, BLUETOOTH_RECONNECT_IMAGE_NUM); } delete group; group = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownModel.cpp index c15993234..d711f3620 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownModel.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-07 18:15:53 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-10-20 11:49:21 + * @LastEditTime: 2024-10-25 17:47:51 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownModel.cpp */ #include "countdown/include/CountDownModel.h" @@ -18,6 +18,7 @@ #include "uiservice/include/ui_service.h" #include "AppViewIDs.h" #include "NativeAbility.h" +#include namespace OHOS { /* -------------------------------------------------------------------------- */ @@ -175,7 +176,7 @@ namespace OHOS playerCtr->SetSource(*source); /* --------------------------------- 4.配置播放器 -------------------------------- */ playerCtr->SetAudioStreamType(AUDIO_STREAM_NOTIFICATION_SYSTEM); // 设置播放器的音频流类型 - playerCtr->Prepare(); // 准备播放器对象以播放音频。 + playerCtr->Prepare(); // 准备播放器对象以播放音频。 /* -------------------------------- 5.请求音频焦点 -------------------------------- */ AudioManager &amIntance = AudioManager::GetInstance(); sessionId = amIntance.MakeSessionId(); @@ -338,13 +339,13 @@ namespace OHOS } return false; } - //获取是否需要跳转到开始到计时界面 + // 获取是否需要跳转到开始到计时界面 bool CountDownModel::GetChanageToStartCountDownView() { return IsChanageToStartCountDownViewFlag; } - //设置是否需要跳转到开始到计时界面 + // 设置是否需要跳转到开始到计时界面 void CountDownModel::SetChanageToStartCountDownView(bool val) { IsChanageToStartCountDownViewFlag = val; @@ -360,14 +361,14 @@ namespace OHOS return false; } - //处理倒计时到期时的一些操作 + // 处理倒计时到期时的一些操作 void CountDownModel::HandCountDownEndOperator(void) { StartCountDownView *p_StartCountDownView = StartCountDownView::GetInstance(); if (p_StartCountDownView) { CountDown_StopTimer(); // 停止定时器 - ScreenTurnOn(5 * 1000); // 亮屏5s + uapi_set_screen_on_api(); // 点亮屏幕 CountDownModel::GetInstance()->RequestStartRingtone(); // 播放铃声 StartCountDownView::GetInstance()->GetPlayOrPauseToggleButton()->SetVisible(false); @@ -418,34 +419,20 @@ namespace OHOS */ static void CountDown_TimerCallbackProc(int data) { - StartCountDownView *p_StartCountDownView = StartCountDownView::GetInstance(); - // 检查倒计时是否结束 - if (CountDownModel::g_CountDownTimes <= 0) + if (CountDownModel::GetInstance()->CountDownViewIsExit()) // 如果已经退出了界面定时器还在跑,就先跳转Slice { - if (CountDownModel::GetInstance()->CountDownViewIsExit()) // 如果已经退出了界面定时器还在跑,就先跳转Slice - { - CountDownModel::GetInstance()->CountDown_StopTimer(); // 停止定时器 - CountDownModel::GetInstance()->SetChanageToStartCountDownView(true); - NativeAbility::GetInstance().EnterSlice(VIEW_MAIN_COUNTDOWN); - return; - } - else + CountDownModel::GetInstance()->CountDown_StopTimer(); // 停止定时器 + CountDownModel::GetInstance()->SetChanageToStartCountDownView(true); + NativeAbility::GetInstance().EnterSlice(VIEW_MAIN_COUNTDOWN); + } + else + { + StartCountDownView *p_StartCountDownView = StartCountDownView::GetInstance(); + if (p_StartCountDownView) { - if (p_StartCountDownView) - { - CountDownModel::GetInstance()->HandCountDownEndOperator(); - } + CountDownModel::GetInstance()->HandCountDownEndOperator(); } } - // else - // { - // if (p_StartCountDownView) - // { - // // 更新显示 - // p_StartCountDownView->GetShowCountDownTimelabel()->SetText(CountDownModel::GetInstance()->DisplayCountDownDuration()); - // } - // } - return; } @@ -454,8 +441,11 @@ namespace OHOS */ static void CountDown_TimerCallback(int data) { - CountDownModel::g_CountDownTimes--; // 每次回调减少1秒 - GraphicService::GetInstance()->PostGraphicEvent(std::bind(CountDown_TimerCallbackProc, data)); + CountDownModel::g_CountDownTimes--; // 每次回调减少1秒 + if (CountDownModel::g_CountDownTimes <= 0) // 检查倒计时是否结束 + { + GraphicService::GetInstance()->PostGraphicEvent(std::bind(CountDown_TimerCallbackProc, data)); + } } /* -- 2.17.1