From: Caisking <3449750381@qq.com> Date: Mon, 15 Apr 2024 06:33:14 +0000 (+0800) Subject: 更新TrainingModel消息同步处理 X-Git-Tag: release_V1.2.70_20241020_135402~1175^2~10 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=refs%2Fchanges%2F5%2Fhead;p=mirrors%2FFD230.git 更新TrainingModel消息同步处理 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEndnote2Presenter.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEndnote2Presenter.h deleted file mode 100644 index 0264ef02d..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEndnote2Presenter.h +++ /dev/null @@ -1,36 +0,0 @@ - -#ifndef _TraingEndnote2_PRESENTER_H -#define _TraingEndnote2_PRESENTER_H - -#include "Presenter.h" -#include "TraingEndnote2View.h" - -namespace OHOS -{ - class TraingEndnote2View; - - class TraingEndnote2Presenter : public Presenter, - public UIView::OnClickListener, - public UIView::OnDragListener - { - public: - TraingEndnote2Presenter(); - virtual ~TraingEndnote2Presenter(); - - void OnStart() override; - void OnPause() override; - void OnResume() override; - void OnStop() override; - static TraingEndnote2Presenter *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/TraingEndnote2View.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEndnote2View.h deleted file mode 100644 index 49108ce6f..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEndnote2View.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef _TraingEndnote2_VIEW_H -#define _TraingEndnote2_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 "traing/include/TraingModel.h" -#include "traing/Training_UiConfig.h" -#include "TraingEndnote2Presenter.h" -namespace OHOS -{ -#define BUTTONNO "button1" -#define BUTTONYES "button2" - - class TraingEndnote2Presenter; - class TraingEndnote2View : public View - { - - public: - TraingEndnote2View(); - virtual ~TraingEndnote2View(); - static TraingEndnote2View *GetInstance(void); - - void OnStart() override; - void OnSetUpView() override; - void OnTearDownView() override; - void OnStop() override; - void InitView(); - void DeInit(); - - void PreLoad(void); - - // 通过函数改变 - void SetLabel(); - void SetButton(); - - private: - UIView::OnDragListener *draglistener{nullptr}; - TraingEndnote2View(TraingEndnote2View &&) = delete; - TraingEndnote2View &operator=(TraingEndnote2View &&) = delete; - - UIViewGroup *container_ = nullptr; - - UILabelExt *label1_ = nullptr; - UILabelExt *label2_ = nullptr; - - UIButton *button1_ = nullptr; - UIButton *button2_ = nullptr; - bool viewiInitStatus{false}; - }; -} // namespace OHOS -#endif // TraingEndnote2_PRESENTER_H diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEndnotePresenter.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEndnotePresenter.h deleted file mode 100644 index 219e3972d..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEndnotePresenter.h +++ /dev/null @@ -1,34 +0,0 @@ - -#ifndef _TraingEndnote_PRESENTER_H -#define _TraingEndnote_PRESENTER_H - -#include "Presenter.h" -#include "TraingEndnoteView.h" - -namespace OHOS -{ - class TraingEndnoteView; - - class TraingEndnotePresenter : public Presenter, - public UIView::OnClickListener, - public UIView::OnDragListener - { - public: - TraingEndnotePresenter(); - virtual ~TraingEndnotePresenter(); - - void OnStart() override; - void OnPause() override; - void OnResume() override; - void OnStop() override; - static TraingEndnotePresenter *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/TraingEndnoteView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEndnoteView.h deleted file mode 100644 index c8cc0cfb9..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEndnoteView.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef _TraingEndnote_VIEW_H -#define _TraingEndnote_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 "traing/include/TraingModel.h" -#include "traing/Training_UiConfig.h" -#include "TraingEndnotePresenter.h" -namespace OHOS -{ -#define BUTTONNO "button1" -#define BUTTONYES "button2" - - class TraingEndnotePresenter; - class TraingEndnoteView : public View - { - - public: - TraingEndnoteView(); - virtual ~TraingEndnoteView(); - static TraingEndnoteView *GetInstance(void); - - void OnStart() override; - void OnSetUpView() override; - void OnTearDownView() override; - void OnStop() override; - void InitView(); - void DeInit(); - - void InitList(); - void PreLoad(void); - - // 通过函数改变 - void SetLabel(); - void SetButton(); - - private: - UIView::OnDragListener *draglistener{nullptr}; - TraingEndnoteView(TraingEndnoteView &&) = delete; - TraingEndnoteView &operator=(TraingEndnoteView &&) = delete; - - UIViewGroup *container_ = nullptr; - - UILabelExt *label1_ = nullptr; - UILabelExt *label2_ = nullptr; - - UIButton *button1_ = nullptr; - UIButton *button2_ = nullptr; - bool viewiInitStatus{false}; - }; -} // namespace OHOS -#endif // TraingEndnote_PRESENTER_H diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEndnote2Presenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEndnote2Presenter.cpp deleted file mode 100644 index 79a6f90af..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEndnote2Presenter.cpp +++ /dev/null @@ -1,85 +0,0 @@ -#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/TraingEndnote2Presenter.h" -// #include "TraingEndnote2View.h" - -namespace OHOS -{ - - // 当前Presenter属性实例化的内存指针 - static TraingEndnote2Presenter *g_pTraingEndnote2Presenter = nullptr; - - TraingEndnote2Presenter::TraingEndnote2Presenter() - { - - g_pTraingEndnote2Presenter = this; - } - - TraingEndnote2Presenter::~TraingEndnote2Presenter() - { - - g_pTraingEndnote2Presenter = nullptr; - } - - TraingEndnote2Presenter *TraingEndnote2Presenter::GetInstance() - { - - return g_pTraingEndnote2Presenter; - } - - void TraingEndnote2Presenter::OnStart() - { - - Presenter::OnStart(); - } - - void TraingEndnote2Presenter::OnPause(void) - { - - Presenter::OnPause(); - } - - void TraingEndnote2Presenter::OnResume(void) - { - - Presenter::OnResume(); - } - - void TraingEndnote2Presenter::OnStop(void) - { - - Presenter::OnStop(); - } - - bool TraingEndnote2Presenter::OnDrag(UIView &view, const DragEvent &event) - { - - // if (event.GetDragDirection() == DragEvent::DIRECTION_TOP_TO_BOTTOM) - // { - // NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGDATA); - // } - UNUSED(view); - return true; - } - - bool TraingEndnote2Presenter::OnClick(UIView &view, const ClickEvent &event) - { - - // 根据控件id查找是哪个控件触发了点击回调 - if (strcmp(view.GetViewId(), BUTTONNO) == 0) - { - // NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCONTROL); - } - if (strcmp(view.GetViewId(), BUTTONYES) == 0) - { - NativeAbility::GetInstance().ChangeSlice(VIEW_TRAINING); - } - return true; - } -} diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEndnote2View.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEndnote2View.cpp deleted file mode 100644 index 635a0cf40..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEndnote2View.cpp +++ /dev/null @@ -1,140 +0,0 @@ - -#include "traing/include/TraingEndnote2View.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 TraingEndnote2View *g_pTraingEndnote2View{nullptr}; - - TraingEndnote2View::TraingEndnote2View() - { - g_pTraingEndnote2View = this; - } - - TraingEndnote2View::~TraingEndnote2View() - { - DeInit(); - g_pTraingEndnote2View = nullptr; - } - - TraingEndnote2View *TraingEndnote2View::GetInstance() - { - - return g_pTraingEndnote2View; - } - - /* InitView:初始化界面*/ - void TraingEndnote2View ::InitView() - { - if (container_ == nullptr) - { - container_ = new UIViewGroup(); - container_->SetPosition(0, 0, 466, 466); - container_->SetStyle(STYLE_BACKGROUND_OPA, 0); - } - - // 初始化Lable - TraingModel::GetInstance()->InitLabel(label1_, 203, 52, 90, 35, "label1", "注意", DEFAULT_VECTOR_FONT_FILENAME, 30); - TraingModel::GetInstance()->InitLabel(label2_, 56, 167, 60, 40, "label2", "当前运动量太小,无法记录\n是否结束运动", DEFAULT_VECTOR_FONT_FILENAME, 30); - - container_->Add(label1_); - container_->Add(label2_); - - TraingModel::GetInstance()->InitButton(button1_, 111, 299, 100, 100, BUTTONNO); - button1_->SetOnClickListener(static_cast(TraingEndnote2Presenter::GetInstance())); - // Set additional property - button1_->SetImageSrc(NO_IMAGE, NO_IMAGE); - - TraingModel::GetInstance()->InitButton(button2_, 256, 299, 100, 100, BUTTONYES); - button2_->SetOnClickListener(static_cast(TraingEndnote2Presenter::GetInstance())); - // Set additional property - button2_->SetImageSrc(YES_IMAGE, YES_IMAGE); - - container_->Add(button1_); - container_->Add(button2_); - } - - /* DeInit:删除组件 */ - void TraingEndnote2View::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 TraingEndnote2View::PreLoad(void) - { - if (!viewiInitStatus) - { - InitView(); - viewiInitStatus = true; - } - } - void TraingEndnote2View::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(TraingEndnote2Presenter::GetInstance()); - if (draglistener == nullptr) - { - return; - } - container_->SetOnDragListener(draglistener); - - container_->SetTouchable(true); - container_->SetDraggable(true); - - PreLoad(); - RootView::GetInstance()->Add(container_); - } - - void TraingEndnote2View::OnSetUpView() - { - - View::OnSetUpView(); - Draw(); - } - - void TraingEndnote2View::OnTearDownView() - { - - View::OnTearDownView(); - return; - } - - void TraingEndnote2View::OnStop() - { - View::OnStop(); - RootView::GetInstance()->RemoveAll(); - return; - } -} diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEndnotePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEndnotePresenter.cpp deleted file mode 100644 index 9ae0f7a45..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEndnotePresenter.cpp +++ /dev/null @@ -1,85 +0,0 @@ -#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/TraingEndnotePresenter.h" -// #include "TraingEndnoteView.h" - -namespace OHOS -{ - - // 当前Presenter属性实例化的内存指针 - static TraingEndnotePresenter *g_pTraingEndnotePresenter = nullptr; - - TraingEndnotePresenter::TraingEndnotePresenter() - { - - g_pTraingEndnotePresenter = this; - } - - TraingEndnotePresenter::~TraingEndnotePresenter() - { - - g_pTraingEndnotePresenter = nullptr; - } - - TraingEndnotePresenter *TraingEndnotePresenter::GetInstance() - { - - return g_pTraingEndnotePresenter; - } - - void TraingEndnotePresenter::OnStart() - { - - Presenter::OnStart(); - } - - void TraingEndnotePresenter::OnPause(void) - { - - Presenter::OnPause(); - } - - void TraingEndnotePresenter::OnResume(void) - { - - Presenter::OnResume(); - } - - void TraingEndnotePresenter::OnStop(void) - { - - Presenter::OnStop(); - } - - bool TraingEndnotePresenter::OnDrag(UIView &view, const DragEvent &event) - { - - // if (event.GetDragDirection() == DragEvent::DIRECTION_TOP_TO_BOTTOM) - // { - // NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGDATA); - // } - UNUSED(view); - return true; - } - - bool TraingEndnotePresenter::OnClick(UIView &view, const ClickEvent &event) - { - - // 根据控件id查找是哪个控件触发了点击回调 - if (strcmp(view.GetViewId(), BUTTONNO) == 0) - { - //NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCONTROL); - } - if (strcmp(view.GetViewId(), BUTTONYES) == 0) - { - NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGWIN); - } - return true; - } -} diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEndnoteView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEndnoteView.cpp deleted file mode 100644 index 59a6739a9..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEndnoteView.cpp +++ /dev/null @@ -1,140 +0,0 @@ - -#include "traing/include/TraingEndnoteView.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 TraingEndnoteView *g_pTraingEndnoteView{nullptr}; - - TraingEndnoteView::TraingEndnoteView() - { - g_pTraingEndnoteView = this; - } - - TraingEndnoteView::~TraingEndnoteView() - { - DeInit(); - g_pTraingEndnoteView = nullptr; - } - - TraingEndnoteView *TraingEndnoteView::GetInstance() - { - - return g_pTraingEndnoteView; - } - - /* InitView:初始化界面*/ - void TraingEndnoteView ::InitView() - { - if (container_ == nullptr) - { - container_ = new UIViewGroup(); - container_->SetPosition(0, 0, 466, 466); - container_->SetStyle(STYLE_BACKGROUND_OPA, 0); - } - - // 初始化Lable - TraingModel::GetInstance()->InitLabel(label1_, 173, 52, 90, 35, "label1", "结束运动", DEFAULT_VECTOR_FONT_FILENAME, 30); - TraingModel::GetInstance()->InitLabel(label2_, 116, 187, 60, 40, "label2", "是否结束本次运动", DEFAULT_VECTOR_FONT_FILENAME, 26); - - container_->Add(label1_); - container_->Add(label2_); - - TraingModel::GetInstance()->InitButton(button1_, 111, 299, 100, 100, BUTTONNO); - button1_->SetOnClickListener(static_cast(TraingEndnotePresenter::GetInstance())); - // Set additional property - button1_->SetImageSrc(NO_IMAGE, NO_IMAGE); - - TraingModel::GetInstance()->InitButton(button2_, 256, 299, 100, 100, BUTTONYES); - button2_->SetOnClickListener(static_cast(TraingEndnotePresenter::GetInstance())); - // Set additional property - button2_->SetImageSrc(YES_IMAGE, YES_IMAGE); - - container_->Add(button1_); - container_->Add(button2_); - } - - /* DeInit:删除组件 */ - void TraingEndnoteView::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 TraingEndnoteView::PreLoad(void) - { - if (!viewiInitStatus) - { - InitView(); - viewiInitStatus = true; - } - } - void TraingEndnoteView::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(TraingEndnotePresenter::GetInstance()); - if (draglistener == nullptr) - { - return; - } - container_->SetOnDragListener(draglistener); - - container_->SetTouchable(true); - container_->SetDraggable(true); - - PreLoad(); - RootView::GetInstance()->Add(container_); - } - - void TraingEndnoteView::OnSetUpView() - { - - View::OnSetUpView(); - Draw(); - } - - void TraingEndnoteView::OnTearDownView() - { - - View::OnTearDownView(); - return; - } - - void TraingEndnoteView::OnStop() - { - View::OnStop(); - RootView::GetInstance()->RemoveAll(); - return; - } -} diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp index 87ef50174..8b71a235f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp @@ -87,14 +87,11 @@ extern "C" return; } cywee_activity_result_t *cyweeInfo = nullptr; // 在switch语句外部定义变量 - int rets; PRINT("request %d\r\n", request->msgId); -#if 0 - switch (request->msgId) + if (request->msgId == TOPIC_EVENT_ACTIVITY_UPDATE) { - case TOPIC_EVENT_ACTIVITY_UPDATE: cyweeInfo = new cywee_activity_result_t(); // 在case块内分配内存 - rets = memcpy_s(cyweeInfo, sizeof(cywee_activity_result_t), (cywee_activity_result_t *)request->data, request->len); + int rets = memcpy_s(cyweeInfo, sizeof(cywee_activity_result_t), (cywee_activity_result_t *)request->data, request->len); if (rets != EOK) { delete cyweeInfo; // 处理内存分配失败的情况 @@ -103,24 +100,7 @@ extern "C" return; } TraingModel::GetInstance()->AnalysisData(cyweeInfo); - break; - case TOPIC_EVENT_INACTIVITY_UPDATE: - cyweeInfo = new cywee_activity_result_t(); // 在case块内分配内存 - rets = memcpy_s(cyweeInfo, sizeof(cywee_activity_result_t), (cywee_activity_result_t *)request->data, request->len); - if (rets != EOK) - { - delete cyweeInfo; // 处理内存分配失败的情况 - cyweeInfo = NULL; - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "memcpy_s cywee_activity_result_t fail! ret = %d", rets); - return; - } - TraingModel::GetInstance()->AnalysisData(cyweeInfo); - break; - default: - // 处理未知msgId的情况 - break; } -#endif delete cyweeInfo; // 释放内存 } #ifdef __cplusplus