From: Caisking <3449750381@qq.com> Date: Fri, 1 Dec 2023 10:11:06 +0000 (+0800) Subject: 增加更多训练列表;增加资源文件 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=267f51ce37231a899140b9d96d344cf22b16f4d4;p=mirrors%2FFD230.git 增加更多训练列表;增加资源文件 --- diff --git a/Resource/res/Training/Ball.bin b/Resource/res/Training/Ball.bin new file mode 100644 index 000000000..df0db80db Binary files /dev/null and b/Resource/res/Training/Ball.bin differ diff --git a/Resource/res/Training/Dance.bin b/Resource/res/Training/Dance.bin new file mode 100644 index 000000000..c892b1233 Binary files /dev/null and b/Resource/res/Training/Dance.bin differ diff --git a/Resource/res/Training/Fitness.bin b/Resource/res/Training/Fitness.bin new file mode 100644 index 000000000..30bda6a30 Binary files /dev/null and b/Resource/res/Training/Fitness.bin differ diff --git a/Resource/res/Training/Ice.bin b/Resource/res/Training/Ice.bin new file mode 100644 index 000000000..993e7a65a Binary files /dev/null and b/Resource/res/Training/Ice.bin differ diff --git a/Resource/res/Training/Limit.bin b/Resource/res/Training/Limit.bin new file mode 100644 index 000000000..068f4fd5c Binary files /dev/null and b/Resource/res/Training/Limit.bin differ diff --git a/Resource/res/Training/Other.bin b/Resource/res/Training/Other.bin new file mode 100644 index 000000000..8248dd3fa Binary files /dev/null and b/Resource/res/Training/Other.bin differ diff --git a/Resource/res/Training/Rest.bin b/Resource/res/Training/Rest.bin new file mode 100644 index 000000000..2adb5b080 Binary files /dev/null and b/Resource/res/Training/Rest.bin differ diff --git a/Resource/res/Training/Swimming.bin b/Resource/res/Training/Swimming.bin new file mode 100644 index 000000000..b0dcf9c43 Binary files /dev/null and b/Resource/res/Training/Swimming.bin differ diff --git a/Resource/res/Training/icon.bin b/Resource/res/Training/icon.bin new file mode 100644 index 000000000..1a68bf4f1 Binary files /dev/null and b/Resource/res/Training/icon.bin differ diff --git a/code/sdk/application/wearable/nativeapp/CMakeLists.txt b/code/sdk/application/wearable/nativeapp/CMakeLists.txt index 0a6f6e6e7..0b2844f86 100644 --- a/code/sdk/application/wearable/nativeapp/CMakeLists.txt +++ b/code/sdk/application/wearable/nativeapp/CMakeLists.txt @@ -244,6 +244,8 @@ set(SOURCES ${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/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 26c764a6c..fbf9faf57 100644 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h @@ -77,6 +77,7 @@ typedef enum : uint16_t VIEW_HEARTRATEREMIND, // 心率提醒 VIEW_TRAINING, // 训练 + VIEW_TRAININGMORE, //更多训练 VIEW_TRAINING_RECORD, // 训练记录 VIEW_BLOODPRESSURE, // 昨日睡眠时间 diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h index b1bc6a06b..3735e6bbf 100644 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h @@ -63,6 +63,7 @@ public: void InitPhoneCallupSlice(void); void InitPhoneRingSlice(void); void InitTraingSlice(void); + void InitTraingMoreSlice(void); void InitUIDisplayBrightnessSlice(void); void InitBlueToothSettingSlice(void); void InitBrightnessControlSlice(void); diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp index 4c6e8c8d5..854d18e2b 100644 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp @@ -103,6 +103,8 @@ #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" #include "displaybrightness/include/DisplayBrightnessPresenter.h" #include "displaybrightness/include/DisplayBrightnessView.h" #include "bluetoothofsetting/include/BlueToothOfSettingPresenter.h" @@ -220,6 +222,7 @@ static const AppViewMapper SLICE_MAPPER[] = { {VIEW_HEARTRATEREMIND, &NativeLauncher::InitHeartRemindSlice}, {VIEW_TRAINING, &NativeLauncher::InitTraingSlice}, //训练 + {VIEW_TRAININGMORE, &NativeLauncher::InitTraingMoreSlice}, //训练 {VIEW_DISPLAY_BRIGHTNESS,&NativeLauncher::InitUIDisplayBrightnessSlice}, //显示与亮度的实例化地址 {VIEW_CONNECT_BLUETOOTH,&NativeLauncher::InitBlueToothSettingSlice}, //蓝牙设置的实例化地址 @@ -783,7 +786,11 @@ void NativeLauncher::InitTraingSlice(void) SliceProxy *traingview = new AbilitySliceProxy; NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAINING, traingview); } - +void NativeLauncher::InitTraingMoreSlice(void) +{ + SliceProxy *traingmoreview = new AbilitySliceProxy; + NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAININGMORE, traingmoreview); +} //DisplayBrightness的实例化 void NativeLauncher::InitUIDisplayBrightnessSlice(void) diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingMorePresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingMorePresenter.h new file mode 100644 index 000000000..8685e839e --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingMorePresenter.h @@ -0,0 +1,33 @@ +#ifndef _TraingMore_PRESENTER_H +#define _TraingMore_PRESENTER_H + +#include "Presenter.h" +#include "TraingMoreView.h" + +namespace OHOS +{ + class TraingMoreView; + + class TraingMorePresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + TraingMorePresenter(); + virtual ~TraingMorePresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static TraingMorePresenter *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/TraingMoreView.h b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingMoreView.h new file mode 100644 index 000000000..5e17f88c2 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingMoreView.h @@ -0,0 +1,83 @@ +#ifndef _TraingMore_VIEW_H +#define _TraingMore_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 "components/ui_list.h" +#include "components/icon_adapter.h" +#include "wearable_log.h" +#include "ohos_types.h" +#include "components/ui_card_page.h" + +#include "TraingMorePresenter.h" +namespace OHOS +{ +#define BUTTON_FITNESS "button1" // 健身 +#define BUTTON_DANCE "button2" // 舞蹈 +#define BUTTON_REST "button3" // 休闲运动 +#define BUTTON_BALL "button4" // 球类 +#define BUTTON_SWIMMING "button5" // 水上运动 +#define BUTTON_ICE "button6" // 冰上运动 +#define BUTTON_LIMIT "button7" // 极限运动 +#define BUTTON_OTHER "button8" // 其他 + + class TraingMorePresenter; + class TraingMoreView : public View + { + + public: + TraingMoreView(); + virtual ~TraingMoreView(); + static TraingMoreView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void InitView(); + void DeInit(); + void InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize); + void InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId); + void InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath); + void InitList(); + void PreLoad(void); + + private: + UIView::OnDragListener *draglistener{nullptr}; + TraingMoreView(TraingMoreView &&) = delete; + TraingMoreView &operator=(TraingMoreView &&) = delete; + + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView1_ = nullptr; + UILabel *label1_ = nullptr; + UIImageView *image1_ = nullptr; + UIImageView *image2_ = nullptr; + UIImageView *image3_ = nullptr; + UIImageView *image4_ = nullptr; + UIImageView *image5_ = nullptr; + UIImageView *image6_ = nullptr; + UIImageView *image7_ = nullptr; + UIImageView *image8_ = nullptr; + UIButton *button1_ = nullptr; + UIButton *button2_ = nullptr; + UIButton *button3_ = nullptr; + UIButton *button4_ = nullptr; + UIButton *button5_ = nullptr; + UIButton *button6_ = nullptr; + UIButton *button7_ = nullptr; + UIButton *button8_ = nullptr; + UIList *list1_ = nullptr; + IconAdapter *list1adapter_ = nullptr; + List *list1data_ = nullptr; + bool viewiInitStatus{false}; + }; +} // namespace OHOS +#endif // TraingMore_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingMorePresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingMorePresenter.cpp new file mode 100644 index 000000000..c76fd4e05 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingMorePresenter.cpp @@ -0,0 +1,84 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include +#include +#include +#include "traing/include/TraingMorePresenter.h" +// #include "TraingMoreView.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static TraingMorePresenter *g_pTraingMorePresenter = nullptr; + + TraingMorePresenter::TraingMorePresenter() + { + + g_pTraingMorePresenter = this; + } + + TraingMorePresenter::~TraingMorePresenter() + { + + g_pTraingMorePresenter = nullptr; + } + + TraingMorePresenter *TraingMorePresenter::GetInstance() + { + + return g_pTraingMorePresenter; + } + + void TraingMorePresenter::OnStart() + { + + Presenter::OnStart(); + } + + void TraingMorePresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void TraingMorePresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void TraingMorePresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool TraingMorePresenter::OnDrag(UIView &view, const DragEvent &event) + { + + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_TRAINING); + } + UNUSED(view); + return true; + } + + bool TraingMorePresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), " ") == 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_TraingMoreREMIND); + } + return true; + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingMoreView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingMoreView.cpp new file mode 100644 index 000000000..3d43e72b9 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingMoreView.cpp @@ -0,0 +1,411 @@ + +#include "traing/include/TraingMoreView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +namespace OHOS +{ + // 定义全局变量 + char *imagePaths[] = {"/user/res/Training/Fitness.bin", + "/user/res/Training/Dance.bin", + "/user/res/Training/Rest.bin", + "/user/res/Training/Ball.bin", + "/user/res/Training/Swimming.bin", + "/user/res/Training/Ice.bin", + "/user/res/Training/Limit.bin", + "/user/res/Training/Other.bin"}; + + char *text[] = {"健身类", "舞蹈类", "休闲运动", "球类", "水上运动", "冰上运动", "极限运动", "其他"}; + const char *imagePath_iocn = "/user/res/Training/icon.bin"; + + static TraingMoreView *g_pTraingMoreView{nullptr}; + + TraingMoreView::TraingMoreView() + { + g_pTraingMoreView = this; + } + + TraingMoreView::~TraingMoreView() + { + DeInit(); + g_pTraingMoreView = nullptr; + } + + TraingMoreView *TraingMoreView::GetInstance() + { + + return g_pTraingMoreView; + } + /* + InitLabel:初始化标签 + @param label 标签指针 + @param left 标签左边位置 + @param top 标签顶部位置 + @param width 标签宽度 + @param height 标签高度 + @param viewId 标签的视图 ID + @param text 标签显示的文本 + @param fontName 字体名称 + @param fontSize 字体大小 + */ + void TraingMoreView::InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize) + { + // 检查标签指针是否为空 + if (label == nullptr) + { + label = new UILabel(); + } + // 设置标签的位置和大小 + label->SetPosition(left, top); + label->Resize(width, height); + // 设置标签的视图 ID + label->SetViewId(viewId); + // 设置标签的样式 + label->SetStyle(STYLE_TEXT_FONT, fontSize); + label->SetFont(fontName, fontSize); + // 设置标签的文本和其他属性 + label->SetText(text); + label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label->SetRollSpeed(0); + // 设置标签可见 + label->SetVisible(true); + } + /* + InitButton:初始化按钮 + @param button 按钮指针 + @param left 按钮左边位置 + @param top 按钮顶部位置 + @param width 按钮宽度 + @param height 按钮高度 + @param viewId 按钮的视图 ID + */ + void TraingMoreView::InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId) + { + // 设置按钮的背景颜色 + uint32_t backgroundColor = 0xff191919; // 默认背景颜色 + uint32_t pressedBackgroundColor = 0xff249115; // 按下时的背景颜色 + uint32_t pressedBorderColor = 0xff0b1928; // 按下时的边框颜色 + // 创建新按钮(如果当前按钮为空) + if (button == nullptr) + { + button = new UIButton(); + } + button->SetPosition(left, top); + button->Resize(width, height); + button->SetViewId(viewId); + button->SetStyle(STYLE_BACKGROUND_COLOR, backgroundColor); + button->SetStyleForState(STYLE_BACKGROUND_COLOR, pressedBackgroundColor, UIButton::PRESSED); + button->SetStyleForState(STYLE_BORDER_COLOR, pressedBorderColor, UIButton::PRESSED); + // 设置按钮的点击事件监听器为 TraingMorePresenter 的实例 + button->SetOnClickListener(static_cast(TraingMorePresenter::GetInstance())); + // 设置按钮可见 + button->SetVisible(true); + } + + /* + InitImageView:初始化图片 + @param imageView 图片指针 + @param left 图片左边位置 + @param top 图片顶部位置 + @param width 图片宽度 + @param height 图片高度 + @param viewId 图片的视图 ID + @param imagePath 图片路径 + */ + void TraingMoreView::InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath) + { + if (imageView == nullptr) + { + imageView = new UIImageView(); + } + imageView->SetPosition(left, top); + imageView->Resize(width, height); + imageView->SetViewId(viewId); + imageView->SetSrc(imagePath); + imageView->SetVisible(true); + } + + /* Traing:初始化list */ + void TraingMoreView::InitList() + { + // Add List to App + if (list1_ == nullptr) + { + list1_ = new UIList(); + } + list1_->SetPosition(35, 110); // widget's left position and top position + list1_->Resize(300, 1100); // widget's width and height + list1_->SetViewId("list1"); // Set style + list1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + list1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property + if (list1data_ == nullptr) + { + list1data_ = new List(); + } + + // 使用全局变量来初始化列表项 + for (int i = 0; i < 8; ++i) + { + IconItemNode *listData = new IconItemNode(); + listData->imagePath = imagePaths[i]; + listData->txt = text[i]; + list1data_->PushBack(listData); + } + + if (list1adapter_ == nullptr) + { + list1adapter_ = new IconAdapter(); + } + list1adapter_->SetItemSize(250, 120); + list1adapter_->SetImageSize(130, 120); + list1adapter_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + list1adapter_->SetData(list1data_); + list1_->SetAdapter(list1adapter_); + + // Add to scrollView1 + // scrollView1_->Add(list1_); + list1_->SetVisible(true); + } + /* InitView:初始化界面*/ + void TraingMoreView ::InitView() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + // Add ScrollView to App + if (scrollView1_ == nullptr) + { + scrollView1_ = new UIScrollView(); + } + scrollView1_->SetPosition(0, 0); // widget's left position and top position + scrollView1_->Resize(466, 466); // widget's width and height + scrollView1_->SetViewId("scrollView1"); // Set style + scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + // Add to rootView + container_->Add(scrollView1_); + scrollView1_->SetVisible(true); + + // 初始化Lable + InitLabel(label1_, 203, 52, 200, 60, "label1", "训练", DEFAULT_VECTOR_FONT_FILENAME, 30); + scrollView1_->Add(label1_); + // 初始化Button + InitButton(button1_, 43, 120, 380, 100, BUTTON_FITNESS); + InitButton(button2_, 43, 240, 380, 100, BUTTON_DANCE); + InitButton(button1_, 43, 120, 380, 100, BUTTON_FITNESS); + InitButton(button2_, 43, 240, 380, 100, BUTTON_DANCE); + InitButton(button3_, 43, 360, 380, 100, BUTTON_REST); + InitButton(button4_, 43, 480, 380, 100, BUTTON_BALL); + InitButton(button5_, 43, 600, 380, 100, BUTTON_SWIMMING); + InitButton(button6_, 43, 720, 380, 100, BUTTON_ICE); + InitButton(button7_, 43, 840, 380, 100, BUTTON_LIMIT); + InitButton(button8_, 43, 960, 380, 100, BUTTON_OTHER); + scrollView1_->Add(button1_); + scrollView1_->Add(button2_); + scrollView1_->Add(button3_); + scrollView1_->Add(button4_); + scrollView1_->Add(button5_); + scrollView1_->Add(button6_); + scrollView1_->Add(button7_); + scrollView1_->Add(button8_); + // 初始化image + InitImageView(image1_, 360, 160, 100, 100, "image1", imagePath_iocn); + InitImageView(image2_, 360, 280, 100, 100, "image2", imagePath_iocn); + InitImageView(image3_, 360, 400, 100, 100, "image3", imagePath_iocn); + InitImageView(image4_, 360, 520, 100, 100, "image4", imagePath_iocn); + InitImageView(image5_, 360, 640, 100, 100, "image5", imagePath_iocn); + InitImageView(image6_, 360, 760, 100, 100, "image6", imagePath_iocn); + InitImageView(image7_, 360, 880, 100, 100, "image7", imagePath_iocn); + InitImageView(image8_, 360, 1000, 100, 100, "image8", imagePath_iocn); + scrollView1_->Add(image1_); + scrollView1_->Add(image2_); + scrollView1_->Add(image3_); + scrollView1_->Add(image4_); + scrollView1_->Add(image5_); + scrollView1_->Add(image6_); + scrollView1_->Add(image7_); + scrollView1_->Add(image8_); + // 初始化list + InitList(); + scrollView1_->Add(list1_); + } + /* DeInit:删除组件*/ + void TraingMoreView::DeInit() + { + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (button1_ != nullptr) + { + delete button1_; + button1_ = nullptr; + } + if (button8_ != nullptr) + { + delete button8_; + button8_ = nullptr; + } + if (button7_ != nullptr) + { + delete button7_; + button7_ = nullptr; + } + if (button6_ != nullptr) + { + delete button6_; + button6_ = nullptr; + } + if (button5_ != nullptr) + { + delete button5_; + button5_ = nullptr; + } + if (button4_ != nullptr) + { + delete button4_; + button4_ = nullptr; + } + if (button3_ != nullptr) + { + delete button3_; + button3_ = nullptr; + } + if (button2_ != nullptr) + { + delete button2_; + button2_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + if (image2_ != nullptr) + { + delete image2_; + image2_ = nullptr; + } + if (image3_ != nullptr) + { + delete image3_; + image3_ = nullptr; + } + if (image4_ != nullptr) + { + delete image4_; + image4_ = nullptr; + } + if (image5_ != nullptr) + { + delete image5_; + image5_ = nullptr; + } + if (image6_ != nullptr) + { + delete image6_; + image6_ = nullptr; + } + if (image7_ != nullptr) + { + delete image7_; + image7_ = nullptr; + } + if (image8_ != nullptr) + { + delete image8_; + image8_ = nullptr; + } + if (list1_ != nullptr) + { + delete list1_; + list1_ = nullptr; + } + if (list1adapter_ != nullptr) + { + delete list1adapter_; + list1adapter_ = nullptr; + } + if (list1data_ != nullptr) + { + list1data_->Clear(); + delete list1data_; + list1data_ = nullptr; + } + if (scrollView1_ != nullptr) + { + delete scrollView1_; + scrollView1_ = nullptr; + } + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + } + + void TraingMoreView::PreLoad(void) + { + if (!viewiInitStatus) + { + InitView(); + viewiInitStatus = true; + } + } + void TraingMoreView::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(TraingMorePresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + PreLoad(); + RootView::GetInstance()->Add(container_); + } + + void TraingMoreView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void TraingMoreView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void TraingMoreView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingPresenter.cpp index 7a4bbc234..27334e7b1 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingPresenter.cpp @@ -69,9 +69,9 @@ namespace OHOS bool TraingPresenter::OnClick(UIView &view, const ClickEvent &event) { // 根据控件id查找是哪个控件触发了点击回调 - if (strcmp(view.GetViewId(), BUTTON1) == 0) + if (strcmp(view.GetViewId(), BUTTONMORE) == 0) { - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGMORE); } if (strcmp(view.GetViewId(), "Remind") == 0) {