#include "goal_notification.h"
#include "custom_utils.h"
#include "cywee_ble_Service.h"
-
+// #include "goalmodel.h"
namespace OHOS
{
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);
+ step_goal=ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_STEPCOUNT);
+ distanc_goal=ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_DISTANCE);
+ fat_goal=ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_DURATION);
+ calories_goal=ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_CALORIES);
+ stand_goal=ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_STANDUP_TIMES);
standdata_now=get_now_stand_count();
}
uint8_t GoalModel::getstepvalue()
{
- int stepgoal = step;
+ int stepgoal = step_goal;
int stepdata = show_data_step_refresh();//get_step_data();//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;
}
uint32_t GoalModel::getstepgoaldata()
{
- return step;
+ return step_goal;
}
- char stepgoalstr[20];
- char *GoalModel::getstepGoal()
+
+ std::string GoalModel::getstepGoal()
{
- int stepgoal = step;
- memset((void *)stepgoalstr, 0, 20);
- sprintf_s(stepgoalstr, 20, "/%d", stepgoal);
+ // int stepgoal = step;
+ // memset((void *)stepgoalstr, 0, 20);
+ char temp_str[20]={0};
+ sprintf_s(temp_str, 20, "/%d", step_goal);
+ std::string stepgoalstr;
+ stepgoalstr= temp_str;
return stepgoalstr;
}
- char stepnewstr[20];
- char *GoalModel::getstepnew()
+
+ std::string GoalModel::getstepnew()
{
+
int stepdata = show_data_step_refresh();
- memset((void *)stepnewstr, 0, 20);
- sprintf_s(stepnewstr, 20, "%d", stepdata);
+ char temp_str[20]={0};
+ sprintf_s(temp_str, 20, "%d", stepdata);
+
+ std::string stepnewstr=temp_str;
+
return stepnewstr;
}
- char caloriesgoalstr[20];
- char *GoalModel::getcaloriesGoal()
+
+ std::string GoalModel::getcaloriesGoal()
{
- int caloriesdata =calories;
- memset((void *)caloriesgoalstr, 0, 20);
- sprintf_s(caloriesgoalstr, 20, "/%d", caloriesdata);
+ std::string caloriesgoalstr;
+
+ int caloriesdata =calories_goal;
+ char temp_str[20]={0};
+ sprintf_s(temp_str, 20, "/%d", caloriesdata);
+ caloriesgoalstr=temp_str;
+
return caloriesgoalstr;
}
- char caloriesnewstr[20];
- char *GoalModel::getcaloriespnew()
+
+ std::string GoalModel::getcaloriespnew()
{
+ std::string caloriesnewstr;
+
int caloriesdata = show_data_calories_refresh();
+ char temp_str[20]={0};
+ sprintf_s(temp_str, 20, "%d", caloriesdata);
- memset((void *)caloriesnewstr, 0, 20);
- sprintf_s(caloriesnewstr, 20, "%d", caloriesdata);
+ caloriesnewstr=temp_str;
+
return caloriesnewstr;
}
- char distancegoalstr[20];
- char *GoalModel::getdistanceGoal()
+ std::string GoalModel::getdistanceGoal()
{
- int distancedata = distance;
- memset((void *)distancegoalstr, 0, 20);
- sprintf_s(distancegoalstr, 20, "/%d", distancedata);
+ std::string distancegoalstr;
+
+ int distancedata = distanc_goal;
+ char temp_str[20]={0};
+ sprintf_s(temp_str, 20, "/%d", distancedata);
+
+ distancegoalstr=temp_str;
+
return distancegoalstr;
}
- char distancenewstr[20];
- char *GoalModel::getdistancenew()
+
+ std::string GoalModel::getdistancenew()
{
+ std::string distancenewstr;
+
float distancedata = show_data_distance_refresh();
+ char temp_str[20]={0};
+ sprintf_s(temp_str, 20, "%0.1f", distancedata);
+
+ distancenewstr=temp_str;
- memset((void *)distancenewstr, 0, 20);
- sprintf_s(distancenewstr, 20, "%0.1f", distancedata);
return distancenewstr;
}
- char fatburninggoalstr[20];
- char *GoalModel::getfatburninggoal()
+
+ std::string GoalModel::getfatburninggoal()
{
- int fatburningdata = fat;
- memset((void *)fatburninggoalstr, 0, 20);
- sprintf_s(fatburninggoalstr, 20, "/%d", fatburningdata);
+ std::string fatburninggoalstr;
+
+ int fatburningdata = fat_goal;
+
+ char temp_str[20]={0};
+ sprintf_s(temp_str, 20, "/%d", fatburningdata);
+ fatburninggoalstr=temp_str;
+
return fatburninggoalstr;
}
+ std::string GoalModel::getfatburningnew()
+ {
+
+ std::string fatburningnewstr;
+
+ int fatburningdata = show_data_fat_refresh();;
+
+ char temp_str[20]={0};
+ sprintf_s(temp_str, 20, "%d", fatburningdata);
+ fatburningnewstr=temp_str;
+
+ return fatburningnewstr;
+ }
+
+
+ std::string GoalModel::getstandgoal()
+ {
+ std::string standstr;
+
+ int standdata =stand_goal;
+ char temp_str[20]={0};
+ sprintf_s(temp_str, 20, "/%d", standdata);
+ standstr=temp_str;
+
+ return standstr;
+ }
+
+
+ std::string GoalModel::getstandnew()
+ {
+ std::string standnewstr;
+
+ int standdata = standdata_now;
+ char temp_str[20]={0};
+ sprintf_s(temp_str, 20, "%d", standdata);
+ standnewstr=temp_str;
+
+ return standnewstr;
+ }
+
+
bool GoalModel::is_goal_DISTANCE_done()
{
float distancedata_now = show_data_distance_refresh();
- int distancedata_goal = distance;
+ int distancedata_goal = distanc_goal;
if(distancedata_now>=distancedata_goal)
return true;
{
int fatburningdata_now =show_data_fat_refresh();
- int fatburningdata_goal = fat;
+ int fatburningdata_goal = fat_goal;
if(fatburningdata_now>=fatburningdata_goal)
return true;
{
int standdata_now_ = standdata_now;
- int standdata_goal = stand;
+ int standdata_goal = stand_goal;
if(standdata_now_>=standdata_goal)
return true;
{
int calories_now = show_data_calories_refresh();
- int calories_goal = calories;
+ int caloriesdata_goal = calories_goal;
- if(calories_now>=calories_goal)
+ if(calories_now>=caloriesdata_goal)
return true;
else
return false;
}
- char fatburningnewstr[20];
- char *GoalModel::getfatburningnew()
- {
- int fatburningdata = show_data_fat_refresh();
-
- memset((void *)fatburningnewstr, 0, 20);
- sprintf_s(fatburningnewstr, 20, "%d", fatburningdata);
- return fatburningnewstr;
- }
-
- char standstr[20];
- char *GoalModel::getstandgoal()
- {
- int standdata =stand;
- memset((void *)standstr, 0, 20);
- sprintf_s(standstr, 20, "/%d", standdata);
- return standstr;
- }
-
- char standnewstr[20];
- char *GoalModel::getstandnew()
- {
- int standdata = standdata_now;
-
- memset((void *)standnewstr, 0, 20);
- sprintf_s(standnewstr, 20, "%d", standdata);
- return standnewstr;
- }
GoalModel &GoalModel::GetInstance()
{
memcpy(&timetemp,date+i*8,4);
memcpy(&sing_date,date+i*8+4,4);
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "time: %d", timetemp);
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "data: %d", sing_date);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "data: %f", sing_date);
struct tm *timeinfo;
memcpy(&timetemp,date+i*8,4);
memcpy(&sing_date,date+i*8+4,4);
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "time: %d", timetemp);
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "data: %d", sing_date);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "data: %f", sing_date);
struct tm *timeinfo;
timeinfo = localtime((time_t *) &timetemp);
void GoalotherView::GoalViewrefresh()
{
if(mileagenowdataLabel)
- mileagenowdataLabel->SetText(GoalModel::GetInstance().getdistancenew());
+ mileagenowdataLabel->SetText(GoalModel::GetInstance().getdistancenew().c_str());
if(mileagegoaldataLabel)
- mileagegoaldataLabel->SetText(GoalModel::GetInstance().getdistanceGoal());
+ mileagegoaldataLabel->SetText(GoalModel::GetInstance().getdistanceGoal().c_str());
if(fatburningnowdataLabel)
- fatburningnowdataLabel->SetText(GoalModel::GetInstance().getfatburningnew());
+ fatburningnowdataLabel->SetText(GoalModel::GetInstance().getfatburningnew().c_str());
if(fatburninggoaldataLabel)
- fatburninggoaldataLabel->SetText(GoalModel::GetInstance().getfatburninggoal());
+ fatburninggoaldataLabel->SetText(GoalModel::GetInstance().getfatburninggoal().c_str());
if(standnowdataLabel)
- standnowdataLabel->SetText(GoalModel::GetInstance().getstandnew());
+ standnowdataLabel->SetText(GoalModel::GetInstance().getstandnew().c_str());
if(standgoaldataLabel)
- standgoaldataLabel->SetText(GoalModel::GetInstance().getstandgoal());
+ standgoaldataLabel->SetText(GoalModel::GetInstance().getstandgoal().c_str());
if(calorienowdataLabel)
- calorienowdataLabel->SetText(GoalModel::GetInstance().getcaloriespnew());
+ calorienowdataLabel->SetText(GoalModel::GetInstance().getcaloriespnew().c_str());
if(caloriegoaldataLabel)
- caloriegoaldataLabel->SetText(GoalModel::GetInstance().getcaloriesGoal());
+ caloriegoaldataLabel->SetText(GoalModel::GetInstance().getcaloriesGoal().c_str());
Invalidate();
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GoalViewrefresh Invalidat ");
mileagenowdataLabel->SetStyle(STYLE_TEXT_FONT, 40);
// Set additional property
- mileagenowdataLabel->SetText(GoalModel::GetInstance().getdistancenew());
+ mileagenowdataLabel->SetText(GoalModel::GetInstance().getdistancenew().c_str());
mileagenowdataLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
mileagenowdataLabel->SetTextColor(Color::GetColorFromRGBA(0x4F, 0xC3, 0x4C, 0xff));
mileagenowdataLabel->SetAlign(TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_CENTER);
mileagegoaldataLabel->SetStyle(STYLE_TEXT_FONT, 40);
// Set additional property
- mileagegoaldataLabel->SetText(GoalModel::GetInstance().getdistanceGoal());
+ mileagegoaldataLabel->SetText(GoalModel::GetInstance().getdistanceGoal().c_str());
mileagegoaldataLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
mileagegoaldataLabel->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff));
mileagegoaldataLabel->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);
fatburningnowdataLabel->SetStyle(STYLE_TEXT_FONT, 40);
// Set additional property
- fatburningnowdataLabel->SetText(GoalModel::GetInstance().getfatburningnew());
+ fatburningnowdataLabel->SetText(GoalModel::GetInstance().getfatburningnew().c_str());
fatburningnowdataLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
fatburningnowdataLabel->SetTextColor(Color::GetColorFromRGBA(0x4F, 0xC3, 0x4C, 0xff));
fatburningnowdataLabel->SetAlign(TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_CENTER);
fatburninggoaldataLabel->SetStyle(STYLE_TEXT_FONT, 40);
// Set additional property
- fatburninggoaldataLabel->SetText(GoalModel::GetInstance().getfatburninggoal());
+ fatburninggoaldataLabel->SetText(GoalModel::GetInstance().getfatburninggoal().c_str());
fatburninggoaldataLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
fatburninggoaldataLabel->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff));
fatburninggoaldataLabel->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);
// Set additional property
- standnowdataLabel->SetText(GoalModel::GetInstance().getstandnew());
+ standnowdataLabel->SetText(GoalModel::GetInstance().getstandnew().c_str());
standnowdataLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
standnowdataLabel->SetTextColor(Color::GetColorFromRGBA(0x4F, 0xC3, 0x4C, 0xff));
standnowdataLabel->SetAlign(TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_CENTER);
standgoaldataLabel->SetStyle(STYLE_TEXT_FONT, 40);
// Set additional property
- standgoaldataLabel->SetText(GoalModel::GetInstance().getstandgoal());
+ standgoaldataLabel->SetText(GoalModel::GetInstance().getstandgoal().c_str());
standgoaldataLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
standgoaldataLabel->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff));
standgoaldataLabel->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);
calorienowdataLabel->SetStyle(STYLE_TEXT_FONT, 40);
// Set additional property
- calorienowdataLabel->SetText(GoalModel::GetInstance().getcaloriespnew());
+ calorienowdataLabel->SetText(GoalModel::GetInstance().getcaloriespnew().c_str());
calorienowdataLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
calorienowdataLabel->SetTextColor(Color::GetColorFromRGBA(0x4F, 0xC3, 0x4C, 0xff));
calorienowdataLabel->SetAlign(TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_CENTER);
caloriegoaldataLabel->SetStyle(STYLE_TEXT_FONT, 40);
// Set additional property
- caloriegoaldataLabel->SetText(GoalModel::GetInstance().getcaloriesGoal());
+ caloriegoaldataLabel->SetText(GoalModel::GetInstance().getcaloriesGoal().c_str());
caloriegoaldataLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
caloriegoaldataLabel->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff));