From: Caisking <3449750381@qq.com> Date: Tue, 16 Jan 2024 08:17:36 +0000 (+0800) Subject: 增加训练卡片 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=bd3ab7a031a71396bf074777abd9d8e0c87b306c;p=mirrors%2FFD230.git 增加训练卡片 --- diff --git a/code/sdk/application/wearable/nativeapp/CMakeLists.txt b/code/sdk/application/wearable/nativeapp/CMakeLists.txt index dc557da50..c1a97cafe 100755 --- a/code/sdk/application/wearable/nativeapp/CMakeLists.txt +++ b/code/sdk/application/wearable/nativeapp/CMakeLists.txt @@ -46,6 +46,8 @@ set(PRIVATE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/../service/smart_voice/voice_engine_hal/interfaces/innerkits/native_c/include ${CMAKE_CURRENT_SOURCE_DIR}/../ohos_deps ${CMAKE_CURRENT_SOURCE_DIR}/../../battery + ${CMAKE_CURRENT_SOURCE_DIR}/../../../drivers/drivers/driver/rtc_unified + ${CMAKE_CURRENT_SOURCE_DIR}/../../../kernel/liteos/liteos_v207.1.0/Huawei_LiteOS/compat/linux/include/uapi/linux/ ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/src/utils/innerkits ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/include @@ -250,7 +252,7 @@ set(SOURCES ${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/traing/src/TraingMoreView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingMorePresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingLimitView.cpp diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h index 2dc381c3b..159a0fa04 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h @@ -77,7 +77,7 @@ typedef enum : uint16_t VIEW_HEARTRATEREMIND, // 心率提醒 - VIEW_TRAINING, // 训练 + //VIEW_TRAINING, // 训练 VIEW_TRAININGMORE, // 更多训练 VIEW_TRAININGLIMIT, // 极限运动子列表 VIEW_TRAININGNOMAL, // 正常训练开始界面(除骑行,健走,跑步外) diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp index d91b014d4..1206c632e 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp @@ -102,7 +102,7 @@ #include "heartrate/include/HeartRemindPresenter.h" #include "heartrate/include/HeartRemindView.h" -#include "traing/include/TraingPresenter.h" + #include "traing/include/TraingView.h" #include "traing/include/TraingMorePresenter.h" #include "traing/include/TraingMoreView.h" @@ -294,7 +294,7 @@ static const AppViewMapper SLICE_MAPPER[] = { {VIEW_HEARTRATEREMIND, &NativeLauncher::InitHeartRemindSlice}, - {VIEW_TRAINING, &NativeLauncher::InitTraingSlice}, //训练 + //{VIEW_TRAINING, &NativeLauncher::InitTraingSlice}, //训练 {VIEW_TRAININGMORE, &NativeLauncher::InitTraingMoreSlice}, //更多训练 {VIEW_TRAININGLIMIT, &NativeLauncher::InitTraingLimitSlice}, //极限训练 {VIEW_TRAININGNOMAL, &NativeLauncher::InitTraingNomalSlice}, //正常训练初始界面 @@ -900,11 +900,11 @@ void NativeLauncher::InitHeartRemindSlice(void) } //体能训练 -void NativeLauncher::InitTraingSlice(void) -{ - SliceProxy *traingview = new AbilitySliceProxy; - NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAINING, traingview); -} +// void NativeLauncher::InitTraingSlice(void) +// { +// SliceProxy *traingview = new AbilitySliceProxy; +// NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAINING, traingview); +// } void NativeLauncher::InitTraingMoreSlice(void) { SliceProxy *traingmoreview = new AbilitySliceProxy; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/UIInitializer/UIInitializer.cpp b/code/sdk/application/wearable/nativeapp/nativeui/UIInitializer/UIInitializer.cpp index a81a6e093..df94f14ce 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/UIInitializer/UIInitializer.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/UIInitializer/UIInitializer.cpp @@ -35,7 +35,7 @@ namespace OHOS label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); label->SetRollSpeed(0); // 设置标签可见 - label->SetVisible(true); + //label->SetVisible(true); } /** diff --git a/code/sdk/application/wearable/nativeapp/nativeui/applist/src/ApplistModel.cpp b/code/sdk/application/wearable/nativeapp/nativeui/applist/src/ApplistModel.cpp index ea03f2a80..96cdfd350 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/applist/src/ApplistModel.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/applist/src/ApplistModel.cpp @@ -35,7 +35,7 @@ namespace OHOS {VIEW_MAIN_COUNTDOWN, PNG_APPLIST_COUNTDOWN_IMAGE, PNG_APPLIST_COUNTDOWN_IMAGE, "计时器", nullptr}, {VIEW_BLOODOXY_SAMPLE, PNG_APPLIST_SPO2_IMAGE, PNG_APPLIST_SPO2_IMAGE, "血氧饱和度", nullptr}, {VIEW_INDOORWALK, PNG_APPLIST_WALK_IMAGE, PNG_APPLIST_WALK_IMAGE, "室内步行", nullptr}, - {VIEW_TRAINING, PNG_APPLIST_TRAINING_IMAGE, PNG_APPLIST_TRAINING_IMAGE, "体能训练", nullptr}, + //{VIEW_TRAINING, PNG_APPLIST_TRAINING_IMAGE, PNG_APPLIST_TRAINING_IMAGE, "体能训练", nullptr}, //{VIEW_TRAINING_RECORD, PNG_APPLIST_TRAINING_RECORD_IMAGE, PNG_APPLIST_TRAINING_RECORD_IMAGE, "训练记录", nullptr}, {VIEW_OFFLINEVOICE, PNG_APPLIST_VOCASSIST_IMAGE, PNG_APPLIST_VOCASSIST_IMAGE, "语音助手", nullptr}, {VIEW_BLOODPRESSURE, PNG_APPLIST_BLOODPRESSURE_IMAGE, PNG_APPLIST_BLOODPRESSURE_IMAGE, "睡眠监测", nullptr}, diff --git a/code/sdk/application/wearable/nativeapp/nativeui/dial/src/Digital_clockView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/dial/src/Digital_clockView.cpp index 6b24e8a5d..43234bb96 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/dial/src/Digital_clockView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/dial/src/Digital_clockView.cpp @@ -26,10 +26,18 @@ #include #include // 用于格式化输出 #include //异常处理 +#include "timer.h" +#include "uapi/linux/rtc.h" +#include +#include #include "MainViewSample.h" #define PRINT_DEBUG_INFO printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__); +extern "C" +{ + int rtc_tm_to_time(struct rtc_time *tm, unsigned long *time); +} namespace OHOS { @@ -250,7 +258,25 @@ namespace OHOS Add(backgroundAnimator); // backgroundAnimator->SetVisible(true); } - stringtime = "11:54"; + + /* -------------------------------------------------------------------------- */ + struct tm local_time; + time_t seconds; + seconds = time(NULL); + if (localtime_r(&seconds, &local_time) == NULL) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Digital_clockView::Digital_clockView get localtime error!"); + return false; + } + std::ostringstream ostrHour, ostMin; + ostrHour << local_time.tm_hour; + ostMin << local_time.tm_min; + std::string weekStr = ostrHour.str() + ":" + ostMin.str(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "time = %s!", weekStr.c_str()); + printf("weekStr:%s\n",weekStr.c_str()); + /* -------------------------------------------------------------------------- */ + stringtime = "11:35"; + // updateClockTime(stringtime); cJSON *digits = cJSON_GetObjectItem(cjson_json, "digits"); std::string playformat = cJSON_GetObjectItem(digits, "playformat")->valuestring; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h index e9753612a..24c3f76b1 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h @@ -1,12 +1,12 @@ -/*** +/*** * @Author: Caisking 3449750381@qq.com * @Date: 2023-12-12 16:55:29 * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-01-15 17:19:52 + * @LastEditTime: 2024-01-16 15:37:18 * @FilePath: /1.FD230/FD230/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h - * @Description: + * @Description: * @ - * @Copyright (c) 2024 by Caisking , All Rights Reserved. + * @Copyright (c) 2024 by Caisking , All Rights Reserved. */ /* * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. @@ -40,69 +40,75 @@ #include "components/ui_cross_view.h" #include "dial/include/Digital_clockView.h" #include "blood/include/BloodView.h" -namespace OHOS { -class MainPresenterSample; -class MainViewSample : public View { -public: - MainViewSample(); - virtual ~MainViewSample(); - static MainViewSample *GetInstance(void); - void OnStart() override; - void OnSetUpView() override; - void OnTearDownView() override; - void OnStop() override; - UICardPage *InitWatchFacePage(void); - UICardPage *InitHeartRatePage(void); - UICardPage *InitActivityPage(void); - UICardPage *InitCompassPage(void); - UICardPage *InitMusicPlayerPage(void); - UICardPage *InitNewDialPage(void); - UICardPage *InitBloodOxygenPage(void); - - void AnimatorStart(int pageIndex); - void AnimatorStop(void); - uint16_t GetHorCurrentPage() const +#include "traing/include/TraingView.h" +namespace OHOS +{ + class MainPresenterSample; + class MainViewSample : public View { - return mainSwipeGroup->GetCurrentPageId(UISwipeView::HORIZONTAL); // 0: horizontal; 1: vertical - } + public: + MainViewSample(); + virtual ~MainViewSample(); + static MainViewSample *GetInstance(void); + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + UICardPage *InitWatchFacePage(void); + UICardPage *InitHeartRatePage(void); + UICardPage *InitActivityPage(void); + UICardPage *InitCompassPage(void); + UICardPage *InitMusicPlayerPage(void); + UICardPage *InitNewDialPage(void); + UICardPage *InitBloodOxygenPage(void); + UICardPage *InitTrainingPage(void); - UIView* GetMainViewGroup(void) const - { - return mainSwipeGroup; - } + void AnimatorStart(int pageIndex); + void AnimatorStop(void); + uint16_t GetHorCurrentPage() const + { + return mainSwipeGroup->GetCurrentPageId(UISwipeView::HORIZONTAL); // 0: horizontal; 1: vertical + } + + UIView *GetMainViewGroup(void) const + { + return mainSwipeGroup; + } + + bool IsMainView(void); + void SetDragFg(bool continFg); + bool GetDragFg(void); + + private: + int16_t maxPage{0}; + bool continuDragFg{false}; + PullUpDownView *dropDownView{nullptr}; + UICardPage *messageView{nullptr}; + UILabel *messageLable{nullptr}; + + /* -------------------------------------------------------------------------- */ + Digital_clockView *mainClockView{nullptr}; + ActivityWeekView *activityWeekView{nullptr}; + PlayersView *playersView{nullptr}; + /* -------------------------------------------------------------------------- */ - bool IsMainView(void); - void SetDragFg(bool continFg); - bool GetDragFg(void); - -private: - - int16_t maxPage{0}; - bool continuDragFg{false}; - PullUpDownView *dropDownView{nullptr}; - UICardPage *messageView{nullptr}; - UILabel *messageLable{nullptr}; - - /* -------------------------------------------------------------------------- */ - Digital_clockView *mainClockView{nullptr}; - ActivityWeekView *activityWeekView{nullptr}; - PlayersView *playersView{nullptr}; - /* -------------------------------------------------------------------------- */ + CompassControlView *compassControlView{nullptr}; + HeartRateView *heartRateView{nullptr}; + Digital_clockView *dialView{nullptr}; + BloodView *bloodView{nullptr}; + TraingView *traingView{nullptr}; - CompassControlView *compassControlView{nullptr}; - HeartRateView *heartRateView{nullptr}; - Digital_clockView*dialView{nullptr}; - BloodView*bloodView{nullptr}; - UICardPage *recordCard[MAX_CARD]{nullptr}; - bool pageStatus[MAX_CARD]{false}; - UICrossView *mainSwipeGroup{nullptr}; - ZoomEffect* callback{nullptr}; + /* -------------------------------------------------------------------------- */ + UICardPage *recordCard[MAX_CARD]{nullptr}; + bool pageStatus[MAX_CARD]{false}; + UICrossView *mainSwipeGroup{nullptr}; + ZoomEffect *callback{nullptr}; - bool HorizontalViewInit(void); - void VerticalViewInit(void); - void VertViewLoad(void); - void HorViewLoad(void); - UICardPage *CreatePage(int32_t cardId); -}; + bool HorizontalViewInit(void); + void VerticalViewInit(void); + void VertViewLoad(void); + void HorViewLoad(void); + UICardPage *CreatePage(int32_t cardId); + }; } // namespace OHOS #endif // MAIN_VIEW_SAMPLE_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp index e5b1fae9a..26991d97b 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp @@ -40,6 +40,7 @@ namespace OHOS {HEART_RATE, &MainViewSample::InitHeartRatePage}, {COMPASS, &MainViewSample::InitCompassPage}, {BloodOxygen, &MainViewSample::InitBloodOxygenPage}, + {TRAINING, &MainViewSample::InitTrainingPage}, }; MainViewSample::MainViewSample() @@ -362,7 +363,18 @@ namespace OHOS } return bloodView; } - + // 主界面训练卡片 + UICardPage *MainViewSample::InitTrainingPage(void) + { + traingView = new TraingView(); + if (traingView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "traingView new fail"); + return nullptr; + } + return traingView; + } + /* -------------------------------------------------------------------------- */ UICardPage *MainViewSample::CreatePage(int32_t StreamId) { uint16_t i; @@ -372,7 +384,7 @@ namespace OHOS for (i = 0; i < sizeof(PageMapper) / sizeof(PageMapper[0]); i++) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::CreatePage PageMapper[i].id=%d, cardId=%d, StreamId=%d", PageMapper[i].id, cardId, StreamId); - //printf("MainViewSample::CreatePage PageMapper[i].id=%d, cardId=%d, StreamId=%d\n", PageMapper[i].id, cardId, StreamId); + printf("MainViewSample::CreatePage PageMapper[i].id=%d, cardId=%d, StreamId=%d\n", PageMapper[i].id, cardId, StreamId); if (PageMapper[i].id == cardId) { view = (this->*(PageMapper[i].func))(); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/screensetting/include/ScreenModels.h b/code/sdk/application/wearable/nativeapp/nativeui/screensetting/include/ScreenModels.h index 50063c540..51f53926e 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/screensetting/include/ScreenModels.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/screensetting/include/ScreenModels.h @@ -1,12 +1,12 @@ -/*** +/*** * @Author: Caisking 3449750381@qq.com * @Date: 2023-12-15 14:33:22 * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-01-15 19:34:47 + * @LastEditTime: 2024-01-16 15:56:24 * @FilePath: /1.FD230/FD230/code/sdk/application/wearable/nativeapp/nativeui/screensetting/include/ScreenModels.h - * @Description: + * @Description: * @ - * @Copyright (c) 2024 by Caisking , All Rights Reserved. + * @Copyright (c) 2024 by Caisking , All Rights Reserved. */ #ifndef SCREEN_MODEL_H @@ -21,6 +21,7 @@ namespace OHOS { NEW_DAIL = 0, HEART_RATE, + TRAINING, COMPASS, BloodOxygen, MAX_CARD, diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingPresenter.h deleted file mode 100755 index 042eed1dd..000000000 --- a/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingPresenter.h +++ /dev/null @@ -1,33 +0,0 @@ -#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 index c4c11507b..bc624e90a 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingView.h @@ -1,3 +1,13 @@ +/*** + * @Author: Caisking 3449750381@qq.com + * @Date: 2023-12-12 16:55:27 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-01-16 14:43:12 + * @FilePath: /1.FD230/FD230/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingView.h + * @Description: + * @ + * @Copyright (c) 2024 by Caisking , All Rights Reserved. + */ #ifndef _Traing_VIEW_H #define _Traing_VIEW_H @@ -15,16 +25,14 @@ #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 BUTTON1 "button1" // 按键1 +#define BUTTON2 "button2" // 按键2 +#define BUTTON3 "button3" // 按键3 #define BUTTONMORE "button4" // 按键 更多 - class TraingPresenter; - class TraingView : public View + class TraingView : public UICardPage { public: @@ -32,32 +40,32 @@ namespace OHOS virtual ~TraingView(); static TraingView *GetInstance(void); - void OnStart() override; - void OnSetUpView() override; - void OnTearDownView() override; - void OnStop() override; - void Init(); + bool InitView(); void DeInit(); - UIView *GetView(); + bool AddButton(); + bool InitImage(); + bool InitLable(); + + void PreLoad(void) override; + void UnLoad(void) override; 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; + UILabelButtonExt *Button1 = nullptr; + UILabelButtonExt *Button2 = nullptr; + UILabelButtonExt *Button3 = nullptr; + UILabelButtonExt *ButtonMore = nullptr; + + UILabel *titleLabel = nullptr; + UIImageView *image1 = nullptr; + UIImageView *image2 = nullptr; + UIImageView *image3 = nullptr; + UIImageView *imagemore = nullptr; + bool viewiInitStatus{false}; }; } // namespace OHOS #endif // Traing_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingEnddataPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingEnddataPresenter.cpp index e1fd4f542..f469d6de9 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingEnddataPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingEnddataPresenter.cpp @@ -72,7 +72,7 @@ namespace OHOS // 根据控件id查找是哪个控件触发了点击回调 if (strcmp(view.GetViewId(), BUTTONBACK) == 0) { - NativeAbility::GetInstance().ChangeSlice(VIEW_TRAINING); + //NativeAbility::GetInstance().ChangeSlice(VIEW_TRAINING); } return true; } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingEndnote2Presenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingEndnote2Presenter.cpp index 7fd64f605..ae8c85959 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingEndnote2Presenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingEndnote2Presenter.cpp @@ -76,7 +76,7 @@ namespace OHOS } if (strcmp(view.GetViewId(), BUTTONYES) == 0) { - NativeAbility::GetInstance().ChangeSlice(VIEW_TRAINING); + //NativeAbility::GetInstance().ChangeSlice(VIEW_TRAINING); } return true; } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSPresenter.cpp index c436678eb..8bb2633bc 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSPresenter.cpp @@ -62,7 +62,7 @@ namespace OHOS (event.GetDeltaX() > 40) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) { uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - NativeAbility::GetInstance().ChangeSlice(VIEW_TRAINING); + //NativeAbility::GetInstance().ChangeSlice(VIEW_TRAINING); } UNUSED(view); return true; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSlackPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSlackPresenter.cpp index 624a24637..8887c5338 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSlackPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSlackPresenter.cpp @@ -1,3 +1,13 @@ +/*** + * @Author: Caisking 3449750381@qq.com + * @Date: 2023-12-12 16:55:28 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-01-16 15:44:47 + * @FilePath: /1.FD230/FD230/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSlackPresenter.cpp + * @Description: + * @ + * @Copyright (c) 2024 by Caisking , All Rights Reserved. + */ #include "AppViewIDs.h" #include "NativeAbility.h" @@ -62,7 +72,7 @@ namespace OHOS (event.GetDeltaX() > 40) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) { uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - NativeAbility::GetInstance().ChangeSlice(VIEW_TRAINING); + //NativeAbility::GetInstance().ChangeSlice(VIEW_TRAINING); } UNUSED(view); return true; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingMorePresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingMorePresenter.cpp index 5b6f363ac..44119bfec 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingMorePresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingMorePresenter.cpp @@ -61,7 +61,7 @@ namespace OHOS if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && (event.GetDeltaX() > 40) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) { - NativeAbility::GetInstance().ChangeSlice(VIEW_TRAINING); + //NativeAbility::GetInstance().ChangeSlice(VIEW_TRAINING); } UNUSED(view); return true; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingPresenter.cpp deleted file mode 100755 index f090fc82d..000000000 --- a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingPresenter.cpp +++ /dev/null @@ -1,91 +0,0 @@ -#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_LEFT_TO_RIGHT && - (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) - { - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); - } - UNUSED(view); - return true; - } - - bool TraingPresenter::OnClick(UIView &view, const ClickEvent &event) - { - // 根据控件id查找是哪个控件触发了点击回调 - if (strcmp(view.GetViewId(), BUTTONMORE) == 0) - { - NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGMORE); - } - if (strcmp(view.GetViewId(), BUTTON1) == 0) - { - NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGGPS); - } - if (strcmp(view.GetViewId(), BUTTON2) == 0) - { - NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGGPSLACK); - } - if (strcmp(view.GetViewId(), BUTTON3) == 0) - { - NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGGPS); - } - 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 index d1a38ef9c..3d43b9f1f 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingView.cpp @@ -6,14 +6,15 @@ #include "ui_resource_image.h" #include #include "components/ui_button.h" -#include "UIInitializer.h" +#include "components/ui_view_group.h" + namespace OHOS { static TraingView *g_pTraingView{nullptr}; TraingView::TraingView() { - + SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); g_pTraingView = this; } @@ -25,409 +26,258 @@ namespace OHOS TraingView *TraingView::GetInstance() { - return g_pTraingView; } - - void TraingView::Init() + bool TraingView::AddButton() { - if (container_ == nullptr) + std::string traing1 = "健走"; + std::string traing2 = "骑行"; + std::string traing3 = "跑步"; + std::string traingmore = "更多"; + /* -------------------------------------------------------------------------- */ + if (Button1 == nullptr) { - container_ = new UIViewGroup(); - container_->SetPosition(0, 0, 466, 466); - container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + Button1 = new UILabelButtonExt(); } - - /* Add Label to App - if (label1_ == nullptr) + Button1->SetPosition(86, 118); // widget's left position and top position + Button1->Resize(140, 140); // widget's width and height + Button1->SetViewId(BUTTON1); // Set style + + const char *labelButton1defaultImgSrc = PNG_TRAING_BUTTONGRONG2_IMAGE; + char *labelButton1triggeredImgSrc = nullptr; + Button1->SetImageSrc(labelButton1defaultImgSrc, labelButton1triggeredImgSrc); + Button1->SetText(traing1.c_str()); + Button1->SetLabelPosition(0, 70); + Button1->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + Button1->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff19ff41, UIButton::PRESSED); + Button1->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // UIView::OnClickListener *labelButton1Click = static_cast(new Labelbutton1OnClickListener()); + // Button1->SetOnClickListener(labelButton1Click); + Add(Button1); + /* -------------------------------------------------------------------------- */ + if (Button2 == nullptr) { - label1_ = new UILabel(); + Button2 = new UILabelButtonExt(); } - 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); + Button2->SetPosition(236, 118); // widget's left position and top position + Button2->Resize(140, 140); // widget's width and height + Button2->SetViewId(BUTTON2); // Set style // 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); - */ - - // 创建一个 ComponentConfig 结构体实例 - UILabelConfig labelConfig = {173, 52, 200, 60, "label1", "快速训练", DEFAULT_VECTOR_FONT_FILENAME, 30}; - - // 使用 UIInitializer 类中的初始化函数来初始化标签 - UIInitializer::InitLabel(label1_, labelConfig); - - // Add Button to App - if (button3_ == nullptr) + const char *labelButton2defaultImgSrc = PNG_TRAING_BUTTONGRONG_IMAGE; + char *labelButton2triggeredImgSrc = nullptr; + Button2->SetImageSrc(labelButton2defaultImgSrc, labelButton2triggeredImgSrc); + Button2->SetText(traing2.c_str()); + Button2->SetLabelPosition(0, 70); + Button2->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + Button2->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff19ff41, UIButton::PRESSED); + Button2->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // UIView::OnClickListener *labelButton2Click = static_cast(new Labelbutton1OnClickListener()); + // Button2->SetOnClickListener(labelButton2Click); + Add(Button2); + /* -------------------------------------------------------------------------- */ + if (Button3 == nullptr) { - button3_ = new UIButton(); + Button3 = new UILabelButtonExt(); } - 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); - + Button3->SetPosition(86, 268); // widget's left position and top position + Button3->Resize(140, 140); // widget's width and height + Button3->SetViewId(BUTTON3); // 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 + const char *button3defaultImgSrc = PNG_TRAING_BUTTONGRONG_IMAGE; 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); + Button3->SetImageSrc(button3defaultImgSrc, button3triggeredImgSrc); + Button3->SetText(traing3.c_str()); + Button3->SetLabelPosition(0, 70); + Button3->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + Button3->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff19ff41, UIButton::PRESSED); + Button3->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // UIView::OnClickListener *button1Click = static_cast(TraingPresenter::GetInstance()); + // Button3->SetOnClickListener(button1Click); + Add(Button3); + /* -------------------------------------------------------------------------- */ // Add Button to App - if (button4_ == nullptr) + if (ButtonMore == nullptr) { - button4_ = new UIButton(); + ButtonMore = new UILabelButtonExt(); } - 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); + ButtonMore->SetPosition(236, 268); // widget's left position and top position + ButtonMore->Resize(140, 140); // widget's width and height + ButtonMore->SetViewId(BUTTONMORE); // Set style + ButtonMore->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + ButtonMore->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 + const char *button4defaultImgSrc = PNG_TRAING_BOUTTONMORE_IMAGE; 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) + ButtonMore->SetImageSrc(button4defaultImgSrc, button4triggeredImgSrc); + //ButtonMore->SetText(traingmore.c_str()); + ButtonMore->SetLabelPosition(0, 70); + ButtonMore->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + ButtonMore->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff19ff41, UIButton::PRESSED); + ButtonMore->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // UIView::OnClickListener *button4Click = static_cast(TraingPresenter::GetInstance()); + // ButtonMore->SetOnClickListener(button4Click); + Add(ButtonMore); + + return true; + } + bool TraingView::InitLable() + { + // 检查标签指针是否为空 + if (titleLabel == nullptr) { - button2_ = new UIButton(); + titleLabel = new UILabel(); } - 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); - + // 设置标签的位置和大小 + titleLabel->SetPosition(173, 52); + titleLabel->Resize(200, 60); + // 设置标签的视图 ID + titleLabel->SetViewId("titleLabel"); + // 设置标签的样式 + titleLabel->SetStyle(STYLE_TEXT_FONT, 30); + titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // 设置标签的文本和其他属性 + titleLabel->SetText("快速训练"); + titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + titleLabel->SetRollSpeed(0); + Add(titleLabel); + + return true; + } + bool TraingView::InitImage() + { // Add ImageView to App - if (image1_ == nullptr) + if (image1 == nullptr) { - image1_ = new UIImageView(); + 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 - + image1->SetPosition(126, 298); // widget's left position and top position + image1->Resize(100, 100); // widget's width and height + image1->SetViewId("image3"); // 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); - + const char *image1imagesPath = PNG_TRAING_WALKINGBIG_IMAGE; + image1->SetSrc(image1imagesPath); // Add to rootView - container_->Add(image1_); - image1_->SetVisible(true); + Add(image1); - // Add Label to App - if (label2_ == nullptr) + /* -------------------------------------------------------------------------- */ + // Add ImageView to App + if (image2 == nullptr) { - label2_ = new UILabel(); + image2 = new UIImageView(); } - 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); + image2->SetPosition(276, 148); // widget's left position and top position + image2->Resize(100, 100); // widget's width and height + image2->SetViewId("image2"); // Set style // 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); + const char *image2imagesPath = PNG_TRAING_RIDINGBIG_IMAGE; + image2->SetSrc(image2imagesPath); // Add to rootView - container_->Add(label2_); - label2_->SetVisible(true); + Add(image2); + /* -------------------------------------------------------------------------- */ // Add ImageView to App - if (image3_ == nullptr) + if (image3 == nullptr) { - image3_ = new UIImageView(); + 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 + image3->SetPosition(126, 148); // widget's left position and top position + image3->Resize(100, 100); // widget's width and height + image3->SetViewId("image1"); // 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); + 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(image3); - // Add to rootView - container_->Add(label3_); - label3_->SetVisible(true); + return true; + } - // Add ImageView to App - if (image5_ == nullptr) + bool TraingView::InitView() + { + printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__); + if (!InitLable()) { - 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) + printf("InitLable error!\n"); + }; + if (!AddButton()) { - 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); + printf("AddButton error!\n"); + }; + if (!InitImage()) + { + printf("InitImage error!\n"); + }; + SetCoverable(true); + return true; } void TraingView::DeInit() { - if (label1_ != nullptr) - { - delete label1_; - label1_ = nullptr; - } - if (button3_ != nullptr) - { - delete button3_; - button3_ = nullptr; - } - if (button4_ != nullptr) + if (titleLabel != nullptr) { - delete button4_; - button4_ = nullptr; + delete titleLabel; + titleLabel = nullptr; } - if (button1_ != nullptr) + if (ButtonMore != nullptr) { - delete button1_; - button1_ = nullptr; + delete ButtonMore; + ButtonMore = nullptr; } - if (button2_ != nullptr) + if (Button1 != nullptr) { - delete button2_; - button2_ = nullptr; + delete Button1; + Button1 = nullptr; } - if (image1_ != nullptr) + if (Button3 != nullptr) { - delete image1_; - image1_ = nullptr; + delete Button3; + Button3 = nullptr; } - if (label2_ != nullptr) + if (Button2 != nullptr) { - delete label2_; - label2_ = nullptr; + delete Button2; + Button2 = nullptr; } - if (image3_ != nullptr) + if (image2 != nullptr) { - delete image3_; - image3_ = nullptr; + delete image2; + image2 = nullptr; } - if (label3_ != nullptr) + if (image1 != nullptr) { - delete label3_; - label3_ = nullptr; + delete image1; + image1 = nullptr; } - if (image5_ != nullptr) + if (image3 != nullptr) { - delete image5_; - image5_ = nullptr; - } - if (label4_ != nullptr) - { - delete label4_; - label4_ = nullptr; - } - if (container_ != nullptr) - { - container_->RemoveAll(); - delete container_; - container_ = nullptr; + delete image3; + image3 = nullptr; } } - - UIView *TraingView::GetView() + void TraingView::PreLoad(void) { - 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) + printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__); + if (InitView()) { - return; + viewiInitStatus = true; } - 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() + void TraingView::UnLoad(void) { - View::OnStop(); - RootView::GetInstance()->RemoveAll(); - return; } }