+++ /dev/null
-
-#ifndef _TraingEndnote2_PRESENTER_H
-#define _TraingEndnote2_PRESENTER_H
-
-#include "Presenter.h"
-#include "TraingEndnote2View.h"
-
-namespace OHOS
-{
- class TraingEndnote2View;
-
- class TraingEndnote2Presenter : public Presenter<TraingEndnote2View>,
- 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
+++ /dev/null
-#ifndef _TraingEndnote2_VIEW_H
-#define _TraingEndnote2_VIEW_H
-
-#include "BaseView.h"
-#include "View.h"
-#include <ui_scroll_view.h>
-#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<TraingEndnote2Presenter>
- {
-
- 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
+++ /dev/null
-
-#ifndef _TraingEndnote_PRESENTER_H
-#define _TraingEndnote_PRESENTER_H
-
-#include "Presenter.h"
-#include "TraingEndnoteView.h"
-
-namespace OHOS
-{
- class TraingEndnoteView;
-
- class TraingEndnotePresenter : public Presenter<TraingEndnoteView>,
- 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
+++ /dev/null
-#ifndef _TraingEndnote_VIEW_H
-#define _TraingEndnote_VIEW_H
-
-#include "BaseView.h"
-#include "View.h"
-#include <ui_scroll_view.h>
-#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<TraingEndnotePresenter>
- {
-
- 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
+++ /dev/null
-#include "AppViewIDs.h"
-#include "components/ui_label_ext.h"
-#include "language/font/ui_resource_string.h"
-#include "NativeAbility.h"
-
-#include <iostream>
-#include <chrono>
-#include <thread>
-#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<TraingEndnote2View>::OnStart();
- }
-
- void TraingEndnote2Presenter::OnPause(void)
- {
-
- Presenter<TraingEndnote2View>::OnPause();
- }
-
- void TraingEndnote2Presenter::OnResume(void)
- {
-
- Presenter<TraingEndnote2View>::OnResume();
- }
-
- void TraingEndnote2Presenter::OnStop(void)
- {
-
- Presenter<TraingEndnote2View>::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;
- }
-}
+++ /dev/null
-
-#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 <ui_scroll_view.h>
-#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<UIView::OnClickListener *>(TraingEndnote2Presenter::GetInstance()));
- // Set additional property
- button1_->SetImageSrc(NO_IMAGE, NO_IMAGE);
-
- TraingModel::GetInstance()->InitButton(button2_, 256, 299, 100, 100, BUTTONYES);
- button2_->SetOnClickListener(static_cast<UIView::OnClickListener *>(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<UIViewGroup *>(container_)->GetChildrenHead();
- while (view != nullptr)
- {
- UIView *tempView = view;
- view = view->GetNextSibling();
- if (tempView->GetParent())
- {
- static_cast<UIViewGroup *>(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<UIView::OnDragListener *>(TraingEndnote2Presenter::GetInstance());
- if (draglistener == nullptr)
- {
- return;
- }
- container_->SetOnDragListener(draglistener);
-
- container_->SetTouchable(true);
- container_->SetDraggable(true);
-
- PreLoad();
- RootView::GetInstance()->Add(container_);
- }
-
- void TraingEndnote2View::OnSetUpView()
- {
-
- View<TraingEndnote2Presenter>::OnSetUpView();
- Draw();
- }
-
- void TraingEndnote2View::OnTearDownView()
- {
-
- View<TraingEndnote2Presenter>::OnTearDownView();
- return;
- }
-
- void TraingEndnote2View::OnStop()
- {
- View<TraingEndnote2Presenter>::OnStop();
- RootView::GetInstance()->RemoveAll();
- return;
- }
-}
+++ /dev/null
-#include "AppViewIDs.h"
-#include "components/ui_label_ext.h"
-#include"language/font/ui_resource_string.h"
-#include "NativeAbility.h"
-
-#include <iostream>
-#include <chrono>
-#include <thread>
-#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<TraingEndnoteView>::OnStart();
- }
-
- void TraingEndnotePresenter::OnPause(void)
- {
-
- Presenter<TraingEndnoteView>::OnPause();
- }
-
- void TraingEndnotePresenter::OnResume(void)
- {
-
- Presenter<TraingEndnoteView>::OnResume();
- }
-
- void TraingEndnotePresenter::OnStop(void)
- {
-
- Presenter<TraingEndnoteView>::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;
- }
-}
+++ /dev/null
-
-#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 <ui_scroll_view.h>
-#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<UIView::OnClickListener *>(TraingEndnotePresenter::GetInstance()));
- // Set additional property
- button1_->SetImageSrc(NO_IMAGE, NO_IMAGE);
-
- TraingModel::GetInstance()->InitButton(button2_, 256, 299, 100, 100, BUTTONYES);
- button2_->SetOnClickListener(static_cast<UIView::OnClickListener *>(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<UIViewGroup *>(container_)->GetChildrenHead();
- while (view != nullptr)
- {
- UIView *tempView = view;
- view = view->GetNextSibling();
- if (tempView->GetParent())
- {
- static_cast<UIViewGroup *>(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<UIView::OnDragListener *>(TraingEndnotePresenter::GetInstance());
- if (draglistener == nullptr)
- {
- return;
- }
- container_->SetOnDragListener(draglistener);
-
- container_->SetTouchable(true);
- container_->SetDraggable(true);
-
- PreLoad();
- RootView::GetInstance()->Add(container_);
- }
-
- void TraingEndnoteView::OnSetUpView()
- {
-
- View<TraingEndnotePresenter>::OnSetUpView();
- Draw();
- }
-
- void TraingEndnoteView::OnTearDownView()
- {
-
- View<TraingEndnotePresenter>::OnTearDownView();
- return;
- }
-
- void TraingEndnoteView::OnStop()
- {
- View<TraingEndnotePresenter>::OnStop();
- RootView::GetInstance()->RemoveAll();
- return;
- }
-}
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; // 处理内存分配失败的情况
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