From d369f0f752727c9e195a6e3b3b236818fbf0aded Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E8=A2=81=E6=B8=85=E6=A2=A6?= <3449750381@qq.com> Date: Thu, 13 Jun 2024 10:28:44 +0000 Subject: [PATCH] Merge #274 into sdk602patch0521 from refs/changes/274/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from 袁清梦 * refs/changes/274/head: (5 commits squashed) - 优化训练死机bug - Merge branch 'sdk602patch0521' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - 修复心率血氧数据json的时间戳 - Merge branch 'sdk602patch0521' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - Merge branch 'sdk602patch0521' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 Signed-off-by: Caisking <3449750381@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/274 --- .../include/BloodOxygenPresenter.h | 10 +- .../bloodoxygen/src/BloodOxygenPresenter.cpp | 32 +++---- .../health_service/health_service.cpp | 91 ++++++++++--------- .../heart_blood/src/BloodCardView.cpp | 8 +- .../heartrate/include/HeartPresenter.h | 4 +- .../nativeui/heartrate/src/HeartModel.cpp | 2 +- .../nativeui/heartrate/src/HeartPresenter.cpp | 32 +++++-- .../traing/src/TraingEnddataPresenter.cpp | 12 ++- .../nativeui/traing/src/TraingEnddataView.cpp | 15 ++- .../nativeui/traing/src/TraingModel.cpp | 5 +- .../src/TraingAquaticView.cpp | 6 +- .../training_list_ball/src/TraingBallView.cpp | 6 +- .../src/TraingDanceView.cpp | 6 +- .../src/TraingFitnessView.cpp | 6 +- .../training_list_ice/src/TraingIceView.cpp | 6 +- .../src/TraingLimitView.cpp | 6 +- .../training_list_more/src/TraingMoreView.cpp | 6 +- .../src/TraingOtherView.cpp | 6 +- .../training_list_rest/src/TraingRestView.cpp | 6 +- .../src/TraingRecordPresenter.cpp | 3 +- .../traingrecord/src/TraingRecordView.cpp | 6 -- 21 files changed, 152 insertions(+), 122 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenPresenter.h index 3324fe354..aed3211fa 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenPresenter.h @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-04-15 10:55:58 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-06-13 17:05:26 + * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenPresenter.h + */ /* * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. @@ -52,8 +58,8 @@ namespace OHOS bool OnClick(UIView &view, const ClickEvent &event) override; bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 - uint64_t GetCurrentTime(); - int GetTDOA(uint64_t new_time, uint64_t old_time); + uint32_t GetCurrentTime(); + int GetTDOA(uint32_t new_time, uint32_t old_time); private: bool CheckPointersValue(void); diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp index 7956aefc7..8847d7653 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp @@ -43,33 +43,29 @@ namespace OHOS static constexpr uint16_t PROGRESS_VALUE_MAX = 10; static BloodOxygenPresenter *g_pMainView; /* -------------------------------------------------------------------------- */ - // 获取当前的"时间分" - uint64_t BloodOxygenPresenter::GetCurrentTime() + // 获取当前的时间戳 + uint32_t BloodOxygenPresenter::GetCurrentTime() { - - // time_t now = time(0); - // struct tm *tblock = localtime(&now); - - /*优化为更安全的localtime_r()*/ - struct timeval tv; - gettimeofday(&tv, NULL); - struct tm tblock; - localtime_r(&tv.tv_sec, &tblock); - - uint64_t current_time = tblock.tm_hour * 60 + tblock.tm_min; - return current_time; + uint32_t time; + if (uapi_get_timestampe_ss(&time) != ERRCODE_SUCC) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to get timestamp"); + return 0; + } + return time; } // 获取时间差,现在传进来的是两个时间戳 - int BloodOxygenPresenter::GetTDOA(uint64_t new_time, uint64_t old_time) + int BloodOxygenPresenter::GetTDOA(uint32_t new_time, uint32_t old_time) { if (new_time == old_time || old_time > new_time) { return 0; } - - int time_diff = new_time - old_time; - return time_diff; + int time_diff_seconds = new_time - old_time; + // 转换为分钟的差值 + int time_diff_minutes = time_diff_seconds / 60; + return time_diff_minutes; } /* -------------------------------------------------------------------------- */ diff --git a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.cpp b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.cpp index 09d869f24..6dc6d0e8b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.cpp @@ -7,11 +7,9 @@ #include namespace OHOS { - static HealthService *g_pHealthService = nullptr; - static constexpr const char *HEALTH_JSON_PATH_HEART = "/user/userdata/health/heart/"; - - static constexpr const char *HEALTH_JSON_PATH_OXYGEN = "/user/userdata/health/oxygen/"; + static HealthService *g_pHealthService = nullptr; + /*获取日期*/ std::string GetCurrentDate() { time_t now = time(0); @@ -20,17 +18,7 @@ namespace OHOS strftime(date, sizeof(date), "%Y%m%d", ltm); return std::string(date); } - //static char *JSON_F_buf=NULL; - const char *GET_HEALTH_JSON_PATH_C_STR_HEART() - { - return HEALTH_JSON_PATH_HEART; - } - - const char *GET_HEALTH_JSON_PATH_C_STR_OXYGEN() - { - return HEALTH_JSON_PATH_OXYGEN; - } - + // static char *JSON_F_buf=NULL; cJSON *heart_root = NULL; cJSON *oxygen_root = NULL; HealthService::HealthService() @@ -38,46 +26,61 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HealthService::HealthService"); g_pHealthService = this; } - HealthService::~HealthService() { g_pHealthService = nullptr; } - HealthService *HealthService::GetInstance() { static HealthService instance; return &instance; } + + static constexpr const char *HEALTH_JSON_PATH = "/user/userdata/health/"; + static constexpr const char *HEALTH_JSON_PATH_HEART = "/user/userdata/health/heart/"; + static constexpr const char *HEALTH_JSON_PATH_OXYGEN = "/user/userdata/health/oxygen/"; + /* --------------------------------- 文件IO操作 --------------------------------- */ /*创建文件夹*/ bool HealthService::CreateHealthFolder() { struct stat info; + // 判断HEALTH_JSON_PATH是否存在 不存在就创建 + if (stat(HEALTH_JSON_PATH, &info) != 0) + { + if (mkdir(HEALTH_JSON_PATH, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "mkdir HEALTH_JSON_PATH is error"); + return false; // Failed to create folder + } + } + // 判断HEALTH_JSON_PATH_HEART是否存在 不存在就创建 if (stat(HEALTH_JSON_PATH_HEART, &info) != 0) { if (mkdir(HEALTH_JSON_PATH_HEART, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "mkdir HEALTH_JSON_PATH_HEART is error"); return false; // Failed to create folder } } + // 判断HEALTH_JSON_PATH_OXYGEN是否存在 不存在就创建 if (stat(HEALTH_JSON_PATH_OXYGEN, &info) != 0) { if (mkdir(HEALTH_JSON_PATH_OXYGEN, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "mkdir HEALTH_JSON_PATH_OXYGEN is error"); return false; // Failed to create folder } } return true; } - /*获取日期*/ - /*生成文件*/ std::string GetJsonFilePath(uint8_t type) { std::string currentDate = GetCurrentDate(); - if(type==HEALTH_TYPE_HEART) + + if (type == HEALTH_TYPE_HEART) { return std::string(HEALTH_JSON_PATH_HEART) + currentDate + ".json"; } @@ -85,28 +88,31 @@ namespace OHOS { return std::string(HEALTH_JSON_PATH_OXYGEN) + currentDate + ".json"; } - } - - + const char *GET_HEALTH_JSON_PATH_C_STR_HEART() + { + return HEALTH_JSON_PATH_HEART; + } + const char *GET_HEALTH_JSON_PATH_C_STR_OXYGEN() + { + return HEALTH_JSON_PATH_OXYGEN; + } bool HealthService::LoadJsonData(uint8_t type) { // 创建健康数据文件夹 - - if(!CreateHealthFolder()) + if (!CreateHealthFolder()) { return false; } - - // 获取当天日期对应的JSON文件路径 std::string jsonFilePath = GetJsonFilePath(type); std::ifstream inFile(jsonFilePath); - cJSON *defaultJson=NULL; + cJSON *defaultJson = NULL; if (!inFile.is_open()) { +#if 0 // 如果文件不存在,则创建一个包含默认值的JSON文件 - if(type==HEALTH_TYPE_HEART) + if (type == HEALTH_TYPE_HEART) { defaultJson = cJSON_Parse("{\ \"heart_latest_data\": {\ @@ -121,7 +127,7 @@ namespace OHOS ]\ }"); } - else if(type==HEALTH_TYPE_OXYGEN) + else if (type == HEALTH_TYPE_OXYGEN) { defaultJson = cJSON_Parse("{\ \"spo2_latest_data\": {\ @@ -136,7 +142,6 @@ namespace OHOS ]\ }"); } - std::ofstream outFile(jsonFilePath); if (!outFile.is_open()) { @@ -148,21 +153,20 @@ namespace OHOS cJSON_free(defaultJsonString); cJSON_Delete(defaultJson); inFile.open(jsonFilePath); // 重新打开文件 +#endif } // 读取JSON文件内容 std::string jsonDataString((std::istreambuf_iterator(inFile)), std::istreambuf_iterator()); const char *jsonData = jsonDataString.c_str(); - if(type==HEALTH_TYPE_HEART) + if (type == HEALTH_TYPE_HEART) { - heart_root = cJSON_Parse(jsonData); + heart_root = cJSON_Parse(jsonData); } - if(type==HEALTH_TYPE_OXYGEN) + if (type == HEALTH_TYPE_OXYGEN) { - oxygen_root = cJSON_Parse(jsonData); + oxygen_root = cJSON_Parse(jsonData); } - - return true; } #if 0 @@ -224,7 +228,8 @@ namespace OHOS HeartRateData *data = new HeartRateData(); cJSON *latestData = cJSON_GetObjectItem(heart_root, "heart_latest_data"); data->Heart = cJSON_GetObjectItem(latestData, "value")->valueint; - data->timestamp = cJSON_GetObjectItem(latestData, "timestamp")->valuedouble; + data->timestamp = cJSON_GetObjectItem(latestData, "timestamp")->valueint; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ReadHeartRateData: value %d timestamp%d", data->Heart, data->timestamp); cJSON_Delete(heart_root); return data; } @@ -269,7 +274,7 @@ namespace OHOS return true; } - bool HealthService::UpdateJsonData( uint8_t type) + bool HealthService::UpdateJsonData(uint8_t type) { std::string jsonFilePath = GetJsonFilePath(type); std::ofstream outFile(jsonFilePath); @@ -277,12 +282,12 @@ namespace OHOS { return false; } - char *jsonData=NULL; + char *jsonData = NULL; - if(type==HEALTH_TYPE_HEART) - jsonData = cJSON_Print(heart_root); + if (type == HEALTH_TYPE_HEART) + jsonData = cJSON_Print(heart_root); else - jsonData = cJSON_Print(oxygen_root); + jsonData = cJSON_Print(oxygen_root); if (jsonData == NULL) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/src/BloodCardView.cpp b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/src/BloodCardView.cpp index 467a93042..0bf068761 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/src/BloodCardView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/src/BloodCardView.cpp @@ -47,8 +47,8 @@ namespace OHOS std::string bloodoxygenStr = std::to_string(spo2_); bloodLabel->SetText(bloodoxygenStr.c_str()); // 更新时间 - uint64_t time = BloodOxygenPresenter::GetInstance()->GetCurrentTime(); - uint64_t check_time = BloodOxygenModel::GetInstance()->GetCheckTime(); + uint32_t time = BloodOxygenPresenter::GetInstance()->GetCurrentTime(); + uint32_t check_time = BloodOxygenModel::GetInstance()->GetCheckTime(); std::string TimeStr = BloodOxygenPresenter::GetInstance()->GetTDOA(time, check_time) + "检测"; timeLabel->SetText(TimeStr.c_str()); } @@ -118,8 +118,8 @@ namespace OHOS if (bloodoxygen != 0) { // 更新时间 - uint64_t time = BloodOxygenPresenter::GetInstance()->GetCurrentTime(); - uint64_t check_time = BloodOxygenModel::GetInstance()->GetCheckTime(); + uint32_t time = BloodOxygenPresenter::GetInstance()->GetCurrentTime(); + uint32_t check_time = BloodOxygenModel::GetInstance()->GetCheckTime(); std::string TimeStr = BloodOxygenPresenter::GetInstance()->GetTDOA(time, check_time) + "检测"; timeLabel->SetText(TimeStr.c_str()); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartPresenter.h index 970ae3e75..d0916d20e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartPresenter.h @@ -49,8 +49,8 @@ namespace OHOS bool OnClick(UIView &view, const ClickEvent &event) override; bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 - uint64_t GetCurrentTime(); - int GetTDOA(uint64_t new_time, uint64_t old_time); + uint32_t GetCurrentTime(); + int GetTDOA(uint32_t new_time, uint32_t old_time); private: bool CheckPointersValue(void); diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp index dd5f1e993..62bdf93e7 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp @@ -630,7 +630,7 @@ namespace OHOS HeartRateData *data = new HeartRateData; data->Heart = heart; data->timestamp = HeartPresenter::GetInstance()->GetCurrentTime(); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%d %lld", heart, data->timestamp); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%d %d", heart, data->timestamp); SetCheckTime(data->timestamp); HealthService::GetInstance()->UpdateHeartRateData(*data); // 更新卡片心率值 diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartPresenter.cpp index 323581252..42f7da653 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartPresenter.cpp @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-04-17 16:49:23 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-06-13 17:09:11 + * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartPresenter.cpp + */ #include "common/task_manager.h" #include "components/ui_label.h" @@ -27,6 +33,7 @@ #include "heartrate/include/HeartBandoffView.h" #include "health_service.h" #include "cywee_service.h" +#include "custom_utils.h" #define HEARTKEYABLE 0 @@ -38,30 +45,37 @@ namespace OHOS static constexpr uint16_t PROGRESS_VALUE_MIN = 0; static constexpr uint16_t PROGRESS_VALUE_MAX = 10; - uint64_t HeartPresenter::GetCurrentTime() + uint32_t HeartPresenter::GetCurrentTime() { - // time_t now = time(0); - // struct tm *tblock = localtime(&now); - +#if 0 /*优化为更安全的localtime_r()*/ struct timeval tv; gettimeofday(&tv, NULL); struct tm tblock; localtime_r(&tv.tv_sec, &tblock); - uint64_t current_time = tblock.tm_hour * 60 + tblock.tm_min; + uint32_t current_time = tblock.tm_hour * 60 + tblock.tm_min; return current_time; +#endif + uint32_t time; + if (uapi_get_timestampe_ss(&time) != ERRCODE_SUCC) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to get timestamp"); + return 0; + } + return time; } - int HeartPresenter::GetTDOA(uint64_t new_time, uint64_t old_time) + int HeartPresenter::GetTDOA(uint32_t new_time, uint32_t old_time) { if (new_time == old_time || old_time > new_time) { return 0; } - - int time_diff = new_time - old_time; - return time_diff; + int time_diff_seconds = new_time - old_time; + // 转换为分钟的差值 + int time_diff_minutes = time_diff_seconds / 60; + return time_diff_minutes; } HeartPresenter::HeartPresenter() diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataPresenter.cpp index aae8b1b4c..6d2b73031 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataPresenter.cpp @@ -1,4 +1,10 @@ -/*** +/*** + * @Date: 2024-06-12 11:24:16 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-06-13 15:08:56 + * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataPresenter.cpp + */ +/*** * @Date: 2024-04-15 14:19:47 * @LastEditors: Caisking 3449750381@qq.com * @LastEditTime: 2024-06-11 15:34:57 @@ -73,7 +79,7 @@ namespace OHOS { if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) { - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + NativeAbility::GetInstance().ChangeSlice(VIEW_TRAINING_RECORD); } UNUSED(view); return true; @@ -84,7 +90,7 @@ namespace OHOS // 根据控件id查找是哪个控件触发了点击回调 if (strcmp(view.GetViewId(), BUTTONBACK) == 0) { - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGMORE); } return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp index 7ee0737a1..932b8838f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp @@ -145,8 +145,8 @@ namespace OHOS /* DeInit:删除组件 */ void TraingEnddataView::DeInit() { - container_->RemoveAll(); scrollView_->RemoveAll(); + container_->RemoveAll(); /*单位label*/ if (labeltype != nullptr) { @@ -271,6 +271,13 @@ namespace OHOS delete imageLine7; imageLine7 = nullptr; } + + if (scrollView_ != nullptr) + { + delete scrollView_; + scrollView_ = nullptr; + } + delete container_; container_ = nullptr; } @@ -287,13 +294,13 @@ namespace OHOS void TraingEnddataView::InitData() { SportData *enddata = TraingModel::GetInstance()->GetSportdata(); - + if (enddata == nullptr) { printf("Enddata is nullptr. Exiting InitData()...\r\n"); return; } - printf("Initializing TraingEnddataView data...\r\n"); + // printf("Initializing TraingEnddataView data...\r\n"); // 训练图标Icon std::string imageStr = TraingModel::GetInstance()->GetSportType(enddata->sportType); if (!imageStr.empty()) @@ -316,7 +323,7 @@ namespace OHOS labelduration->SetText(durationStr.c_str()); // 运动目标 - if (enddata->tag) + if (enddata->goaldegree) { std::string tagStr = std::to_string(enddata->goaldegree) + "%"; labeltag->SetText(tagStr.c_str()); diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp index e9b8b7fb9..cc88c58b9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp @@ -1154,7 +1154,7 @@ namespace OHOS // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CheckDataJson is ok"); return true; } -#if 0 +#if 1 bool TraingModel::SaveDataToJson(SportData *data) { if (data == nullptr) @@ -1252,6 +1252,7 @@ namespace OHOS return true; } #endif +#if 0 bool TraingModel::SaveDataToJson(SportData *data) { if (data == nullptr) @@ -1317,7 +1318,7 @@ namespace OHOS WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "SaveDataToJson succeeded"); return true; } - +#endif /* 加载训练数据函数 */ std::vector TraingModel::LoadDataFormJson() { diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_aquatic/src/TraingAquaticView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_aquatic/src/TraingAquaticView.cpp index 3ec710233..cb15c6f93 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_aquatic/src/TraingAquaticView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_aquatic/src/TraingAquaticView.cpp @@ -85,8 +85,8 @@ namespace OHOS TraingAquaticList->SetYScrollBarVisible(true); // 设置滑动滚动条 // 增加表冠控制 - TraingAquaticList->SetRotateFactor(2); - TraingAquaticList->RequestFocus(); + //TraingAquaticList->SetRotateFactor(2); + //TraingAquaticList->RequestFocus(); } UIList *TraingAquaticView::GetList() { @@ -151,7 +151,7 @@ namespace OHOS { View::OnStop(); RootView::GetInstance()->RemoveAll(); - RootView::GetInstance()->ClearFocus(); + // RootView::GetInstance()->ClearFocus(); return; } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_ball/src/TraingBallView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_ball/src/TraingBallView.cpp index d4726a305..9ec6b6878 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_ball/src/TraingBallView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_ball/src/TraingBallView.cpp @@ -85,8 +85,8 @@ namespace OHOS TraingBallList->SetYScrollBarVisible(true); // 设置滑动滚动条 // 增加表冠控制 - TraingBallList->SetRotateFactor(2); - TraingBallList->RequestFocus(); + //TraingBallList->SetRotateFactor(2); + //TraingBallList->RequestFocus(); } UIList *TraingBallView::GetList() { @@ -151,7 +151,7 @@ namespace OHOS { View::OnStop(); RootView::GetInstance()->RemoveAll(); - RootView::GetInstance()->ClearFocus(); + // RootView::GetInstance()->ClearFocus(); return; } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_dance/src/TraingDanceView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_dance/src/TraingDanceView.cpp index b40d50250..03d164a09 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_dance/src/TraingDanceView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_dance/src/TraingDanceView.cpp @@ -85,8 +85,8 @@ namespace OHOS TraingDanceList->SetYScrollBarVisible(true); // 设置滑动滚动条 // 增加表冠控制 - TraingDanceList->SetRotateFactor(2); - TraingDanceList->RequestFocus(); + //TraingDanceList->SetRotateFactor(2); + //TraingDanceList->RequestFocus(); } UIList *TraingDanceView::GetList() { @@ -151,7 +151,7 @@ namespace OHOS { View::OnStop(); RootView::GetInstance()->RemoveAll(); - RootView::GetInstance()->ClearFocus(); + // RootView::GetInstance()->ClearFocus(); return; } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_fitness/src/TraingFitnessView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_fitness/src/TraingFitnessView.cpp index edd4239a5..169713bec 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_fitness/src/TraingFitnessView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_fitness/src/TraingFitnessView.cpp @@ -83,8 +83,8 @@ namespace OHOS TraingFitnessList->SetYScrollBarVisible(true); // 设置滑动滚动条 // 增加表冠控制 - TraingFitnessList->SetRotateFactor(2); - TraingFitnessList->RequestFocus(); + //TraingFitnessList->SetRotateFactor(2); + //TraingFitnessList->RequestFocus(); } UIList *TraingFitnessView::GetList() { @@ -153,7 +153,7 @@ namespace OHOS { View::OnStop(); RootView::GetInstance()->RemoveAll(); - RootView::GetInstance()->ClearFocus(); + // RootView::GetInstance()->ClearFocus(); return; } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_ice/src/TraingIceView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_ice/src/TraingIceView.cpp index 4182d1b8d..5065f0fe0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_ice/src/TraingIceView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_ice/src/TraingIceView.cpp @@ -93,8 +93,8 @@ namespace OHOS TraingIceList->SetYScrollBarVisible(true); // 设置滑动滚动条 // 增加表冠控制 - scrollView->SetRotateFactor(2); - scrollView->RequestFocus(); + //scrollView->SetRotateFactor(2); + //scrollView->RequestFocus(); } UIList *TraingIceView::GetList() { @@ -159,7 +159,7 @@ namespace OHOS { View::OnStop(); RootView::GetInstance()->RemoveAll(); - RootView::GetInstance()->ClearFocus(); + // RootView::GetInstance()->ClearFocus(); return; } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_limit/src/TraingLimitView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_limit/src/TraingLimitView.cpp index e8de6c738..b2a069c75 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_limit/src/TraingLimitView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_limit/src/TraingLimitView.cpp @@ -85,8 +85,8 @@ namespace OHOS TraingLimitList->SetYScrollBarVisible(true); // 设置滑动滚动条 // 增加表冠控制 - TraingLimitList->SetRotateFactor(2); - TraingLimitList->RequestFocus(); + //TraingLimitList->SetRotateFactor(2); + //TraingLimitList->RequestFocus(); } UIList *TraingLimitView::GetList() { @@ -151,7 +151,7 @@ namespace OHOS { View::OnStop(); RootView::GetInstance()->RemoveAll(); - RootView::GetInstance()->ClearFocus(); + // RootView::GetInstance()->ClearFocus(); return; } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_more/src/TraingMoreView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_more/src/TraingMoreView.cpp index dec193d5a..8e0823ffd 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_more/src/TraingMoreView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_more/src/TraingMoreView.cpp @@ -90,8 +90,8 @@ namespace OHOS scrollView->SetYScrollBarVisible(true); // 设置滑动滚动条 // 增加表冠控制 - TraingMoreList->SetRotateFactor(2); - TraingMoreList->RequestFocus(); + //TraingMoreList->SetRotateFactor(2); + //TraingMoreList->RequestFocus(); } UIList *TraingMoreView::GetList() { @@ -156,7 +156,7 @@ namespace OHOS { View::OnStop(); RootView::GetInstance()->RemoveAll(); - RootView::GetInstance()->ClearFocus(); + //RootView::GetInstance()->ClearFocus(); return; } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_other/src/TraingOtherView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_other/src/TraingOtherView.cpp index 34c0b85ff..4c784900b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_other/src/TraingOtherView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_other/src/TraingOtherView.cpp @@ -85,8 +85,8 @@ namespace OHOS TraingOtherList->SetYScrollBarVisible(true); // 设置滑动滚动条 // 增加表冠控制 - TraingOtherList->SetRotateFactor(2); - TraingOtherList->RequestFocus(); + //TraingOtherList->SetRotateFactor(2); + //TraingOtherList->RequestFocus(); } UIList *TraingOtherView::GetList() { @@ -151,7 +151,7 @@ namespace OHOS { View::OnStop(); RootView::GetInstance()->RemoveAll(); - RootView::GetInstance()->ClearFocus(); + //RootView::GetInstance()->ClearFocus(); return; } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_rest/src/TraingRestView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_rest/src/TraingRestView.cpp index 5e0d517b4..78b292dec 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_rest/src/TraingRestView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_rest/src/TraingRestView.cpp @@ -85,8 +85,8 @@ namespace OHOS TraingRestList->SetYScrollBarVisible(true); // 设置滑动滚动条 // 增加表冠控制 - TraingRestList->SetRotateFactor(2); - TraingRestList->RequestFocus(); + //TraingRestList->SetRotateFactor(2); + //TraingRestList->RequestFocus(); } UIList *TraingRestView::GetList() { @@ -151,7 +151,7 @@ namespace OHOS { View::OnStop(); RootView::GetInstance()->RemoveAll(); - RootView::GetInstance()->ClearFocus(); + //RootView::GetInstance()->ClearFocus(); return; } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordPresenter.cpp index 788e0f4b5..afe88b8f8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordPresenter.cpp @@ -108,7 +108,8 @@ namespace OHOS if (!sportDataVector.empty()) { // 选择点击按键的历史数据 - SportData sportData = sportDataVector[index]; + int arraynum = sportDataVector.size() - 1; + SportData sportData = sportDataVector[arraynum - index]; // 显示是倒序 id同理 NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGENDDATA); TraingModel::GetInstance()->SetSportdata(&sportData); return true; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordView.cpp index 33e382dab..33cfd9098 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordView.cpp @@ -213,10 +213,6 @@ namespace OHOS TraingRecordList->SetMaxScrollDistance(MAX_SCR_DIS); recordView->SetYScrollBarVisible(true); // 设置滑动滚动条 - - // 增加表冠控制 - TraingRecordList->SetRotateFactor(2); - TraingRecordList->RequestFocus(); TraingRecordList->SetOnClickListener(static_cast(TraingRecordPresenter::GetInstance())); UIView::OnDragListener *recorddraglistener = static_cast(TraingRecordPresenter::GetInstance()); @@ -309,8 +305,6 @@ namespace OHOS { View::OnStop(); RootView::GetInstance()->RemoveAll(); - if (TraingRecordModel::GetInstance().GetJsonStatus()) - RootView::GetInstance()->ClearFocus(); return; } } -- 2.17.1