From: Caisking <3449750381@qq.com> Date: Mon, 4 Dec 2023 01:57:01 +0000 (+0800) Subject: 增加极限运动列表 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=5b8c67f6cc534b600cf682bd5e600982221f1c57;p=mirrors%2FFD230.git 增加极限运动列表 --- diff --git a/code/sdk/application/wearable/nativeapp/CMakeLists.txt b/code/sdk/application/wearable/nativeapp/CMakeLists.txt index 59217db87..bc57c5e38 100644 --- a/code/sdk/application/wearable/nativeapp/CMakeLists.txt +++ b/code/sdk/application/wearable/nativeapp/CMakeLists.txt @@ -246,6 +246,8 @@ set(SOURCES ${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 + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingLimitPresenter.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 fbf9faf57..03e94fd53 100644 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h @@ -77,7 +77,8 @@ typedef enum : uint16_t VIEW_HEARTRATEREMIND, // 心率提醒 VIEW_TRAINING, // 训练 - VIEW_TRAININGMORE, //更多训练 + VIEW_TRAININGMORE, // 更多训练 + VIEW_TRAININGLIMIT, // 极限运动子列表 VIEW_TRAINING_RECORD, // 训练记录 VIEW_BLOODPRESSURE, // 昨日睡眠时间 @@ -106,6 +107,8 @@ typedef enum : uint16_t VIEW_CONNECT_BLUETOOTH, // 蓝牙 VIEW_SOUND_VIBRATION, // 声音与震动 VIEW_SYSTEM_VOLUME, // 系统音量 + VIEW_CALL_VOLUME,        // 通话音量 + VIEW_MEDIA_VOLUME,       // 媒体音量 VIEW_QUICK_ACCESS, // 快速访问 VIEW_SYSTEM, // 系统 // 系统 diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h index 3735e6bbf..0fa24ef10 100644 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h @@ -64,6 +64,7 @@ public: void InitPhoneRingSlice(void); void InitTraingSlice(void); void InitTraingMoreSlice(void); + void InitTraingLimitSlice(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 854d18e2b..cd64657bf 100644 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp @@ -105,6 +105,8 @@ #include "traing/include/TraingView.h" #include "traing/include/TraingMorePresenter.h" #include "traing/include/TraingMoreView.h" +#include "traing/include/TraingLimitPresenter.h" +#include "traing/include/TraingLimitView.h" #include "displaybrightness/include/DisplayBrightnessPresenter.h" #include "displaybrightness/include/DisplayBrightnessView.h" #include "bluetoothofsetting/include/BlueToothOfSettingPresenter.h" @@ -117,8 +119,8 @@ #include "soundandvibration/include/SoundAndVibrationView.h" #include "soundandvibration/include/SystemVolumePresenter.h" #include "soundandvibration/include/SystemVolumeView.h" -#include "quickaccess/include/QuickAccessPresenter.h" -#include "quickaccess/include/QuickAccessView.h" +#include "secondaryfunction/include/QuickAccessPresenter.h" +#include "secondaryfunction/include/QuickAccessView.h" #include "system/include/SystemPresenter.h" #include "system/include/SystemView.h" #include "system/include/SystemAboutPresenter.h" @@ -221,8 +223,9 @@ static const AppViewMapper SLICE_MAPPER[] = { {VIEW_DIAL, &NativeLauncher::InitDialSlice}, //表盘 {VIEW_HEARTRATEREMIND, &NativeLauncher::InitHeartRemindSlice}, - {VIEW_TRAINING, &NativeLauncher::InitTraingSlice}, //训练 - {VIEW_TRAININGMORE, &NativeLauncher::InitTraingMoreSlice}, //训练 + {VIEW_TRAINING, &NativeLauncher::InitTraingSlice}, //训练 + {VIEW_TRAININGMORE, &NativeLauncher::InitTraingMoreSlice}, //更多训练 + {VIEW_TRAININGLIMIT, &NativeLauncher::InitTraingLimitSlice}, //极限训练 {VIEW_DISPLAY_BRIGHTNESS,&NativeLauncher::InitUIDisplayBrightnessSlice}, //显示与亮度的实例化地址 {VIEW_CONNECT_BLUETOOTH,&NativeLauncher::InitBlueToothSettingSlice}, //蓝牙设置的实例化地址 @@ -791,7 +794,11 @@ void NativeLauncher::InitTraingMoreSlice(void) SliceProxy *traingmoreview = new AbilitySliceProxy; NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAININGMORE, traingmoreview); } - +void NativeLauncher::InitTraingLimitSlice(void) +{ + SliceProxy *trainglimitview = new AbilitySliceProxy; + NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAININGLIMIT, trainglimitview); +} //DisplayBrightness的实例化 void NativeLauncher::InitUIDisplayBrightnessSlice(void) { diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingLimitPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingLimitPresenter.h new file mode 100644 index 000000000..6a2099113 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingLimitPresenter.h @@ -0,0 +1,33 @@ +#ifndef _TraingLimit_PRESENTER_H +#define _TraingLimit_PRESENTER_H + +#include "Presenter.h" +#include "TraingLimitView.h" + +namespace OHOS +{ + class TraingLimitView; + + class TraingLimitPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + TraingLimitPresenter(); + virtual ~TraingLimitPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static TraingLimitPresenter *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/TraingLimitView.h b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingLimitView.h new file mode 100644 index 000000000..26ffab6d4 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingLimitView.h @@ -0,0 +1,83 @@ +#ifndef _TraingLimit_VIEW_H +#define _TraingLimit_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 "TraingLimitPresenter.h" +namespace OHOS +{ +#define BUTTON1 "button1" // 健身 +#define BUTTON2 "button2" // 舞蹈 +#define BUTTON3 "button3" // 休闲运动 +#define BUTTON4 "button4" // 球类 +#define BUTTON5 "button5" // 水上运动 +#define BUTTON6 "button6" // 冰上运动 +#define BUTTON7 "button7" // 极限运动 +#define BUTTON8 "button8" // 其他 + + class TraingLimitPresenter; + class TraingLimitView : public View + { + + public: + TraingLimitView(); + virtual ~TraingLimitView(); + static TraingLimitView *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}; + TraingLimitView(TraingLimitView &&) = delete; + TraingLimitView &operator=(TraingLimitView &&) = 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 // TraingLimit_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingLimitPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingLimitPresenter.cpp new file mode 100644 index 000000000..0c5da9f3b --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingLimitPresenter.cpp @@ -0,0 +1,84 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include +#include +#include +#include "traing/include/TraingLimitPresenter.h" +// #include "TraingLimitView.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static TraingLimitPresenter *g_pTraingLimitPresenter = nullptr; + + TraingLimitPresenter::TraingLimitPresenter() + { + + g_pTraingLimitPresenter = this; + } + + TraingLimitPresenter::~TraingLimitPresenter() + { + + g_pTraingLimitPresenter = nullptr; + } + + TraingLimitPresenter *TraingLimitPresenter::GetInstance() + { + + return g_pTraingLimitPresenter; + } + + void TraingLimitPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void TraingLimitPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void TraingLimitPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void TraingLimitPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool TraingLimitPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGMORE); + } + UNUSED(view); + return true; + } + + bool TraingLimitPresenter::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_TraingLimitREMIND); + } + return true; + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingLimitView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingLimitView.cpp new file mode 100644 index 000000000..6d5bbda37 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingLimitView.cpp @@ -0,0 +1,402 @@ + +#include "traing/include/TraingLimitView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +namespace OHOS +{ + + static char *text[] = {"一般极限运动", "滑板", "高空弹跳/蹦极", "跑酷", "BMX", "定向越野", "跳伞", "铁人三项运动"}; + static const char *imagePath_iocn = "/user/res/Training/icon.bin"; + + static TraingLimitView *g_pTraingLimitView{nullptr}; + + TraingLimitView::TraingLimitView() + { + g_pTraingLimitView = this; + } + + TraingLimitView::~TraingLimitView() + { + DeInit(); + g_pTraingLimitView = nullptr; + } + + TraingLimitView *TraingLimitView::GetInstance() + { + + return g_pTraingLimitView; + } + /* + InitLabel:初始化标签 + @param label 标签指针 + @param left 标签左边位置 + @param top 标签顶部位置 + @param width 标签宽度 + @param height 标签高度 + @param viewId 标签的视图 ID + @param text 标签显示的文本 + @param fontName 字体名称 + @param fontSize 字体大小 + */ + void TraingLimitView::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 TraingLimitView::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); + // 设置按钮的点击事件监听器为 TraingLimitPresenter 的实例 + button->SetOnClickListener(static_cast(TraingLimitPresenter::GetInstance())); + // 设置按钮可见 + button->SetVisible(true); + } + + /* + InitImageView:初始化图片 + @param imageView 图片指针 + @param left 图片左边位置 + @param top 图片顶部位置 + @param width 图片宽度 + @param height 图片高度 + @param viewId 图片的视图 ID + @param imagePath 图片路径 + */ + void TraingLimitView::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 TraingLimitView::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 TraingLimitView ::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, BUTTON1); + InitButton(button2_, 43, 240, 380, 100, BUTTON1); + InitButton(button1_, 43, 120, 380, 100, BUTTON1); + InitButton(button2_, 43, 240, 380, 100, BUTTON1); + InitButton(button3_, 43, 360, 380, 100, BUTTON1); + InitButton(button4_, 43, 480, 380, 100, BUTTON1); + InitButton(button5_, 43, 600, 380, 100, BUTTON1); + InitButton(button6_, 43, 720, 380, 100, BUTTON1); + InitButton(button7_, 43, 840, 380, 100, BUTTON1); + InitButton(button8_, 43, 960, 380, 100, BUTTON1); + 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 TraingLimitView::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 TraingLimitView::PreLoad(void) + { + if (!viewiInitStatus) + { + InitView(); + viewiInitStatus = true; + } + } + void TraingLimitView::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(TraingLimitPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + PreLoad(); + RootView::GetInstance()->Add(container_); + } + + void TraingLimitView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void TraingLimitView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void TraingLimitView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} 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 c76fd4e05..80b3af686 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingMorePresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingMorePresenter.cpp @@ -69,9 +69,9 @@ namespace OHOS bool TraingMorePresenter::OnClick(UIView &view, const ClickEvent &event) { // 根据控件id查找是哪个控件触发了点击回调 - if (strcmp(view.GetViewId(), " ") == 0) + if (strcmp(view.GetViewId(), BUTTON_LIMIT) == 0) { - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGLIMIT); } if (strcmp(view.GetViewId(), "Remind") == 0) { diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingMoreView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingMoreView.cpp index 3d43e72b9..77a821f0f 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingMoreView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingMoreView.cpp @@ -9,7 +9,7 @@ namespace OHOS { // 定义全局变量 - char *imagePaths[] = {"/user/res/Training/Fitness.bin", + static char *imagePaths[] = {"/user/res/Training/Fitness.bin", "/user/res/Training/Dance.bin", "/user/res/Training/Rest.bin", "/user/res/Training/Ball.bin", @@ -18,8 +18,8 @@ namespace OHOS "/user/res/Training/Limit.bin", "/user/res/Training/Other.bin"}; - char *text[] = {"健身类", "舞蹈类", "休闲运动", "球类", "水上运动", "冰上运动", "极限运动", "其他"}; - const char *imagePath_iocn = "/user/res/Training/icon.bin"; + static char *text[] = {"健身类", "舞蹈类", "休闲运动", "球类", "水上运动", "冰上运动", "极限运动", "其他"}; + static const char *imagePath_iocn = "/user/res/Training/icon.bin"; static TraingMoreView *g_pTraingMoreView{nullptr};