From: Caisking <3449750381@qq.com> Date: Fri, 1 Dec 2023 05:02:02 +0000 (+0800) Subject: 增加快速训练接口 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=b39f754619ac4f2ea689b588146499f1015e77a8;p=mirrors%2FFD230.git 增加快速训练接口 --- diff --git a/.vscode/settings.json b/.vscode/settings.json index 197abf04b..0041084e6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -14,5 +14,6 @@ "chrono": "cpp", "iostream": "cpp" }, - "cmake.sourceDirectory": "/wsl.localhost/Ubuntu-20.04/home/caiking/FD230/code/sdk/include/driver/security_unified" + "cmake.sourceDirectory": "/wsl.localhost/Ubuntu-20.04/home/caiking/FD230/code/sdk/include/driver/security_unified", + "git.ignoreLimitWarning": true } \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/CMakeLists.txt b/code/sdk/application/wearable/nativeapp/CMakeLists.txt index 93e078453..0a6f6e6e7 100644 --- a/code/sdk/application/wearable/nativeapp/CMakeLists.txt +++ b/code/sdk/application/wearable/nativeapp/CMakeLists.txt @@ -241,6 +241,9 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/heartrate/src/HeartRemindView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/heartrate/src/HeartRemindPresenter.cpp + + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingPresenter.cpp #ָ���� ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/CompassControlView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/CompassCalibrationView.cpp diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h index 24052f7b6..26c764a6c 100644 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h @@ -78,6 +78,7 @@ typedef enum : uint16_t VIEW_TRAINING, // 训练 VIEW_TRAINING_RECORD, // 训练记录 + VIEW_BLOODPRESSURE, // 昨日睡眠时间 VIEW_SLEEPTIME, // 睡眠详细数据 VIEW_SLEEPACT, // 睡眠事项说明 diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h index bb3a4c158..b1bc6a06b 100644 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h @@ -62,6 +62,7 @@ public: void InitPhoneCallingSlice(void); void InitPhoneCallupSlice(void); void InitPhoneRingSlice(void); + void InitTraingSlice(void); void InitUIDisplayBrightnessSlice(void); void InitBlueToothSettingSlice(void); void InitBrightnessControlSlice(void); diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h index 2f30c60fb..411fdc883 100644 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h @@ -260,6 +260,17 @@ namespace OHOS //表盘切换 static constexpr const char *PNG_DIAL_USER_IMAGE = APP_RES_PATH "/Dial/Diallogo.bin"; static constexpr const char *PNG_PHONE_FINGER_IMAGE = APP_RES_PATH "/Save_Ele/finger.bin"; + //快速训练 + static constexpr const char *PNG_TRAING_BOUTTONMORE_IMAGE = APP_RES_PATH "/Training/More.bin"; + static constexpr const char *PNG_TRAING_BUTTONGRONG_IMAGE = APP_RES_PATH "/Training/Bouttonground.bin"; + static constexpr const char *PNG_TRAING_BUTTONGRONG2_IMAGE = APP_RES_PATH "/Training/Buttonground2.bin"; + static constexpr const char *PNG_TRAING_RIDINGBIG_IMAGE = APP_RES_PATH "/Training/riding-big2.bin"; + static constexpr const char *PNG_TRAING_RUNNINGBIG_IMAGE = APP_RES_PATH "/Training/running-big.bin"; + static constexpr const char *PNG_TRAING_WALKINGBIG_IMAGE = APP_RES_PATH "/Training/walking-big.bin"; + //static constexpr const char *PNG_TRAING_BUTTONGRONG1_IMAGE = APP_RES_PATH "/TRAING/More.bin"; + //static constexpr const char *PNG_TRAING_BUTTONGRONG1_IMAGE = APP_RES_PATH "/TRAING/More.bin"; + + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE01 = APP_RES_PATH "/VOICE_ASSISTANT_01.bin"; static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE02 = APP_RES_PATH "/VOICE_ASSISTANT_02.bin"; static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE03 = APP_RES_PATH "/VOICE_ASSISTANT_03.bin"; diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp index a7f913f0c..4c6e8c8d5 100644 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp @@ -101,6 +101,8 @@ #include "dial/include/DialView.h" #include "heartrate/include/HeartRemindPresenter.h" #include "heartrate/include/HeartRemindView.h" +#include "traing/include/TraingPresenter.h" +#include "traing/include/TraingView.h" #include "displaybrightness/include/DisplayBrightnessPresenter.h" #include "displaybrightness/include/DisplayBrightnessView.h" #include "bluetoothofsetting/include/BlueToothOfSettingPresenter.h" @@ -217,6 +219,8 @@ static const AppViewMapper SLICE_MAPPER[] = { {VIEW_DIAL, &NativeLauncher::InitDialSlice}, //表盘 {VIEW_HEARTRATEREMIND, &NativeLauncher::InitHeartRemindSlice}, + {VIEW_TRAINING, &NativeLauncher::InitTraingSlice}, //训练 + {VIEW_DISPLAY_BRIGHTNESS,&NativeLauncher::InitUIDisplayBrightnessSlice}, //显示与亮度的实例化地址 {VIEW_CONNECT_BLUETOOTH,&NativeLauncher::InitBlueToothSettingSlice}, //蓝牙设置的实例化地址 {VIEW_BRIGHTNESS_CONTROL,&NativeLauncher::InitBrightnessControlSlice}, //调节亮度的实例化地址 @@ -774,6 +778,13 @@ void NativeLauncher::InitHeartRemindSlice(void) NativeAbility::GetInstance().AddSliceProxy(VIEW_HEARTRATEREMIND, heartremindview); } +void NativeLauncher::InitTraingSlice(void) +{ + SliceProxy *traingview = new AbilitySliceProxy; + NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAINING, traingview); +} + + //DisplayBrightness的实例化 void NativeLauncher::InitUIDisplayBrightnessSlice(void) { diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingPresenter.h new file mode 100644 index 000000000..042eed1dd --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingPresenter.h @@ -0,0 +1,33 @@ +#ifndef _Traing_PRESENTER_H +#define _Traing_PRESENTER_H + +#include "Presenter.h" +#include "TraingView.h" + +namespace OHOS +{ + class TraingView; + + class TraingPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + TraingPresenter(); + virtual ~TraingPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static TraingPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingView.h b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingView.h new file mode 100644 index 000000000..c4c11507b --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingView.h @@ -0,0 +1,63 @@ +#ifndef _Traing_VIEW_H +#define _Traing_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.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 "wearable_log.h" +#include "ohos_types.h" +#include "components/ui_card_page.h" + +#include "TraingPresenter.h" +namespace OHOS +{ +#define BUTTON1 "button1" // 按键1 +#define BUTTON2 "button2" // 按键2 +#define BUTTON3 "button3" // 按键3 +#define BUTTONMORE "button4" // 按键 更多 + + class TraingPresenter; + class TraingView : public View + { + + public: + TraingView(); + virtual ~TraingView(); + static TraingView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void Init(); + void DeInit(); + + UIView *GetView(); + + private: + UIView::OnDragListener *draglistener{nullptr}; + TraingView(TraingView &&) = delete; + TraingView &operator=(TraingView &&) = delete; + + UIViewGroup *container_ = nullptr; + UILabel *label1_ = nullptr; + UIButton *button3_ = nullptr; + UIButton *button4_ = nullptr; + UIButton *button1_ = nullptr; + UIButton *button2_ = nullptr; + UIImageView *image1_ = nullptr; + UILabel *label2_ = nullptr; + UIImageView *image3_ = nullptr; + UILabel *label3_ = nullptr; + UIImageView *image5_ = nullptr; + UILabel *label4_ = nullptr; + }; +} // namespace OHOS +#endif // Traing_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingPresenter.cpp new file mode 100644 index 000000000..7a4bbc234 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingPresenter.cpp @@ -0,0 +1,84 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include +#include +#include +#include "traing/include/TraingPresenter.h" +//#include "TraingView.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static TraingPresenter *g_pTraingPresenter = nullptr; + + TraingPresenter::TraingPresenter() + { + + g_pTraingPresenter = this; + } + + TraingPresenter::~TraingPresenter() + { + + g_pTraingPresenter = nullptr; + } + + TraingPresenter *TraingPresenter::GetInstance() + { + + return g_pTraingPresenter; + } + + void TraingPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void TraingPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void TraingPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void TraingPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool TraingPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + if (event.GetDragDirection() == DragEvent::DIRECTION_RIGHT_TO_LEFT) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + } + UNUSED(view); + return true; + } + + bool TraingPresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), BUTTON1) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + } + if (strcmp(view.GetViewId(), "Remind") == 0) + { + // 模拟心率监测,等待20秒 + //std::this_thread::sleep_for(std::chrono::seconds(20)); + //NativeAbility::GetInstance().ChangeSlice(VIEW_TraingREMIND); + } + return true; + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingView.cpp new file mode 100644 index 000000000..86c9f1f24 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingView.cpp @@ -0,0 +1,425 @@ + +#include "traing/include/TraingView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +namespace OHOS +{ + static TraingView *g_pTraingView{nullptr}; + + TraingView::TraingView() + { + + g_pTraingView = this; + } + + TraingView::~TraingView() + { + DeInit(); + g_pTraingView = nullptr; + } + + TraingView *TraingView::GetInstance() + { + + return g_pTraingView; + } + + void TraingView::Init() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(173, 52); // widget's left position and top position + label1_->Resize(200, 60); // widget's width and height + label1_->SetViewId("label1"); // Set style + label1_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label1_->SetText("快速训练"); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetRollSpeed(0); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + container_->Add(label1_); + label1_->SetVisible(true); + + // Add Button to App + if (button3_ == nullptr) + { + button3_ = new UIButton(); + } + button3_->SetPosition(236, 268); // widget's left position and top position + button3_->Resize(140, 140); // widget's width and height + button3_->SetViewId(BUTTONMORE); // Set style + button3_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button3_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property +#ifdef _WIN32 + char *button3defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Training/More.bin"; +#else + const char *button3defaultImgSrc = PNG_TRAING_BOUTTONMORE_IMAGE; +#endif + char *button3triggeredImgSrc = nullptr; + button3_->SetImageSrc(button3defaultImgSrc, button3triggeredImgSrc); + button3_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff33df1c, UIButton::PRESSED); + button3_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + button3_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button3Click = static_cast(TraingPresenter::GetInstance()); + button3_->SetOnClickListener(button3Click); + // Add to rootView + container_->Add(button3_); + button3_->SetVisible(true); + + // Add Button to App + if (button4_ == nullptr) + { + button4_ = new UIButton(); + } + button4_->SetPosition(86, 118); // widget's left position and top position + button4_->Resize(140, 140); // widget's width and height + button4_->SetViewId(BUTTON2); // Set style + button4_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button4_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property +#ifdef _WIN32 + char *button4defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Training/Buttonground2.bin"; +#else + const char *button4defaultImgSrc = PNG_TRAING_BUTTONGRONG2_IMAGE; +#endif + char *button4triggeredImgSrc = nullptr; + button4_->SetImageSrc(button4defaultImgSrc, button4triggeredImgSrc); + button4_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff33df1c, UIButton::PRESSED); + button4_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + button4_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button4Click = static_cast(TraingPresenter::GetInstance()); + button4_->SetOnClickListener(button4Click); + // Add to rootView + container_->Add(button4_); + button4_->SetVisible(true); + + // Add Button to App + if (button1_ == nullptr) + { + button1_ = new UIButton(); + } + button1_->SetPosition(86, 268); // widget's left position and top position + button1_->Resize(140, 140); // widget's width and height + button1_->SetViewId(BUTTON3); // Set style + button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property +#ifdef _WIN32 + char *button1defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Training/Bouttonground.bin"; +#else + const char *button1defaultImgSrc = PNG_TRAING_BUTTONGRONG_IMAGE; +#endif + char *button1triggeredImgSrc = nullptr; + button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); + button1_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff33df1c, UIButton::PRESSED); + button1_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button1Click = static_cast(TraingPresenter::GetInstance()); + button1_->SetOnClickListener(button1Click); + // Add to rootView + container_->Add(button1_); + button1_->SetVisible(true); + + // Add Button to App + if (button2_ == nullptr) + { + button2_ = new UIButton(); + } + button2_->SetPosition(236, 118); // widget's left position and top position + button2_->Resize(140, 140); // widget's width and height + button2_->SetViewId(BUTTON1); // Set style + button2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property +#ifdef _WIN32 + char *button2defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Training/Bouttonground.bin"; +#else + const char *button2defaultImgSrc = PNG_TRAING_BUTTONGRONG_IMAGE; +#endif + char *button2triggeredImgSrc = nullptr; + button2_->SetImageSrc(button2defaultImgSrc, button2triggeredImgSrc); + button2_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff33df1c, UIButton::PRESSED); + button2_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + button2_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button2Click = static_cast(TraingPresenter::GetInstance()); + button2_->SetOnClickListener(button2Click); + // Add to rootView + container_->Add(button2_); + button2_->SetVisible(true); + + // Add ImageView to App + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(276, 148); // widget's left position and top position + image1_->Resize(100, 100); // widget's width and height + image1_->SetViewId("image2"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Training/riding-big2.bin"; +#else + const char *image1imagesPath = PNG_TRAING_RIDINGBIG_IMAGE; +#endif + image1_->SetSrc(image1imagesPath); + + // Add to rootView + container_->Add(image1_); + image1_->SetVisible(true); + + // Add Label to App + if (label2_ == nullptr) + { + label2_ = new UILabel(); + } + label2_->SetPosition(286, 210); // widget's left position and top position + label2_->Resize(200, 60); // widget's width and height + label2_->SetViewId("label2"); // Set style + label2_->SetStyle(STYLE_TEXT_FONT, 20); + + // Set additional property + label2_->SetText("骑行"); + label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label2_->SetRollSpeed(0); + label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + + // Add to rootView + container_->Add(label2_); + label2_->SetVisible(true); + + // Add ImageView to App + if (image3_ == nullptr) + { + image3_ = new UIImageView(); + } + image3_->SetPosition(126, 298); // widget's left position and top position + image3_->Resize(100, 100); // widget's width and height + image3_->SetViewId("image3"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image3imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Training/running-big.bin"; +#else + const char *image3imagesPath = PNG_TRAING_RUNNINGBIG_IMAGE; +#endif + image3_->SetSrc(image3imagesPath); + + // Add to rootView + container_->Add(image3_); + image3_->SetVisible(true); + + // Add Label to App + if (label3_ == nullptr) + { + label3_ = new UILabel(); + } + label3_->SetPosition(135, 210); // widget's left position and top position + label3_->Resize(200, 60); // widget's width and height + label3_->SetViewId("label3"); // Set style + label3_->SetStyle(STYLE_TEXT_FONT, 20); + + // Set additional property + label3_->SetText("健走"); + label3_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label3_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label3_->SetRollSpeed(0); + label3_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + + // Add to rootView + container_->Add(label3_); + label3_->SetVisible(true); + + // Add ImageView to App + if (image5_ == nullptr) + { + image5_ = new UIImageView(); + } + image5_->SetPosition(126, 148); // widget's left position and top position + image5_->Resize(100, 100); // widget's width and height + image5_->SetViewId("image1"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image5imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Training/walking-big.bin"; +#else + const char *image5imagesPath = PNG_TRAING_WALKINGBIG_IMAGE; +#endif + image5_->SetSrc(image5imagesPath); + + // Add to rootView + container_->Add(image5_); + image5_->SetVisible(true); + + // Add Label to App + if (label4_ == nullptr) + { + label4_ = new UILabel(); + } + label4_->SetPosition(131, 365); // widget's left position and top position + label4_->Resize(200, 60); // widget's width and height + label4_->SetViewId("label4"); // Set style + label4_->SetStyle(STYLE_TEXT_FONT, 20); + + // Set additional property + label4_->SetText("跑步"); + label4_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label4_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label4_->SetRollSpeed(0); + label4_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + + // Add to rootView + container_->Add(label4_); + label4_->SetVisible(true); + } + + void TraingView::DeInit() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (button3_ != nullptr) + { + delete button3_; + button3_ = nullptr; + } + if (button4_ != nullptr) + { + delete button4_; + button4_ = nullptr; + } + if (button1_ != nullptr) + { + delete button1_; + button1_ = nullptr; + } + if (button2_ != nullptr) + { + delete button2_; + button2_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + if (label2_ != nullptr) + { + delete label2_; + label2_ = nullptr; + } + if (image3_ != nullptr) + { + delete image3_; + image3_ = nullptr; + } + if (label3_ != nullptr) + { + delete label3_; + label3_ = nullptr; + } + if (image5_ != nullptr) + { + delete image5_; + image5_ = nullptr; + } + if (label4_ != nullptr) + { + delete label4_; + label4_ = nullptr; + } + } + + UIView *TraingView::GetView() + { + Init(); + return container_; + } + + void TraingView::OnStart() + { + container_ = new UIViewGroup(); + if (container_ == nullptr) + { + return; + } + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + + // 创建 draglistener 实例并设置为拖动监听器 + UIView::OnDragListener *draglistener = static_cast(TraingPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + GetView(); + RootView::GetInstance()->Add(container_); + } + + void TraingView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void TraingView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void TraingView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +}