${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/training_card/src/TraingCardPresenter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/training_card/src/TrainingControlView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/training_card/src/TrainingDataView.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/training_card/src/TrainingDetailView.cpp
#训练记录
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traingrecord/src/TraingRecordView.cpp
{
"spo2_latest_data": {
- "oxygen_value": 98,
- "timestamp": 1646769855
+ "oxygen_value": 0,
+ "timestamp": 0
},
"spo2_data_list": [
{
- "oxygen_value": 95,
- "timestamp": 1646769823
- },
- {
- "oxygen_value": 97,
- "timestamp": 1646769844
- },
- {
- "oxygen_value": 96,
- "timestamp": 1646769849
- },
- {
- "oxygen_value": 98,
- "timestamp": 1646769855
+ "oxygen_value": 0,
+ "timestamp": 0
}
],
"heart_latest_data": {
- "heart_value": 88,
- "timestamp": 1646769855
+ "heart_value": 0,
+ "timestamp": 0
},
"heart_data_list": [
{
- "heart_value": 95,
- "timestamp": 1646769823
- },
- {
- "heart_value": 57,
- "timestamp": 1646769844
- },
- {
- "heart_value": 86,
- "timestamp": 1646769849
- },
- {
- "heart_value": 88,
- "timestamp": 1646769855
+ "heart_value": 0,
+ "timestamp": 0
}
]
}
\ No newline at end of file
#include <fstream>
#include "wearable_log.h"
#include "cJSON.h"
+#include <sys/stat.h>
+#include <ctime>
namespace OHOS
{
static HealthService *g_pHealthService = nullptr;
+ static constexpr const char *HEALTH_JSON_PATH = "/user/userdata/health/";
+
cJSON *root = NULL;
HealthService::HealthService()
{
static HealthService instance;
return &instance;
}
+ /* --------------------------------- 文件IO操作 --------------------------------- */
+ /*创建文件夹*/
+ bool HealthService::CreateHealthFolder()
+ {
+ struct stat info;
+ if (stat(HEALTH_JSON_PATH, &info) != 0)
+ {
+ if (mkdir(HEALTH_JSON_PATH, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0)
+ {
+ return false; // Failed to create folder
+ }
+ }
+ return true;
+ }
+ /*获取日期*/
+ std::string GetCurrentDate()
+ {
+ time_t now = time(0);
+ tm *ltm = localtime(&now);
+ char date[20];
+ strftime(date, sizeof(date), "%Y%m%d", ltm);
+ return std::string(date);
+ }
+ /*生成文件*/
+ std::string GetJsonFilePath()
+ {
+ std::string currentDate = GetCurrentDate();
+ return std::string(HEALTH_JSON_PATH) + currentDate + ".json";
+ }
+ bool HealthService::LoadJsonData()
+ {
+ // 创建健康数据文件夹
+ if (!CreateHealthFolder())
+ {
+ return false;
+ }
+ // 获取当天日期对应的JSON文件路径
+ std::string jsonFilePath = GetJsonFilePath();
+ std::ifstream inFile(jsonFilePath);
+ if (!inFile.is_open())
+ {
+ // 如果文件不存在,则创建一个包含默认值的JSON文件
+ cJSON *defaultJson = cJSON_Parse("{\
+ \"spo2_latest_data\": {\
+ \"oxygen_value\": 0, \
+ \"timestamp\": 0 \
+ }, \
+ \"spo2_data_list\": [\
+ {\
+ \"oxygen_value\": 0, \
+ \"timestamp\": 0 \
+ }\
+ ], \
+ \"heart_latest_data\": {\
+ \"heart_value\": 0, \
+ \"timestamp\": 0 \
+ }, \
+ \"heart_data_list\": [\
+ {\
+ \"heart_value\": 0, \
+ \"timestamp\": 0 \
+ }\
+ ]\
+ }");
+ std::ofstream outFile(jsonFilePath);
+ if (!outFile.is_open())
+ {
+ return false; // 无法创建文件
+ }
+ char *defaultJsonString = cJSON_Print(defaultJson);
+ outFile << defaultJsonString; // 写入包含默认值的JSON对象
+ outFile.close();
+ cJSON_Delete(defaultJson);
+ inFile.open(jsonFilePath); // 重新打开文件
+ }
+ // 读取JSON文件内容
+ std::string jsonDataString((std::istreambuf_iterator<char>(inFile)), std::istreambuf_iterator<char>());
+ const char *jsonData = jsonDataString.c_str();
+ root = cJSON_Parse(jsonData);
+ return true;
+ }
+#if 0
bool HealthService::LoadJsonData()
{
std::ifstream inFile(HEALTH_JSON_PATH);
root = cJSON_Parse(jsonData);
return true;
}
-
+#endif
BloodOxygenData *HealthService::ReadBloodOxygenData()
{
LoadJsonData();
cJSON_Delete(root);
return data;
}
-
bool HealthService::UpdateBloodOxygenData(const BloodOxygenData &data)
{
LoadJsonData();
bool HealthService::UpdateJsonData()
{
- std::ofstream outFile(HEALTH_JSON_PATH);
+ std::string jsonFilePath = GetJsonFilePath();
+ std::ofstream outFile(jsonFilePath);
if (!outFile.is_open())
{
return false;
HealthService();
~HealthService();
static HealthService *GetInstance(void);
+ bool CreateHealthFolder();
bool LoadJsonData(); // 加载json
BloodOxygenData *ReadBloodOxygenData(); // 读取血氧数据
bool UpdateBloodOxygenData(const BloodOxygenData &data); // 更新血氧数据
HeartPoints *ReadHeartRateDataList(); // 读取心率列表
bool UpdateHeartRateData(const HeartRateData &data); // 更新心率数据
bool UpdateJsonData(); // 更新json
- private:
- static constexpr const char *HEALTH_JSON_PATH = "/user/userdata/health.json";
};
}
#endif // HEALTH_MODEL_H
\ No newline at end of file
CardId id;
UICardPage *(MainViewSample::*func)(void);
};
- //严格按照Id对应
+ // 严格按照Id对应
static const MainViewMapper CardMapper[] = {
{WATCH_FACE, &MainViewSample::InitWatchFacePage},
{HEART_RATE, &MainViewSample::InitHeartRatePage},
dropDownView->SetViewId("dropDownView");
dropDownView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
dropDownView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+ /* -------------------------------------------------------------------------- */
messageView = new MessageCardView();
if (messageView == nullptr)
{
button_exit = new UIButton();\r
}\r
button_exit->SetPosition(204, 350); // widget's left position and top position\r
- button_exit->Resize(60, 60); // widget's width and height\r
+ button_exit->Resize(100, 100); // widget's width and height\r
button_exit->SetViewId("button_exit"); // Set style\r
button_exit->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);\r
button_exit->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
// Set additional property\r
char *button1defaultImgSrc = "/user/res/Save_Ele/finger.bin";\r
char *button1triggeredImgSrc = nullptr;\r
- button_exit->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc);\r
+ button_exit->SetImageSrc(button1defaultImgSrc, button1defaultImgSrc);\r
button_exit->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED);\r
\r
// Add the CallBack about events\r
}
/* 开启定时器 */
- void InitTraingTimer()
+ void InitTimer(void)
{
if (g_startCounting != NULL)
{
}
g_startCounting = NULL;
}
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitTimer!");
return;
}
}
/* 关闭定时器 */
- void DisableTraingTimer()
+ void DisableTimer(void)
{
if (g_startCounting != NULL)
{
}
g_startCounting = NULL;
g_motionTimes = 0;
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisableTimer!");
+ }
+ }
+ /* 暂停定时器 */
+ void PauseTimer(void)
+ {
+ // 检查定时器是否存在
+ if (g_startCounting != NULL)
+ {
+ // 暂停定时器,但不删除它
+ osStatus_t ret = osTimerStop(g_startCounting);
+ if (ret != osOK)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StopWatch_PauseTimer osTimerStop failed, ret = %lx!!", ret);
+ }
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PauseTimer!");
+ }
+ }
+
+ /*恢复定时器*/
+ void ResumeTimer(void)
+ {
+ // 检查定时器是否存在
+ if (g_startCounting != NULL)
+ {
+ int tick = osMs2Tick(MS_ONE_SECONDS);
+ // 恢复定时器
+ osStatus_t ret = osTimerStart(g_startCounting, tick);
+ if (ret != osOK)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ResumeTimer osTimerStart failed, ret = %lx!!", ret);
+ }
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ResumeTimer!");
}
}
#include "PlayersView.h"\r
#include "traing/training_card/include/TrainingControlView.h"\r
#include "traing/training_card/include/TrainingDataView.h"\r
+#include "traing/training_card/include/TrainingDetailView.h"\r
\r
namespace OHOS\r
{\r
class TraingCardPresenter;\r
class TrainingControlView;\r
class TrainingDataView;\r
+ class TrainingDetailView;\r
class TraingCardView : public View<TraingCardPresenter>\r
{\r
\r
UICardPage *InitControlPage(void);\r
UICardPage *InitDataPage(void);\r
UICardPage *InitMusicPage(void);\r
+ UICardPage *InitDetailPage(void);\r
\r
void InitView();\r
void DeInit();\r
void InitList();\r
void PreLoad(void);\r
- \r
- int GetCurrentPageId();\r
+\r
+ int GetCurrentPage();\r
+\r
private:\r
UIView::OnDragListener *draglistener{nullptr};\r
TraingCardView(TraingCardView &&) = delete;\r
TraingCardView &operator=(TraingCardView &&) = delete;\r
\r
- UISwipeView *swipe_ = nullptr;\r
+ UICrossView *swipe_ = nullptr;\r
\r
TrainingControlView *ControlView{nullptr};\r
TrainingDataView *DataVIew{nullptr};\r
+ TrainingDetailView *DetailView{nullptr};\r
PlayersView *MusicView{nullptr};\r
\r
bool viewiInitStatus{false};\r
--- /dev/null
+#ifndef _TrainingDetail_VIEW_H
+#define _TrainingDetail_VIEW_H
+
+#include "BaseView.h"
+#include "View.h"
+#include <ui_scroll_view.h>
+#include "components/ui_view_group.h"
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_image_view.h"
+#include "components/ui_button.h"
+#include "components/ui_image_animator.h"
+#include "components/ui_label_button_ext.h"
+#include "components/ui_chart.h"
+#include "components/ui_list.h"
+#include "components/icon_adapter.h"
+#include "wearable_log.h"
+#include "ohos_types.h"
+#include "components/ui_card_page.h"
+#include "traing/include/TraingModel.h"
+#include "traing/Training_UiConfig.h"
+
+#include "traing/include/TraingModel.h"
+#include "traing/Training_UiConfig.h"
+
+#include "traing/training_card/include/TrainingDetailView.h"
+#include "traing/training_card/include/TraingCardPresenter.h"
+namespace OHOS
+{
+
+ class TrainingDetailView : public UICardPage
+ {
+ public:
+ TrainingDetailView();
+ virtual ~TrainingDetailView();
+ static TrainingDetailView *GetInstance(void);
+
+ void InitView();
+ void DeInit();
+
+ void PreLoad(void) override;
+ void UnLoad(void) override;
+ // UILabelExt *GetTimeLabel();
+
+ private:
+ UIView::OnDragListener *draglistener{nullptr};
+ TrainingDetailView(TrainingDetailView &&) = delete;
+ TrainingDetailView &operator=(TrainingDetailView &&) = delete;
+
+ UIViewGroup *container_ = nullptr;
+
+ UILabelExt *u_heartlabel = nullptr;
+ UILabelExt *u_milelabel = nullptr;
+ UILabelExt *u_stepslabel = nullptr;
+ UILabelExt *u_calorielabel = nullptr;
+ UILabelExt *heartlabel = nullptr;
+ UILabelExt *milelabel = nullptr;
+ UILabelExt *steplabel = nullptr;
+ UILabelExt *calorielabel = nullptr;
+
+ UIImageView *heartimage = nullptr;
+ UIImageView *mileimage = nullptr;
+ UIImageView *stepimage = nullptr;
+ UIImageView *calorieimage = nullptr;
+ UIImageView *lineimage1_ = nullptr;
+ UIImageView *lineimage2_ = nullptr;
+ UIImageView *lineimage3_ = nullptr;
+
+ bool viewiInitStatus{false};
+ };
+} // namespace OHOS
+#endif // TraingDetail_PRESENTER_H
#include <thread>\r
#include "traing/training_card/include/TraingCardPresenter.h"\r
// #include "TraingCardView.h"\r
-\r
+extern "C"\r
+{\r
+ void InitTimer();\r
+ void DisableTimer();\r
+ void PauseTimer();\r
+ void ResumeTimer();\r
+}\r
namespace OHOS\r
{\r
// 当前Presenter属性实例化的内存指针\r
\r
bool TraingCardPresenter::OnDrag(UIView &view, const DragEvent &event)\r
{\r
- uint8_t viewid = TraingCardView::GetInstance()->GetCurrentPageId();\r
- // const char *viewid = view.GetViewId();\r
- if (viewid == Control_Card::DATA)\r
- {\r
- if (event.GetDragDirection() == DragEvent::DIRECTION_BOTTOM_TO_TOP)\r
- {\r
- NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGDETAIL);\r
- }\r
- return true;\r
- }\r
+ // uint8_t viewid = TraingCardView::GetInstance()->GetCurrentPage();\r
+ // // const char *viewid = view.GetViewId();\r
+ // if (viewid == Control_Card::DATA)\r
+ // {\r
+ // if (event.GetDragDirection() == DragEvent::DIRECTION_BOTTOM_TO_TOP)\r
+ // {\r
+ // NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGDETAIL);\r
+ // }\r
+ // return true;\r
+ // }\r
UNUSED(view);\r
- return false;\r
+ return true;\r
}\r
\r
bool TraingCardPresenter::OnClick(UIView &view, const ClickEvent &event)\r
if (TraingModel::GetInstance()->GetSportState() == ExerciseState::Start)\r
{\r
TrainingControlView::GetInstance()->GetLabel()->SetText("继续");\r
- TrainingControlView::GetInstance()->GetButton()->SetImageSrc(SPORT_CONTINUE_IMAGE, nullptr);\r
+ TrainingControlView::GetInstance()->GetButton()->SetImageSrc(SPORT_CONTINUE_IMAGE, SPORT_CONTINUE_IMAGE);\r
// 设置为暂停状态\r
TraingModel::GetInstance()->SetSportState(ExerciseState::Pause);\r
+ // 暂停计时器\r
+ PauseTimer();\r
return true;\r
}\r
// 暂停状态\r
if (TraingModel::GetInstance()->GetSportState() == ExerciseState::Pause)\r
{\r
TrainingControlView::GetInstance()->GetLabel()->SetText("暂停");\r
- TrainingControlView::GetInstance()->GetButton()->SetImageSrc(SPORT_PAUSE_IMAGE, nullptr);\r
+ TrainingControlView::GetInstance()->GetButton()->SetImageSrc(SPORT_PAUSE_IMAGE, SPORT_PAUSE_IMAGE);\r
// 设置为开始状态\r
TraingModel::GetInstance()->SetSportState(ExerciseState::Start);\r
+ // 恢复计时器\r
+ ResumeTimer();\r
return true;\r
}\r
}\r
return true;\r
}\r
\r
- // 计时器更新\r
+ // 计时器更新timer\r
void TraingCardPresenter::ModifiesTime()\r
{\r
std ::string TimeStr = TraingModel::GetInstance()->DisplayMotionDuration();\r
\r
extern "C"\r
{\r
- void InitTraingTimer();\r
- void DisableTraingTimer();\r
+ void InitTimer();\r
+ void DisableTimer();\r
}\r
\r
namespace OHOS\r
{\r
g_pTraingCardView = this;\r
// 开启计时器\r
- InitTraingTimer();\r
+ InitTimer();\r
// 设置运动状态为开始\r
TraingModel::GetInstance()->SetSportState(ExerciseState::Start);\r
}\r
DeInit();\r
g_pTraingCardView = nullptr;\r
// 关闭计时器\r
- DisableTraingTimer();\r
+ DisableTimer();\r
// 设置运动状态为结束\r
TraingModel::GetInstance()->SetSportState(ExerciseState::End);\r
}\r
\r
if (swipe_ == nullptr)\r
{\r
- swipe_ = new UISwipeView();\r
+ swipe_ = new UICrossView();\r
swipe_->SetPosition(0, 0, 466, 466);\r
swipe_->SetStyle(STYLE_BACKGROUND_OPA, 0);\r
}\r
InitControlPage();\r
InitDataPage();\r
InitMusicPage();\r
+ InitDetailPage();\r
\r
- swipe_->Add(ControlView);\r
- swipe_->Add(DataVIew);\r
- swipe_->Add(MusicView);\r
+ swipe_->HorAdd(ControlView);\r
+ swipe_->HorAdd(DataVIew);\r
+ swipe_->HorAdd(MusicView);\r
+ // swipe_->HorAdd(DetailView);\r
\r
- swipe_->SetCurrentPage(Control_Card::CONTROL);\r
+ swipe_->VerAdd(DetailView, UICrossView::VPage::DOWN_PAGE);\r
+\r
+ swipe_->SetHorCurrentPage(Control_Card::CONTROL);\r
\r
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::InitPage over");\r
}\r
delete DataVIew;\r
DataVIew = nullptr;\r
}\r
+ if (DetailView != nullptr)\r
+ {\r
+ DetailView->RemoveAll();\r
+ delete DetailView;\r
+ DetailView = nullptr;\r
+ }\r
if (MusicView != nullptr)\r
{\r
MusicView->RemoveAll();\r
}\r
return MusicView;\r
}\r
-\r
+ UICardPage *TraingCardView::InitDetailPage()\r
+ {\r
+ DetailView = new TrainingDetailView();\r
+ DetailView->PreLoad();\r
+ DetailView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
+ if (DetailView == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DetailView new fail");\r
+ return nullptr;\r
+ }\r
+ return DetailView;\r
+ }\r
void TraingCardView::PreLoad(void)\r
{\r
if (!viewiInitStatus)\r
InitView();\r
viewiInitStatus = true;\r
}\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingCardView PreLoad");\r
}\r
void TraingCardView::OnStart()\r
{\r
- swipe_ = new UISwipeView();\r
+ swipe_ = new UICrossView();\r
if (swipe_ == nullptr)\r
{\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "swipe_ new fail");\r
return;\r
}\r
\r
- int TraingCardView::GetCurrentPageId()\r
+ int TraingCardView::GetCurrentPage()\r
{\r
- return swipe_->GetCurrentPage();\r
+ return swipe_->GetCurrentPageId(0); // 获取水平页面\r
}\r
}\r
buttonNote->SetImageSrc(NOTE_IMAGE, NOTE_IMAGE);
buttonNote->SetOnClickListener(static_cast<UIView::OnClickListener *>(TraingCardPresenter::GetInstance()));
Add(buttonNote);
+
+ //增加上拉卡片
+ SetCoverable(true);
}
/* DeInit:删除组件 */
--- /dev/null
+
+#include "traing/training_card/include/TrainingDetailView.h"
+#include "traing/training_card/include/TraingCardView.h"
+
+#include "common/image_cache_manager.h"
+#include "components/ui_label_ext.h"
+#include "language/font/ui_resource_string.h"
+#include "UiConfig.h"
+#include "ui_resource_image.h"
+#include <ui_scroll_view.h>
+#include "components/ui_button.h"
+#include "traing/include/TraingModel.h"
+#include "traing/Training_UiConfig.h"
+
+namespace OHOS
+{
+
+ static TrainingDetailView *g_pTrainingDetailView{nullptr};
+
+ TrainingDetailView::TrainingDetailView()
+ {
+ SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+ g_pTrainingDetailView = this;
+ }
+ TrainingDetailView::~TrainingDetailView()
+ {
+ RemoveAll();
+ DeInit();
+ g_pTrainingDetailView = nullptr;
+ }
+
+ TrainingDetailView *TrainingDetailView::GetInstance()
+ {
+ return g_pTrainingDetailView;
+ }
+
+ /* InitView:初始化界面*/
+ void TrainingDetailView ::InitView()
+ {
+ // 初始化Image
+ TraingModel::GetInstance()->InitImageView(heartimage, 134, 58, 30, 30, "image1", HEARTRATE_30_IMAGE);
+ TraingModel::GetInstance()->InitImageView(mileimage, 44, 189, 30, 30, "image2", MILEAGE_30_IMAGE);
+ TraingModel::GetInstance()->InitImageView(stepimage, 297, 189, 30, 30, "image3", STEP_30_IMAGE);
+ TraingModel::GetInstance()->InitImageView(calorieimage, 129, 335, 30, 30, "image4", CALORIES_30_IMAGE);
+ TraingModel::GetInstance()->InitImageView(lineimage1_, 0, 160, 10, 466, "image5", LINE_1_IMAGE);
+ TraingModel::GetInstance()->InitImageView(lineimage2_, 233, 193, 80, 20, "image5", LINE_2_IMAGE);
+ TraingModel::GetInstance()->InitImageView(lineimage3_, 0, 306, 10, 466, "image5", LINE_1_IMAGE);
+ Add(heartimage);
+ Add(mileimage);
+ Add(stepimage);
+ Add(calorieimage);
+ Add(lineimage1_);
+ Add(lineimage2_);
+ Add(lineimage3_);
+ // 初始化Lable
+ TraingModel::GetInstance()->InitLabel(u_heartlabel, 174, 60, 90, 35, "label1", "心率(次/分)", DEFAULT_VECTOR_FONT_FILENAME, 26);
+ TraingModel::GetInstance()->InitLabel(u_milelabel, 80, 190, 60, 40, "label2", "距离(公里)", DEFAULT_VECTOR_FONT_FILENAME, 26);
+ TraingModel::GetInstance()->InitLabel(u_stepslabel, 332, 189, 60, 40, "label3", "步数", DEFAULT_VECTOR_FONT_FILENAME, 26);
+ TraingModel::GetInstance()->InitLabel(u_calorielabel, 167, 336, 60, 40, "label4", "卡路里(千卡)", DEFAULT_VECTOR_FONT_FILENAME, 26);
+ TraingModel::GetInstance()->InitLabel(heartlabel, 202, 94, 60, 40, "label5", "144", DEFAULT_VECTOR_FONT_FILENAME, 40);
+ TraingModel::GetInstance()->InitLabel(milelabel, 76, 233, 60, 40, "label6", "13.21", DEFAULT_VECTOR_FONT_FILENAME, 40);
+ TraingModel::GetInstance()->InitLabel(steplabel, 300, 233, 60, 40, "label7", "28312", DEFAULT_VECTOR_FONT_FILENAME, 40);
+ TraingModel::GetInstance()->InitLabel(calorielabel, 175, 376, 60, 40, "label8", "210.03", DEFAULT_VECTOR_FONT_FILENAME, 40);
+ Add(u_heartlabel);
+ Add(u_milelabel);
+ Add(u_stepslabel);
+ Add(u_calorielabel);
+ Add(heartlabel);
+ Add(milelabel);
+ Add(steplabel);
+ Add(calorielabel);
+
+ SetTouchable(true);
+ SetIntercept(true);
+ }
+ /* DeInit:删除组件 */
+ void TrainingDetailView::DeInit()
+ {
+ RemoveAll();
+ if (u_heartlabel != nullptr)
+ {
+ delete u_heartlabel;
+ u_heartlabel = nullptr;
+ }
+ if (u_milelabel != nullptr)
+ {
+ delete u_milelabel;
+ u_milelabel = nullptr;
+ }
+ if (u_stepslabel != nullptr)
+ {
+ delete u_stepslabel;
+ u_stepslabel = nullptr;
+ }
+ if (u_calorielabel != nullptr)
+ {
+ delete u_calorielabel;
+ u_calorielabel = nullptr;
+ }
+ if (heartlabel != nullptr)
+ {
+ delete heartlabel;
+ heartlabel = nullptr;
+ }
+ if (milelabel != nullptr)
+ {
+ delete milelabel;
+ milelabel = nullptr;
+ }
+ if (steplabel != nullptr)
+ {
+ delete steplabel;
+ steplabel = nullptr;
+ }
+ if (calorielabel != nullptr)
+ {
+ delete calorielabel;
+ calorielabel = nullptr;
+ }
+
+ // 删除Image
+ if (heartimage != nullptr)
+ {
+ delete heartimage;
+ heartimage = nullptr;
+ }
+ if (mileimage != nullptr)
+ {
+ delete mileimage;
+ mileimage = nullptr;
+ }
+ if (stepimage != nullptr)
+ {
+ delete stepimage;
+ stepimage = nullptr;
+ }
+ if (calorieimage != nullptr)
+ {
+ delete calorieimage;
+ calorieimage = nullptr;
+ }
+ if (lineimage1_ != nullptr)
+ {
+ delete lineimage1_;
+ lineimage1_ = nullptr;
+ }
+ if (lineimage2_ != nullptr)
+ {
+ delete lineimage2_;
+ lineimage2_ = nullptr;
+ }
+ if (lineimage3_ != nullptr)
+ {
+ delete lineimage3_;
+ lineimage3_ = nullptr;
+ }
+ }
+
+ void TrainingDetailView::PreLoad(void)
+ {
+ if (!viewiInitStatus)
+ {
+ InitView();
+ viewiInitStatus = true;
+ }
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingDetailView");
+ }
+
+ void TrainingDetailView::UnLoad(void) {}
+ /*
+ UILabelExt *TrainingDetailView::GetTimeLabel()
+ {
+ return timerlabel;
+ }
+ */
+
+}
PRINT("CYWEE_MSG_TYPE_NORMAL_UPDATE");
PRINT("activit_mode[%d], steps[%d], distance[%d], calories[%d], step frequency[%d], step length[%d], pace[%d], BMR calories[%d], is_pause[%d],len[%d]\n",
c_result_t.activity_mode,c_result_t.steps,c_result_t.distance,c_result_t.calories,c_result_t.step_frequency,
- c_result_t.step_length,c_result_t.pace,c_result_t.BMR_calories,c_result_t.is_pause,sizeof(c_result_t));
- CustomEventPublish(TOPIC_EVENT_NORMAL_UPDATE,&c_result_t,sizeof(c_result_t));
+ c_result_t.step_length,c_result_t.pace,c_result_t.BMR_calories,c_result_t.is_pause,sizeof(cywee_result_t));
+ CustomEventPublish(TOPIC_EVENT_NORMAL_UPDATE,&c_result_t,sizeof(cywee_result_t));
break;
//跑步机模式
PRINT("CYWEE_MSG_TYPE_TREADMILL_UPDATE");
PRINT("activit_mode[%d], steps[%d], distance[%d], calories[%d], step frequency[%d], step length[%d], pace[%d], BMR calories[%d], is_pause[%d],len[%d]\n",
c_result_t.activity_mode,c_result_t.steps,c_result_t.distance,c_result_t.calories,c_result_t.step_frequency,
- c_result_t.step_length,c_result_t.pace,c_result_t.BMR_calories,c_result_t.is_pause,sizeof(c_result_t));
- CustomEventPublish(TOPIC_EVENT_TREADMILL_UPDATE,&c_result_t,sizeof(c_result_t));
+ c_result_t.step_length,c_result_t.pace,c_result_t.BMR_calories,c_result_t.is_pause,sizeof(cywee_result_t));
+ CustomEventPublish(TOPIC_EVENT_TREADMILL_UPDATE,&c_result_t,sizeof(cywee_result_t));
break;
//户外跑步模式
PRINT("CYWEE_MSG_TYPE_OUTDOOR_RUNNING_UPDATE");
PRINT("activit_mode[%d], steps[%d], distance[%d], calories[%d], step frequency[%d], step length[%d], pace[%d], BMR calories[%d], is_pause[%d],len[%d]\n",
c_result_t.activity_mode,c_result_t.steps,c_result_t.distance,c_result_t.calories,c_result_t.step_frequency,
- c_result_t.step_length,c_result_t.pace,c_result_t.BMR_calories,c_result_t.is_pause,sizeof(c_result_t));
- CustomEventPublish(TOPIC_EVENT_OUTDOOR_RUNNING_UPDATE,&c_result_t,sizeof(c_result_t));
+ c_result_t.step_length,c_result_t.pace,c_result_t.BMR_calories,c_result_t.is_pause,sizeof(cywee_result_t));
+ CustomEventPublish(TOPIC_EVENT_OUTDOOR_RUNNING_UPDATE,&c_result_t,sizeof(cywee_result_t));
break;
//室内跑步模式
PRINT("CYWEE_MSG_TYPE_INDOOR_RUNNING_UPDATE");
PRINT("activit_mode[%d], steps[%d], distance[%d], calories[%d], step frequency[%d], step length[%d], pace[%d], BMR calories[%d], is_pause[%d],len[%d]\n",
c_result_t.activity_mode,c_result_t.steps,c_result_t.distance,c_result_t.calories,c_result_t.step_frequency,
- c_result_t.step_length,c_result_t.pace,c_result_t.BMR_calories,c_result_t.is_pause,sizeof(c_result_t));
- CustomEventPublish(TOPIC_EVENT_INDOOR_RUNNING_UPDATE,&c_result_t,sizeof(c_result_t));
+ c_result_t.step_length,c_result_t.pace,c_result_t.BMR_calories,c_result_t.is_pause,sizeof(cywee_result_t));
+ CustomEventPublish(TOPIC_EVENT_INDOOR_RUNNING_UPDATE,&c_result_t,sizeof(cywee_result_t));
break;
//防误触计步模式
PRINT("CYWEE_MSG_TYPE_FITNESS_PEDOMETERR_UPDATE");
PRINT("activit_mode[%d], steps[%d], distance[%d], calories[%d], step frequency[%d], step length[%d], pace[%d], BMR calories[%d], is_pause[%d],len[%d]\n",
c_result_t.activity_mode,c_result_t.steps,c_result_t.distance,c_result_t.calories,c_result_t.step_frequency,
- c_result_t.step_length,c_result_t.pace,c_result_t.BMR_calories,c_result_t.is_pause,sizeof(c_result_t));
- CustomEventPublish(TOPIC_EVENT_FITNESS_PEDOMETERR_UPDATE,&c_result_t,sizeof(c_result_t));
+ c_result_t.step_length,c_result_t.pace,c_result_t.BMR_calories,c_result_t.is_pause,sizeof(cywee_result_t));
+ CustomEventPublish(TOPIC_EVENT_FITNESS_PEDOMETERR_UPDATE,&c_result_t,sizeof(cywee_result_t));
break;
//自由运动模式
case CYWEE_MSG_TYPE_FREE_TRAINING_UPDATE:
PRINT("CYWEE_MSG_TYPE_FREE_TRAINING_UPDATE");
PRINT("activit_mode[%d], calories[%d], duration[%d],len[%d]\n",
- c_result_t.activity_mode,c_result_t.calories,c_result_t.duration,sizeof(c_result_t));
- CustomEventPublish(TOPIC_EVENT_FREE_TRAINING_UPDATE,&c_result_t,sizeof(c_result_t));
+ c_result_t.activity_mode,c_result_t.calories,c_result_t.duration,sizeof(cywee_result_t));
+ CustomEventPublish(TOPIC_EVENT_FREE_TRAINING_UPDATE,&c_result_t,sizeof(cywee_result_t));
break;
//长时间动作侦测模式
case CYWEE_MSG_TYPE_AR_ALERT_UPDATE:
PRINT("CYWEE_MSG_TYPE_AR_ALERT_UPDATE");
PRINT("activit_mode[%d], ar alert type[%d], len[%d]\n",
- c_result_t.activity_mode,c_result_t.ar_alert_type,sizeof(c_result_t));
- CustomEventPublish(TOPIC_EVENT_AR_ALERT_UPDATE,&c_result_t,sizeof(c_result_t));
+ c_result_t.activity_mode,c_result_t.ar_alert_type,sizeof(cywee_result_t));
+ CustomEventPublish(TOPIC_EVENT_AR_ALERT_UPDATE,&c_result_t,sizeof(cywee_result_t));
break;
//额外信息
case CYWEE_MSG_TYPE_EXTRA_INFO_UPDATE:
PRINT("CYWEE_MSG_TYPE_EXTRA_INFO_UPDATE");
PRINT("average step frequency[%d], average step length[%d], average pace[%d], max step frequency[%d], max pace[%d]\n",
- c_result_t.avg_step_freq,c_result_t.avg_step_len,c_result_t.avg_pace,c_result_t.max_step_freq,c_result_t.max_pace,sizeof(c_result_t));
- CustomEventPublish(TOPIC_EVENT_EXTRA_INFO_UPDATE,&c_result_t,sizeof(c_result_t));
+ c_result_t.avg_step_freq,c_result_t.avg_step_len,c_result_t.avg_pace,c_result_t.max_step_freq,c_result_t.max_pace,sizeof(cywee_result_t));
+ CustomEventPublish(TOPIC_EVENT_EXTRA_INFO_UPDATE,&c_result_t,sizeof(cywee_result_t));
break;
default:
PRINT("Unknown sensor message type");