From: luozheng <1732036298@qq.com> Date: Tue, 9 Apr 2024 12:28:39 +0000 (+0800) Subject: 解决秒表视图到达最高记录时间未出现弹窗视图问题 X-Git-Tag: release_V1.2.70_20241020_135402~1189^2~28 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=37aa8c8e362b96383779777ec7d1c2ebf76e17db;p=mirrors%2FFD230.git 解决秒表视图到达最高记录时间未出现弹窗视图问题 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/MainStopWatchView.h b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/MainStopWatchView.h index e65e9b7ad..d4b9f0a60 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/MainStopWatchView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/MainStopWatchView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-04 15:13:51 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-07 10:04:54 + * @LastEditTime: 2024-04-09 20:22:12 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/MainStopWatchView.h */ #ifndef MAIN_STOPWATCH_VIEW_H @@ -54,6 +54,8 @@ namespace OHOS bool ChangeStopWatchRecordCycleLimit(int16_t thisView); bool ChangeMainStopWatchRecordTimeLimit(int16_t thisView); UILabelExt *GetShowTimelabel(void); + UICheckBox *GetPlayOrPausecheckBox(void); + void ChangeRecordTimeToLimitView(void); private: void InitMainStopWatchView(void); void ClearAll(void); diff --git a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchView.cpp b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchView.cpp index abfe10889..b2d8ba4b6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchView.cpp @@ -358,6 +358,17 @@ namespace OHOS return showTimelabel; } + UICheckBox *MainStopWatchView::GetPlayOrPausecheckBox(void) + { + return PlayOrPausecheckBox; + } + + /*切换到记录时间到达上线视图*/ + void MainStopWatchView::ChangeRecordTimeToLimitView(void) + { + ChangeView(MAIN_STOPWATCH, STOPWATCH_RECORD_TIME_TO_LIMIT); + } + void MainStopWatchView::OnStart() { View::OnStart(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/StopWatchModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/StopWatchModel.cpp index 0a387957f..3b64f189e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/StopWatchModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/StopWatchModel.cpp @@ -19,13 +19,14 @@ namespace OHOS // 声明定时器变量 static osTimerId_t g_timer = NULL; static int g_StopWatchTimes = {0}; - static constexpr int32 NUM_TEN = 10; + static constexpr int32 NUM_TEN = 10; // 主要用于格式化输出,当小时、分钟或秒小于10时,在其前面添加一个’0’以保持常规时间格式 static constexpr int16 ERROR = 0; static constexpr int16 SUCCESS = 1; static constexpr int16 NUM_TIME_MIN = 60; static constexpr int16 NUM_TIME_HOUR = 3600; static constexpr int32 NUM_TIME_DAY = 86400; - static uint64_t g_timerStartTimestamp = 0; // 添加一个全局变量来存储定时器开始的时间戳 + static constexpr int32 MAX_NUM_TIME = (99 * 60 * 1000) + (59 * 1000) + 990; // 99分59秒990毫秒 + static uint64_t g_timerStartTimestamp = 0; // 添加一个全局变量来存储定时器开始的时间戳 /* * @brief 显示倒计时(分钟、秒、毫秒),毫秒显示为两位数 */ @@ -101,7 +102,15 @@ namespace OHOS return; } - MainStopWatchView::GetInstance()->GetShowTimelabel()->SetText(StopWatchModel::GetInstance()->DisplayStopWatchDuration()); + if ((g_StopWatchTimes) >= MAX_NUM_TIME) // 5999990 = 99分59秒99的毫秒数 + { + MainStopWatchView::GetInstance()->GetPlayOrPausecheckBox()->SetState(UICheckBox::UNSELECTED); + MainStopWatchView::GetInstance()->ChangeRecordTimeToLimitView(); + } + else + { + MainStopWatchView::GetInstance()->GetShowTimelabel()->SetText(StopWatchModel::GetInstance()->DisplayStopWatchDuration()); + } } /* @@ -109,24 +118,6 @@ namespace OHOS */ static void StopWatch_TimerCallback(int data) { -#if 0 - uint64_t currentTimestamp = GetCurrentTimestamp(); - if ((currentTimestamp - g_timerStartTimestamp) >= 5999990) // 99分59秒99的毫秒数 - { - if (g_timer != NULL) - { - osTimerStop(g_timer); // 停止定时器 - osTimerDelete(g_timer); // 删除定时器 - g_timer = NULL; - g_timerStartTimestamp = 0; // 重置时间戳 - // 可以在这里添加额外的逻辑,比如更新界面显示等 - } - } - else - { - GraphicService::GetInstance()->PostGraphicEvent(std::bind(StopWatch_TimerCallbackProc, data)); - } -#endif GraphicService::GetInstance()->PostGraphicEvent(std::bind(StopWatch_TimerCallbackProc, data)); } @@ -156,7 +147,7 @@ namespace OHOS int tick = osMs2Tick(interval); /* --------------------------------- 4.启动定时器 -------------------------------- */ - //g_timerStartTimestamp = GetCurrentTimestamp(); // 假设GetCurrentTimestamp()是获取当前时间戳的函数 + // g_timerStartTimestamp = GetCurrentTimestamp(); // 假设GetCurrentTimestamp()是获取当前时间戳的函数 osStatus_t ret = osTimerStart(g_timer, tick); /* -------------------- 5.检查定时器启动是否成功,如果启动失败,删除定时器并置为 NULL -------------------- */ if (ret != osOK)