From 1c510b55c732a3982bba95414f96e1ea605084bf Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Fri, 11 Oct 2024 17:34:59 +0800 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E5=A4=8D=E6=AF=8F=E6=97=A5=E7=9B=AE?= =?utf8?q?=E6=A0=87model=EF=BC=8C=E4=B8=8D=E5=86=8D=E5=A4=9A=E6=AC=A1?= =?utf8?q?=E8=AF=BB=E5=8F=96config?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../uicomponents/UIComponents.cpp | 4 +- .../uicomponents/UIComponents.h | 2 +- .../nativeui/goal/include/goalmodel.h | 23 +++++++++++ .../fd230app/nativeui/goal/src/goalmodel.cpp | 40 ++++++++++++++----- 4 files changed, 55 insertions(+), 14 deletions(-) diff --git a/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.cpp b/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.cpp index 3c575f59a..6610d3fe9 100644 --- a/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.cpp +++ b/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.cpp @@ -463,7 +463,7 @@ void InitLabelDefault(UILabelExt *&label, int x, int y, int width, int height, InitLabel(label, x, y, width, height, viewId, text, fontName, fontSize); } void InitImageAnimatorSource(UIImageAnimatorView *&imageAnimator, - ImageAnimatorInfo *&imageAnimatorInfo, + ImageAnimatorInfo *imageAnimatorInfo, const ImageInfo **imageInfo, int numFrames, int left, int top, int width, int height, const char *viewId, int time) { @@ -476,7 +476,7 @@ void InitImageAnimatorSource(UIImageAnimatorView *&imageAnimator, // imageAnimator->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); imageAnimator->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - imageAnimatorInfo = new ImageAnimatorInfo[numFrames]; + // imageAnimatorInfo = new ImageAnimatorInfo[numFrames]; for (int i = 0; i < numFrames; i++) { imageAnimatorInfo[i].imageInfo = imageInfo[i]; imageAnimatorInfo[i].pos.x = left; diff --git a/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.h b/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.h index 073efd42c..6c232acc3 100644 --- a/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.h +++ b/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.h @@ -231,7 +231,7 @@ namespace OHOS * @param config 动画相关的配置(包括路径和帧信息)。 * @param generalConfig 视图的基本配置(位置、大小、视图 ID 等)。 */ - void InitImageAnimatorSource(UIImageAnimatorView *&imageAnimator, ImageAnimatorInfo *&imageAnimatorInfo, const ImageInfo **imageInfo, int numFrames, int left, int top, int width, int height, const char *viewId, int time); + void InitImageAnimatorSource(UIImageAnimatorView *&imageAnimator, ImageAnimatorInfo *imageAnimatorInfo, const ImageInfo **imageInfo, int numFrames, int left, int top, int width, int height, const char *viewId, int time); /** * @brief 释放 UIImageAnimatorView 的资源。 diff --git a/code/sdk/application/wearable/fd230app/nativeui/goal/include/goalmodel.h b/code/sdk/application/wearable/fd230app/nativeui/goal/include/goalmodel.h index 7e02201e1..6719cc73d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/goal/include/goalmodel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/goal/include/goalmodel.h @@ -45,8 +45,31 @@ namespace OHOS char* getstandgoal(); char* getstandnew(); void updata(); + void GoalModelInitdata(); + + uint8_t get_step_goal_show() + { + return step_goal_show; + } + + uint8_t get_other_goal_show() + { + return other_goal_show; + } + private: + //目标数据 + + uint32_t step=0; + uint32_t distance=0; + uint32_t fat=0; + uint32_t calories=0; + uint32_t stand=0; + + uint8_t step_goal_show=0; + uint8_t other_goal_show=0; + GoalModel(); GoalModel(const GoalModel &) = delete; GoalModel &operator=(const GoalModel &) = delete; diff --git a/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalmodel.cpp b/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalmodel.cpp index aa370e352..c1e13841e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalmodel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalmodel.cpp @@ -14,19 +14,35 @@ namespace OHOS { - + GoalModel::GoalModel() { + GoalModelInitdata(); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GoalModel::GoalModel"); } + + + void GoalModel::GoalModelInitdata() + { + step_goal_show=ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_STEP); + other_goal_show=ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_OTHER); + + step=ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_STEPCOUNT); + distance=ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_DISTANCE); + fat=ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_DURATION); + calories=ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_CALORIES); + stand=ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_STANDUP_TIMES); + } + + GoalModel::~GoalModel() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GoalModel::~GoalModel"); } uint8_t GoalModel::getstepvalue() { - int stepgoal = ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_STEPCOUNT); + int stepgoal = step; int stepdata = OHOS::ActivityModel::GetInstance()->GetStepCounter(); // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%d %d %f ",stepdata,stepgoal,((float)stepdata/(float)stepgoal) * 100); uint8_t value = ((float)stepdata / (float)stepgoal) * 100; @@ -41,7 +57,7 @@ namespace OHOS char stepgoalstr[20]; char *GoalModel::getstepGoal() { - int stepgoal = ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_STEPCOUNT); + int stepgoal = step; memset((void *)stepgoalstr, 0, 20); sprintf_s(stepgoalstr, 20, "/%d", stepgoal); return stepgoalstr; @@ -59,7 +75,7 @@ namespace OHOS char caloriesgoalstr[20]; char *GoalModel::getcaloriesGoal() { - int caloriesdata = ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_CALORIES); + int caloriesdata =calories; memset((void *)caloriesgoalstr, 0, 20); sprintf_s(caloriesgoalstr, 20, "/%d", caloriesdata); return caloriesgoalstr; @@ -78,7 +94,7 @@ namespace OHOS char distancegoalstr[20]; char *GoalModel::getdistanceGoal() { - int distancedata = ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_DISTANCE); + int distancedata = distance; memset((void *)distancegoalstr, 0, 20); sprintf_s(distancegoalstr, 20, "/%d", distancedata); return distancegoalstr; @@ -97,7 +113,7 @@ namespace OHOS char fatburninggoalstr[20]; char *GoalModel::getfatburninggoal() { - int fatburningdata = ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_DURATION); + int fatburningdata = fat; memset((void *)fatburninggoalstr, 0, 20); sprintf_s(fatburninggoalstr, 20, "/%d", fatburningdata); return fatburninggoalstr; @@ -107,7 +123,7 @@ namespace OHOS bool GoalModel::is_goal_DISTANCE_done() { float distancedata_now = (float)get_distance_data() / 1000.0; - int distancedata_goal = ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_DISTANCE); + int distancedata_goal = distance; if(distancedata_now>=distancedata_goal) return true; @@ -120,7 +136,7 @@ namespace OHOS { int fatburningdata_now = get_fat_time_data()/60; - int fatburningdata_goal = ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_DURATION); + int fatburningdata_goal = fat; if(fatburningdata_now>=fatburningdata_goal) return true; @@ -133,7 +149,7 @@ namespace OHOS { int standdata_now = get_now_stand_count(); - int standdata_goal = ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_STANDUP_TIMES); + int standdata_goal = stand; if(standdata_now>=standdata_goal) return true; @@ -146,7 +162,7 @@ namespace OHOS { int calories_now = get_calories_data(); - int calories_goal = ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_CALORIES); + int calories_goal = calories; if(calories_now>=calories_goal) return true; @@ -169,7 +185,7 @@ namespace OHOS char standstr[20]; char *GoalModel::getstandgoal() { - int standdata = ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_STANDUP_TIMES); + int standdata =stand; memset((void *)standstr, 0, 20); sprintf_s(standstr, 20, "/%d", standdata); return standstr; @@ -193,6 +209,8 @@ namespace OHOS void GoalModel::updata(void) { + GoalModel::GetInstance().GoalModelInitdata(); + if(OHOS::GoalView::GetInstance()) { OHOS::GoalView::GetInstance()->GoalViewrefresh(); -- 2.17.1