From: luozheng <1732036298@qq.com> Date: Sun, 20 Oct 2024 10:53:41 +0000 (+0800) Subject: 录音刷新采用Notify刷新UI而不再使用timer刷新 X-Git-Tag: fd230_release_V1.3.102~188^2~34 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=c45a1783eeb3ee4d1b44a0a8cf76c32b7acd6695;p=mirrors%2FFD230.git 录音刷新采用Notify刷新UI而不再使用timer刷新 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingPresenter.h index 80b6fe24e..5d29727b1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingPresenter.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-02-27 09:16:51 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-28 15:44:25 + * @LastEditTime: 2024-10-20 17:08:05 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/record/include/RecordingPresenter.h */ @@ -16,6 +16,7 @@ #include "common/key_code.h" #include "record/include/RecordingModel.h" #include +#include "ModelListenerSample.h" namespace OHOS { /*正在录音视图*/ @@ -115,7 +116,8 @@ namespace OHOS class RecordingPresenter : public Presenter, public UIView::OnClickListener, public RootView::OnKeyActListener, - public UIView::OnDragListener + public UIView::OnDragListener, + public ModelListenerSample { public: RecordingPresenter(); @@ -136,6 +138,7 @@ namespace OHOS bool OnDrag(UIView &view, const DragEvent &event) override; bool OnDragEnd(UIView &view, const DragEvent &event) override; bool OnKeyAct(UIView &view, const KeyEvent &event) override; + void Notify() override; void SetCircleProgress(); void StartRecord(void); void StopRecord(void); diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingModel.cpp index a1bf8d5a0..bbabf12f2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingModel.cpp @@ -980,6 +980,7 @@ namespace OHOS */ static void Recording_TimerCallbackProc(int data) { + #if 0 g_RecordingTimes++; WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "g_RecordingTimes:%d\n", g_RecordingTimes); @@ -1002,6 +1003,7 @@ namespace OHOS } RecordGoingView::GetInstance()->GetRecordingDurationLabel()->SetText(RecordingModel::GetInstance()->DisplayRecordDuration()); + #endif } /* @@ -1009,7 +1011,9 @@ namespace OHOS */ static void Recording_TimerCallback(int data) { - GraphicService::GetInstance()->PostGraphicEvent(std::bind(Recording_TimerCallbackProc, data)); + g_RecordingTimes++; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "g_RecordingTimes:%d\n", g_RecordingTimes); + // GraphicService::GetInstance()->PostGraphicEvent(std::bind(Recording_TimerCallbackProc, data)); } /* diff --git a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingPresenter.cpp index 46f71344a..d6a1544b3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingPresenter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-30 09:14:38 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-10-14 19:26:52 + * @LastEditTime: 2024-10-20 17:14:02 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordingPresenter.cpp */ @@ -300,6 +300,19 @@ namespace OHOS return true; } + void RecordingPresenter::Notify() + { + //如果是在正在录音视图且正在录音视图为可见 + if(view_->GetRecordingViewScrollView(RECORDGOINGVIEW) && view_->GetRecordingViewScrollView(RECORDGOINGVIEW)->IsVisible()) + { + if(RecordGoingView::GetInstance()->GetRecordingDurationLabel()) + { + RecordGoingView::GetInstance()->GetRecordingDurationLabel()->SetText(RecordingModel::GetInstance()->DisplayRecordDuration()); + } + } + } + + void RecordingPresenter::SetCircleProgress() { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingPresenter::SetCircleProgress");