From: Caisking <3449750381@qq.com> Date: Fri, 19 Apr 2024 12:32:45 +0000 (+0800) Subject: 删除原训练达到目标弹窗Slice;修复bug X-Git-Tag: release_V1.2.70_20241020_135402~1167 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=0ffe471e2bf605d851e2e594a0cab32dee8122e7;p=mirrors%2FFD230.git 删除原训练达到目标弹窗Slice;修复bug --- diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index 6f0b8cee4..2ced28595 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -476,8 +476,6 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingSetPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingEnddataView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingEnddataPresenter.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingWinView.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingWinPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TrainingSetCaluliView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TrainingSetTimeView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TrainingSetMileView.cpp diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h index dc4e127b9..e004d2b90 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h @@ -76,7 +76,6 @@ typedef enum : uint16_t VIEW_TRAININGSET, // 训练目标(时长,卡路里) VIEW_TRAININGCRAD, // 训练控制卡片 VIEW_TRAININGENDDATA, // 训练结束详细数据 - VIEW_TRAININGWIN, // 目标达成 VIEW_TRAINING_RECORD, // 训练记录 /* ---------------------------------- 训练列表 ---------------------------------- */ VIEW_TRAININGMORE, // 更多训练 diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h index 809a500a3..3ec99394b 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h @@ -66,10 +66,9 @@ namespace OHOS /* ----------------------------------- 训练 ----------------------------------- */ void InitTraingSlice(void); void InitTraingNomalSlice(void); - void InitTraingSetSlice(void); + void InitTraingSetSlice(void); void InitTraingCardSlice(void); void InitTraingEnddataSlice(void); - void InitTraingWinSlice(void); void InitTraingMoreSlice(void); // 更多训练 void InitTraingLimitSlice(void); // 极限训练 @@ -80,8 +79,7 @@ namespace OHOS void InitTraingBallSlice(void); // 球类训练 void InitTraingAquaticSlice(void); // 水上训练 void InitTraingOtherSlice(void); // 其他训练 - - void InitTraingRecordSlice(void); // 训练记录 + void InitTraingRecordSlice(void); // 训练记录 void InitSecondaryFunction(void); void InitFastTrainingSlice(void); diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp index 7115ef357..be66da1dc 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp @@ -165,8 +165,6 @@ #include "traing/include/TraingSetView.h" #include "traing/include/TraingEnddataPresenter.h" #include "traing/include/TraingEnddataView.h" -#include "traing/include/TraingWinPresenter.h" -#include "traing/include/TraingWinView.h" /* ---------------------------------- 训练记录 ---------------------------------- */ #include "traingrecord/include/TraingRecordView.h" #include "traingrecord/include/TraingRecordPresenter.h" @@ -279,8 +277,7 @@ namespace OHOS {VIEW_TRAININGSET, &NativeLauncher::InitTraingSetSlice}, // 训练目标设置界面 {VIEW_TRAININGCRAD, &NativeLauncher::InitTraingCardSlice}, // 训练卡片 {VIEW_TRAININGENDDATA, &NativeLauncher::InitTraingEnddataSlice}, // 训练结束详细数据 - {VIEW_TRAININGWIN, &NativeLauncher::InitTraingWinSlice}, // 训练目标达成 - {VIEW_TRAINING_RECORD, &NativeLauncher::InitTraingRecordSlice}, // 训练目标达成 + {VIEW_TRAINING_RECORD, &NativeLauncher::InitTraingRecordSlice}, // 训练记录 {VIEW_TRAININGMORE, &NativeLauncher::InitTraingMoreSlice}, // 更多训练 {VIEW_TRAININGLIMIT, &NativeLauncher::InitTraingLimitSlice}, // 极限训练 @@ -867,11 +864,6 @@ namespace OHOS SliceProxy *traingenddataview = new AbilitySliceProxy; NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAININGENDDATA, traingenddataview); } - void NativeLauncher::InitTraingWinSlice(void) - { - SliceProxy *traingwinview = new AbilitySliceProxy; - NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAININGWIN, traingwinview); - } void NativeLauncher::InitTraingRecordSlice(void) { SliceProxy *traingrecordview = new AbilitySliceProxy; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h index b9d7890a2..ba321b740 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h @@ -108,6 +108,11 @@ extern "C" namespace OHOS { +#define TIME_INTERVAL 10; +#define CALORIES_INTERVAL 100; +#define DISTANCE_INTERVAL 1; +#define STEPS_INTERVAL 500; + // 运动状态 enum class ExerciseState { diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingWinPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingWinPresenter.h deleted file mode 100644 index ed8b1e19a..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingWinPresenter.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef _TraingWin_PRESENTER_H -#define _TraingWin_PRESENTER_H - -#include "Presenter.h" -#include "TraingWinView.h" - -namespace OHOS -{ - class TraingWinView; - - class TraingWinPresenter : public Presenter, - public UIView::OnClickListener, - public UIView::OnDragListener - { - public: - TraingWinPresenter(); - virtual ~TraingWinPresenter(); - - void OnStart() override; - void OnPause() override; - void OnResume() override; - void OnStop() override; - - static TraingWinPresenter *GetInstance(); - - private: - // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; - bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView &view, const DragEvent &event) override; - //bool OnDragEnd(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/fd230app/nativeui/traing/include/TraingWinView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingWinView.h deleted file mode 100644 index d64a20aec..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingWinView.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef _TraingWin_VIEW_H -#define _TraingWin_VIEW_H - -#include "BaseView.h" -#include "View.h" -#include -#include "components/ui_view_group.h" -#include "components/ui_label.h" -#include "components/ui_label_ext.h" -#include "components/ui_image_view.h" -#include "components/ui_button.h" -#include "components/ui_image_animator.h" -#include "components/ui_label_button_ext.h" -#include "components/ui_chart.h" -#include "components/ui_list.h" -#include "components/icon_adapter.h" -#include "wearable_log.h" -#include "ohos_types.h" -#include "components/ui_card_page.h" -#include "traing/include/TraingModel.h" -#include "traing/Training_UiConfig.h" - -#include "TraingWinPresenter.h" -namespace OHOS -{ -#define BUTTONOK "button1" - - class TraingWinPresenter; - class TraingWinView : public View - { - - public: - TraingWinView(); - virtual ~TraingWinView(); - static TraingWinView *GetInstance(void); - - void OnStart() override; - void OnSetUpView() override; - void OnTearDownView() override; - void OnStop() override; - void InitView(); - void DeInit(); - - void InitImageAnimatorSource(UIImageAnimatorView *&imageAnimator, const char **imagePaths, int numFrames, int left, int top, int width, int height, const char *viewId,int time); - - void InitList(); - void PreLoad(void); - - private: - UIView::OnDragListener *draglistener{nullptr}; - TraingWinView(TraingWinView &&) = delete; - TraingWinView &operator=(TraingWinView &&) = delete; - UIViewGroup *container_ = nullptr; - UILabelExt *label1_ = nullptr; - UILabelExt *label2_ = nullptr; - UILabelExt *label3_ = nullptr; - UILabelExt *label4_ = nullptr; - UIButton *button1_ = nullptr; - UIImageView *image1_ = nullptr; - UIImageAnimatorView *imageAnimator; - bool viewiInitStatus{false}; - }; - -} // namespace OHOS -#endif // TraingWin_PRESENTER_H diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataPresenter.cpp index a247865bb..5e076de54 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataPresenter.cpp @@ -1,4 +1,4 @@ -/*** +/*** * @Date: 2024-04-15 14:19:47 * @LastEditors: Caisking 3449750381@qq.com * @LastEditTime: 2024-04-17 14:59:43 @@ -78,7 +78,7 @@ namespace OHOS // 根据控件id查找是哪个控件触发了点击回调 if (strcmp(view.GetViewId(), BUTTONBACK) == 0) { - NativeAbility::GetInstance().Back(); + NativeAbility::GetInstance().EnterSlice(VIEW_APPLIST); } return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalPresenter.cpp index 03d6073b2..537782d46 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalPresenter.cpp @@ -79,7 +79,7 @@ namespace OHOS } if (strcmp(view.GetViewId(), BUTTONGO) == 0) { - NativeAbility::GetInstance().EnterSlice(VIEW_TRAININGCRAD); + NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCRAD); // 获取运动类型 ExerciseClass type = TraingModel::GetInstance()->GetSportType(); // 开启对应的运动 diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingSetPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingSetPresenter.cpp index b34a2b760..13f7d8cfe 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingSetPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingSetPresenter.cpp @@ -14,6 +14,7 @@ #include #include "traing/include/TraingSetPresenter.h" #include "traing/training_card/include/TraingCardPresenter.h" +#include "traing/include/TraingModel.h" // #include "TraingSetView.h" namespace OHOS @@ -121,7 +122,7 @@ namespace OHOS TraingModel::GetInstance()->SetSportTag(GetExerciseTagFromCard(CardID), tag); // TraingModel::GetInstance()->SetSportTag(ExerciseTag::STEP, 10); // 测试 PRINT("GetButtonIdFromCard:%d tag:%d \r\n", CardID, tag); - NativeAbility::GetInstance().EnterSlice(VIEW_TRAININGCRAD); + NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCRAD); ExerciseClass type = TraingModel::GetInstance()->GetSportType(); TraingCardPresenter::GetInstance()->OpenSensor(type); } @@ -178,16 +179,26 @@ namespace OHOS */ int TraingSetPresenter::GetTagFromCard(int cardID) { + int selectedValue = 0; + switch (cardID) { case SET_DURATION: - return TrainingSetTimeView::GetInstance()->GetTimePicker()->GetSelected(); + // 获取时间选择器中选定的时间值,并加1后乘以区间值 + selectedValue = TrainingSetTimeView::GetInstance()->GetTimePicker()->GetSelected(); + return (selectedValue + 1) * TIME_INTERVAL; case SET_CALORIES: - return TrainingSetCaluliView::GetInstance()->GetCaluliPicker()->GetSelected(); + // 获取卡路里选择器中选定的卡路里值,并加1后乘以区间值 + selectedValue = TrainingSetCaluliView::GetInstance()->GetCaluliPicker()->GetSelected(); + return (selectedValue + 1) * CALORIES_INTERVAL; case SET_DISTANCE: - return TrainingSetMileView::GetInstance()->GetMilePicker()->GetSelected(); + // 获取距离选择器中选定的距离值,并加1后乘以区间值 + selectedValue = TrainingSetMileView::GetInstance()->GetMilePicker()->GetSelected(); + return (selectedValue + 1) * DISTANCE_INTERVAL; case SET_STEPS: - return TrainingSetStepView::GetInstance()->GetSetpPicker()->GetSelected(); + // 获取步数选择器中选定的步数值,并加1后乘以区间值 + selectedValue = TrainingSetStepView::GetInstance()->GetSetpPicker()->GetSelected(); + return (selectedValue + 1) * STEPS_INTERVAL; default: return 0; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingWinPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingWinPresenter.cpp deleted file mode 100644 index 4bf9d63bb..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingWinPresenter.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/*** - * @Date: 2024-04-15 10:55:58 - * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-04-17 14:22:58 - * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingWinPresenter.cpp - */ - -#include "AppViewIDs.h" -#include "components/ui_label_ext.h" -#include"language/font/ui_resource_string.h" -#include "NativeAbility.h" - -#include -#include -#include -#include "traing/include/TraingWinPresenter.h" -// #include "TraingWinView.h" - -namespace OHOS -{ - - // 当前Presenter属性实例化的内存指针 - static TraingWinPresenter *g_pTraingWinPresenter = nullptr; - - TraingWinPresenter::TraingWinPresenter() - { - - g_pTraingWinPresenter = this; - } - - TraingWinPresenter::~TraingWinPresenter() - { - g_pTraingWinPresenter = nullptr; - } - - TraingWinPresenter *TraingWinPresenter::GetInstance() - { - - return g_pTraingWinPresenter; - } - - void TraingWinPresenter::OnStart() - { - - Presenter::OnStart(); - } - - void TraingWinPresenter::OnPause(void) - { - - Presenter::OnPause(); - } - - void TraingWinPresenter::OnResume(void) - { - - Presenter::OnResume(); - } - - void TraingWinPresenter::OnStop(void) - { - - Presenter::OnStop(); - } - - bool TraingWinPresenter::OnDrag(UIView &view, const DragEvent &event) - { - - // if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && - // (event.GetDeltaX() > 40) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) - // { - // uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - // NativeAbility::GetInstance().ChangeSlice(preSlice); - // } - UNUSED(view); - return true; - } - - bool TraingWinPresenter::OnClick(UIView &view, const ClickEvent &event) - { - // 根据控件id查找是哪个控件触发了点击回调 - if (strcmp(view.GetViewId(), BUTTONOK) == 0) - { - NativeAbility::GetInstance().EnterSlice(VIEW_TRAININGENDDATA); - } - return true; - } -} diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingWinView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingWinView.cpp deleted file mode 100644 index 854ec1d8e..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingWinView.cpp +++ /dev/null @@ -1,226 +0,0 @@ - -#include "traing/include/TraingWinView.h" - -#include "common/image_cache_manager.h" -#include "components/ui_label_ext.h" -#include "language/font/ui_resource_string.h" -#include "UiConfig.h" -#include "ui_resource_image.h" -#include -#include "components/ui_button.h" -#include "traing/include/TraingModel.h" -#include "traing/Training_UiConfig.h" - -namespace OHOS -{ - - static TraingWinView *g_pTraingWinView{nullptr}; - TraingWinView::TraingWinView() - { - g_pTraingWinView = this; - } - - TraingWinView::~TraingWinView() - { - DeInit(); - g_pTraingWinView = nullptr; - } - TraingWinView *TraingWinView::GetInstance() - { - - return g_pTraingWinView; - } - - /** - * 创建包含图片文件路径的数组 - * @param basePath 包含图片文件的基本路径 - * @param fileExtension 图片文件的扩展名 - * @param numImages 图片文件的数量 - * @return 返回包含图片文件路径的数组 - */ - const char **CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages) - { - const char **imagePaths = new const char *[numImages]; - char buffer[256]; - for (int i = 0; i < numImages; i++) - { - snprintf(buffer, sizeof(buffer), "%s/%d.%s", basePath, i + 1, fileExtension); - imagePaths[i] = strdup(buffer); - } - return imagePaths; - } - - /** - * 释放图片文件路径数组占用的内存 - * @param imagePaths 图片文件路径数组 - * @param numImages 图片文件的数量 - */ - void FreeImagePathsArray(const char **imagePaths, int numImages) - { - for (int i = 0; i < numImages; i++) - { - free((void *)imagePaths[i]); - } - delete[] imagePaths; - } - /** - * @brief 初始化UIImageAnimatorView,并设置为GIF动画。 - * - * 该函数用于使用提供的GIF图像和属性初始化UIImageAnimatorView。 - * - * @param imageAnimator 要初始化的UIImageAnimatorView对象的引用。 - * @param paths GIF图像文件路径的数组。 - * @param numFrames GIF中的帧数。 - * @param left 视图的左侧位置。 - * @param top 视图的顶部位置。 - * @param width 视图的宽度。 - * @param height 视图的高度。 - * @param viewId 视图的ID。 - * @param time 视图的帧速 - * @return 如果初始化成功则返回true,否则返回false。 - */ - void TraingWinView::InitImageAnimatorSource(UIImageAnimatorView *&imageAnimator, const char **imagePaths, int numFrames, int left, int top, int width, int height, const char *viewId, int time) - { - if (imageAnimator == nullptr) - { - imageAnimator = new UIImageAnimatorView(); - } - imageAnimator->SetPosition(left, top); - imageAnimator->Resize(width, height); - imageAnimator->SetViewId(viewId); - imageAnimator->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); - imageAnimator->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - - ImageAnimatorInfo *imageAnimatorInfo = new ImageAnimatorInfo[numFrames]; - for (int i = 0; i < numFrames; i++) - { - imageAnimatorInfo[i].imagePath = imagePaths[i]; - imageAnimatorInfo[i].pos.x = left; - imageAnimatorInfo[i].pos.y = top; - imageAnimatorInfo[i].width = width; - imageAnimatorInfo[i].height = height; - imageAnimatorInfo[i].imageType = IMG_SRC_FILE_PATH; - } - - imageAnimator->SetImageAnimatorSrc(imageAnimatorInfo, numFrames, time); // 200 is the default delay time - imageAnimator->SetTimeOfPause(time); - imageAnimator->SetRepeatTimes(1); - imageAnimator->SetReverse(true); - imageAnimator->SetVisible(true); - } - /* InitView:初始化界面*/ - void TraingWinView ::InitView() - { - if (container_ == nullptr) - { - container_ = new UIViewGroup(); - container_->SetPosition(0, 0, 466, 466); - container_->SetStyle(STYLE_BACKGROUND_OPA, 0); - } - - // 初始化Lable - TraingModel::GetInstance()->InitLabel(label1_, 83, 50, 300, 35, "label1", "目标已达成", DEFAULT_VECTOR_FONT_FILENAME, 35); - container_->Add(label1_); - TraingModel::GetInstance()->InitLabel(label2_, 70, 215, 326, 97, "label2", "10,000", DEFAULT_VECTOR_FONT_FILENAME, 80); - label2_->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff)); - container_->Add(label2_); - TraingModel::GetInstance()->InitLabel(label3_, 103, 307, 200, 35, "label3", "完成目标", DEFAULT_VECTOR_FONT_FILENAME, 30); - container_->Add(label3_); - TraingModel::GetInstance()->InitLabel(label4_, 233, 307, 160, 35, "label3", "100%", DEFAULT_VECTOR_FONT_FILENAME, 30); - // label4_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f)); - container_->Add(label4_); - - - // 初始化图片数组 - const char *basePath = "/user/res/Training/training_GIF/win/"; - const char *fileExtension = "bin"; - const char **imagePaths = CreateImagePathsArray(basePath, fileExtension, 94); - InitImageAnimatorSource(imageAnimator, imagePaths, 94, 173, 100, 120, 120, "imageAnimator1", 10); - container_->Add(imageAnimator); - // FreeImagePathsArray(imagePaths, 94); //删除数组,释放内存 - - // 初始化Button - TraingModel::GetInstance()->InitButton(button1_, 0, 366, 466, 100, BUTTONOK); - // Set additional property - - button1_->SetImageSrc(BUTTONOK_IMAGE, BUTTONOK_IMAGE); - button1_->SetOnClickListener(static_cast(TraingWinPresenter::GetInstance())); - container_->Add(button1_); - } - - /* DeInit:删除组件*/ - void TraingWinView::DeInit() - { - container_->RemoveAll(); - UIView *view = static_cast(container_)->GetChildrenHead(); - while (view != nullptr) - { - UIView *tempView = view; - view = view->GetNextSibling(); - if (tempView->GetParent()) - { - static_cast(tempView->GetParent())->Remove(tempView); - } - delete tempView; - } - delete container_; - container_ = nullptr; - } - - void TraingWinView::PreLoad(void) - { - if (!viewiInitStatus) - { - InitView(); - imageAnimator->Start(); - viewiInitStatus = true; - } - } - void TraingWinView::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(TraingWinPresenter::GetInstance()); - if (draglistener == nullptr) - { - return; - } - container_->SetOnDragListener(draglistener); - - container_->SetTouchable(true); - container_->SetDraggable(true); - - PreLoad(); - RootView::GetInstance()->Add(container_); - } - - void TraingWinView::OnSetUpView() - { - - View::OnSetUpView(); - Draw(); - } - - void TraingWinView::OnTearDownView() - { - - View::OnTearDownView(); - return; - } - - void TraingWinView::OnStop() - { - View::OnStop(); - imageAnimator->Stop(); - RootView::GetInstance()->RemoveAll(); - return; - } -} diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp index 4f4b42412..41f557cdb 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp @@ -299,11 +299,11 @@ namespace OHOS if (TraingCardView::GetInstance()->RefreshEndView()) { // 进行存储操作? - NativeAbility::GetInstance().EnterSlice(VIEW_TRAININGWIN); + NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGENDDATA); } else { - NativeAbility::GetInstance().Back(); + NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGMORE); } } // 返回按键 @@ -330,8 +330,8 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Invalid sport command"); return false; } - uapi_set_screen_on_api(); // 亮屏检测 - NativeAbility::GetInstance().EnterSlice(VIEW_TRAININGCRAD); // 切换Slice + uapi_set_screen_on_api(); // 亮屏检测 + NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCRAD); // 切换Slice switch (cmd->sportType) {