${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/training_list_aquatic/src/TraingAquaticItemView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/training_list_aquatic/src/TraingAquaticModel.cpp
+ #其他训练
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/training_list_other/src/TraingOtherView.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/training_list_other/src/TraingOtherPresenter.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/training_list_other/src/TraingOtherAdapter.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/training_list_other/src/TraingOtherItemView.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/training_list_other/src/TraingOtherModel.cpp
+
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/training_list_more/src/TraingMoreView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/training_list_more/src/TraingMorePresenter.cpp
VIEW_TRAININGREST, // 休闲运动列表
VIEW_TRAININGBALL, // 球类运动列表
VIEW_TRAININGAQUATIC, // 水上运动列表
-
+ VIEW_TRAININGOTHER, // 其他列表
/* ---------------------------------- GPS训练 --------------------------------- */
VIEW_TRAININGGPS, // GPS训练
VIEW_TRAININGGPSSET, // GPS训练目标(时长,距离,卡路里,步数)
void InitTraingRestSlice(void); // 休闲训练
void InitTraingBallSlice(void); // 球类训练
void InitTraingAquaticSlice(void); // 水上训练
+ void InitTraingOtherSlice(void); // 其他训练
void InitTraingRecordSlice(void); // 训练记录
#include "traing/training_list_ball/include/TraingBallView.h"
#include "traing/training_list_aquatic/include/TraingAquaticPresenter.h"
#include "traing/training_list_aquatic/include/TraingAquaticView.h"
+#include "traing/training_list_other/include/TraingOtherPresenter.h"
+#include "traing/training_list_other/include/TraingOtherView.h"
/* ---------------------------------- 主界面卡片 --------------------------------- */
#include "traing/training_card/include/TraingCardPresenter.h"
#include "traing/training_card/include/TraingCardView.h"
{VIEW_TRAININGREST, &NativeLauncher::InitTraingRestSlice}, // 休闲训练
{VIEW_TRAININGBALL, &NativeLauncher::InitTraingBallSlice}, // 球类训练
{VIEW_TRAININGAQUATIC, &NativeLauncher::InitTraingAquaticSlice}, // 水上训练
+ {VIEW_TRAININGOTHER, &NativeLauncher::InitTraingOtherSlice}, // 水上训练
/* -------------------------------------------------------------------------- */
#ifdef SUPPORT_ALIPAY_SEC
SliceProxy *TraingAquaticview = new AbilitySliceProxy<TraingAquaticView, TraingAquaticPresenter>;
NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAININGAQUATIC, TraingAquaticview);
}
+ void NativeLauncher::InitTraingOtherSlice(void)
+ {
+ SliceProxy *TraingOtherview = new AbilitySliceProxy<TraingOtherView, TraingOtherPresenter>;
+ NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAININGOTHER, TraingOtherview);
+ }
/* -------------------------------------------------------------------------- */
// 省电模式
* @Author: Caisking 3449750381@qq.com
* @Date: 2024-03-29 15:18:34
* @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-03-29 18:03:00
+ * @LastEditTime: 2024-03-29 19:23:48
* @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_aquatic/include/TraingAquaticModel.h
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-26 09:46:17
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-29 19:24:43
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_aquatic/src/TraingAquaticPresenter.cpp
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
/***
* @Author: Caisking 3449750381@qq.com
* @Date: 2024-03-19 17:37:19
/* -------------------------------------------------------------------------- */
// 初始化Lable
- TraingModel::GetInstance()->InitLabel(title, 173, 52, 200, 60, "label1", "极限运动", DEFAULT_VECTOR_FONT_FILENAME, 30);
+ TraingModel::GetInstance()->InitLabel(title, 173, 52, 200, 60, "label1", "冰上运动", DEFAULT_VECTOR_FONT_FILENAME, 30);
scrollView->Add(title);
// UIList 的适配器
p_TraingAquaticListAdapter = new TraingAquaticAdapter();
/* -------------------------------------------------------------------------- */
// 初始化Lable
- TraingModel::GetInstance()->InitLabel(title, 173, 52, 200, 60, "label1", "极限运动", DEFAULT_VECTOR_FONT_FILENAME, 30);
+ TraingModel::GetInstance()->InitLabel(title, 173, 52, 200, 60, "label1", "球类运动", DEFAULT_VECTOR_FONT_FILENAME, 30);
scrollView->Add(title);
// UIList 的适配器
p_TraingBallListAdapter = new TraingBallAdapter();
}\r
if (strcmp(view.GetViewId(), BUTTON_OTHER) == 0)\r
{\r
- NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGLIMIT);\r
+ NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGOTHER);\r
}\r
if (strcmp(view.GetViewId(), BUTTON_REST) == 0)\r
{\r
--- /dev/null
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-29 17:36:30
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-29 17:47:13
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_aquatic/include/TraingOtherAapter.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef TraingOther_ADAPTER_H
+#define TraingOther_ADAPTER_H
+#include <list>
+#include <string>
+#include "components/ui_list.h"
+#include "components/abstract_adapter.h"
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "language/font/ui_resource_string.h"
+#include "components/ui_checkbox.h"
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+
+
+// 列表的适配器
+namespace OHOS
+{
+
+ typedef struct
+ {
+ AppViewId id;
+ UIResourceTextId labelid; // 标签
+ } TraingOtherItem;
+
+ class TraingOtherAdapter : public AbstractAdapter
+ {
+ public:
+ explicit TraingOtherAdapter();
+ virtual ~TraingOtherAdapter();
+
+ void SetData(std::list<TraingOtherItem> &data);
+
+ virtual uint16_t GetCount(void) override;
+
+ virtual UIView *GetView(UIView *inView, int16_t index) override;
+
+ virtual void AddItem(const TraingOtherItem &item);
+
+ void SetItemClickListener(UIView::OnClickListener *itemclicklistener)
+ {
+ itemClickListener = itemclicklistener;
+ }
+
+ private:
+ std::list<TraingOtherItem> listData;
+ UIView::OnClickListener *itemClickListener{nullptr};
+ };
+}
+
+#endif
\ No newline at end of file
--- /dev/null
+
+#ifndef TraingOther_ITEM_VIEW_H
+#define TraingOther_ITEM_VIEW_H
+
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "language/font/ui_resource_string.h"
+#include "components/ui_view_group.h"
+#include "components/ui_checkbox.h"
+#include "components/ui_image_view.h"
+#include "traing/training_list_other/include/TraingOtherAdapter.h"
+#include "components/ui_label_button.h"
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include "language/font/ui_resource_string.h"
+#include "ohos_types.h"
+
+namespace OHOS
+{
+ class TraingOtherItemView : public UIViewGroup
+ {
+ public:
+ explicit TraingOtherItemView();
+ virtual ~TraingOtherItemView();
+ virtual void SetItemInfo(const TraingOtherItem itemInfo);
+ virtual void SetUpChild();
+ AppViewId GetTraingOtherIndex();
+ UIResourceTextId GetTraingOtherId();
+
+ private:
+ TraingOtherItemView(const TraingOtherItemView &);
+ UIImageView sbackground; // 背景
+ UIImageView sicon; // 箭头
+ UILabelExt sLabel; // 标签
+ TraingOtherItem sItemInfo = {VIEW_INVALID, STR_EXERCISE_GENERAL};
+ };
+
+}
+#endif
\ No newline at end of file
--- /dev/null
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-29 19:21:24
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-29 19:33:05
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_other/include/TraingOtherModel.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-29 15:18:34
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-29 18:03:00
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_other/include/TraingOtherModel.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef TraingOther_MODEL_H
+#define TraingOther_MODEL_H
+
+#include <cstdint>
+#include <map>
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include "language/font/ui_resource_string.h"
+#include "components/ui_label_ext.h"
+#include "language/font/ui_resource_string.h"
+#include "UiConfig.h"
+#include "TraingOtherPresenter.h"
+#include "traing/training_list_other/include/TraingOtherAdapter.h"
+
+namespace OHOS
+{
+ class TraingOtherModel
+ {
+ public:
+ static TraingOtherModel &GetInstance(void);
+ void InitTraingOtherListItem();
+ const TraingOtherItem *GetTraingOtherlistItems() const;
+ uint8_t GetTraingOtherListNum() const;
+ // const std::map<TraingOtherIndex, AppViewId> &GetTraingOtherIdToViewId() const;
+
+ private:
+ TraingOtherModel();
+ TraingOtherModel(const TraingOtherModel &);
+ TraingOtherModel &operator=(const TraingOtherModel &);
+ virtual ~TraingOtherModel();
+ static const uint16_t TraingOtherListMaxNum = 9;
+ TraingOtherItem TraingOthers[TraingOtherListMaxNum] = {VIEW_INVALID, STR_EXERCISE_GENERAL};
+ // std::map<int, AppViewId> TraingOtherIdToViewId;
+ bool btConnectStatus{false};
+ };
+}
+
+#endif
--- /dev/null
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-19 17:37:18
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-29 19:23:56
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_limit/include/TraingOtherPresenter.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef _TraingOther_PRESENTER_H
+#define _TraingOther_PRESENTER_H
+
+#include "Presenter.h"
+#include "TraingOtherView.h"
+
+namespace OHOS
+{
+ class TraingOtherView;
+ class TraingOtherModel;
+ class TraingOtherPresenter : public Presenter<TraingOtherView>,
+ public UIView::OnClickListener,
+ public UIView::OnDragListener
+ {
+ public:
+ TraingOtherPresenter();
+ virtual ~TraingOtherPresenter();
+
+ void OnStart() override;
+ void OnPause() override;
+ void OnResume() override;
+ void OnStop() override;
+
+ static TraingOtherPresenter *GetInstance();
+
+ private:
+ // 因为继承了OnClickener,所以有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;
+
+ TraingOtherModel *p_TraingOtherModel{nullptr};
+ };
+} // namespace OHOS
+
+#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
--- /dev/null
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-19 17:37:18
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-27 11:15:59
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_other/include/TraingOtherView.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef TraingOther_VIEW_H
+#define TraingOther_VIEW_H
+
+#include "BaseView.h"
+#include "View.h"
+#include "components/ui_view_group.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_list.h"
+#include "traing/training_list_other/include/TraingOtherAdapter.h"
+#include "traing/training_list_other/include/TraingOtherModel.h"
+#include "components/ui_label_button_ext.h"
+#include "components/ui_label_ext.h"
+#include"language/font/ui_resource_string.h"
+
+namespace OHOS
+{
+ class TraingOtherPresenter;
+ class TraingOtherModel;
+ class TraingOtherView : public View<TraingOtherPresenter>, public UIViewGroup
+ {
+
+ public:
+ TraingOtherView();
+ virtual ~TraingOtherView();
+ static TraingOtherView *GetInstance(void);
+
+ void OnStart() override;
+ void OnSetUpView() override;
+ void OnTearDownView() override;
+ void OnStop() override;
+
+ UIList *GetList();
+ void AddToTraingOtherList(const TraingOtherItem &item);
+
+ private:
+ void InitView(void);
+ void DeInitView(void);
+ void PreLoad(void);
+
+ private:
+ UIScrollView *scrollView = nullptr;
+ UILabelExt *title{nullptr};
+ TraingOtherAdapter *p_TraingOtherListAdapter{nullptr};
+ UIList *TraingOtherList = nullptr;
+ UIView::OnDragListener *draglistener{nullptr};
+
+ TraingOtherPresenter *g_TraingOtherPresenter{nullptr};
+ TraingOtherModel *g_TraingOtherModel{nullptr};
+ bool viewInitStatus{false};
+ };
+} // namespace OHOS
+#endif
\ No newline at end of file
--- /dev/null
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-29 19:21:41
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-29 19:24:17
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_other/src/TraingOtherAdapter.cpp
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+#include "traing/training_list_other/include/TraingOtherAdapter.h"
+#include "traing/training_list_other/include/TraingOtherModel.h"
+#include "traing/training_list_other/include/TraingOtherItemView.h"
+
+#include "wearable_log.h"
+
+namespace OHOS
+{
+ TraingOtherAdapter::TraingOtherAdapter() {}
+
+ TraingOtherAdapter::~TraingOtherAdapter()
+ {
+ listData.clear();
+ }
+
+ uint16_t TraingOtherAdapter::GetCount(void)
+ {
+ return listData.size();
+ }
+
+ void TraingOtherAdapter::SetData(std::list<TraingOtherItem> &data)
+ {
+ if (!listData.empty())
+ {
+ listData.clear();
+ }
+ std::list<TraingOtherItem>::iterator it;
+ for (it = data.begin(); it != data.end(); it++)
+ {
+ listData.push_back(*it);
+ }
+ }
+
+ /// @brief 为列表的每一项创建一个视图
+ /// @param inView 一个指向已存在的视图对象的指
+ /// @param index 要创建的视图在列表中的索引l。
+ /// @return 返回该视图对象
+ UIView *TraingOtherAdapter::GetView(UIView *inView, int16_t index)
+ {
+
+ // 1.先检查列表数据是否为空,若为空则返回空指针
+ if (listData.empty())
+ {
+ return nullptr;
+ }
+ // 2.接着检查索引是否小于0,若小于0则返回空指针
+ if (index < 0)
+ {
+ return nullptr;
+ }
+ // 3.检查是否超出列表数据大小,若超出则返回空指针
+ size_t uindex = index;
+ if (uindex >= listData.size())
+ {
+ return nullptr;
+ }
+ // 4.通过迭代器访问列表中指定索引位置的元素,将其赋值给itemData变量
+ std::list<TraingOtherItem>::iterator it = listData.begin();
+ for (int i = 0; i < index; i++)
+ {
+ it++;
+ }
+ TraingOtherItem itemData = *it;
+ TraingOtherItemView *item = nullptr;
+ /*
+ 5.根据传入的inView参数是否已经存在一个视图对象,
+ 若为空则创建一个新的MessageItemView对象,
+ 否则将inView转换成MessageItemView类型的指针
+ */
+ if (inView == nullptr)
+ {
+ item = new TraingOtherItemView();
+ }
+ else
+ {
+ item = static_cast<TraingOtherItemView *>(inView);
+ }
+ item->SetItemInfo(itemData);
+ item->SetOnClickListener(itemClickListener);
+ return item;
+ }
+
+ void TraingOtherAdapter::AddItem(const TraingOtherItem &item)
+ {
+ listData.push_back(item);
+ }
+} // namespace OHOS
--- /dev/null
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-29 17:42:13
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-29 17:52:02
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_other/src/TraingOtherItem.cpp
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+
+#include "traing/training_list_other/include/TraingOtherItemView.h"
+#include "traing/include/TraingModel.h"
+#include "traing/Training_UiConfig.h"
+#include "components/ui_label_ext.h"
+#include "language/font/ui_resource_string.h"
+#include "UiConfig.h"
+namespace OHOS
+{
+
+ TraingOtherItemView::TraingOtherItemView()
+ {
+ SetPosition(0, 0, 380, 120); // 每一个itemview宽高要配置好,因为加到list都是以这个视图为基准
+ SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+ SetStyle(STYLE_BACKGROUND_OPA, 255);
+ SetTouchable(true);
+ SetUpChild();
+ Add(&sbackground);
+ Add(&sicon);
+ Add(&sLabel);
+ }
+
+ TraingOtherItemView::~TraingOtherItemView()
+ {
+ Remove(&sbackground);
+ Remove(&sicon);
+ Remove(&sLabel);
+ }
+
+ /// @brief 设置item的信息
+ /// @param itemInfo
+ void TraingOtherItemView::SetItemInfo(const TraingOtherItem itemInfo)
+ {
+ sItemInfo = itemInfo;
+ sLabel.SetTextId(itemInfo.labelid);
+ }
+
+ /// @brief 设置每一个itemview上的组件
+ void TraingOtherItemView::SetUpChild()
+ {
+ sbackground.SetSrc(PNG_SETTING_BACKGROUND_IMAGE);
+
+ sicon.SetPosition(330, 40);
+ sicon.SetSrc(ICON_IMAGE);
+ sicon.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE);
+
+ sLabel.SetPosition(50, 10, 300, 80);
+ sLabel.SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+ sLabel.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ sLabel.SetRollSpeed(0);
+ sLabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+ }
+
+ /// @brief 获取list的中每个组件的在list的下标
+ /// @return 返回下标
+ AppViewId TraingOtherItemView::GetTraingOtherIndex()
+ {
+ return sItemInfo.id;
+ }
+ UIResourceTextId TraingOtherItemView::GetTraingOtherId()
+ {
+ return sItemInfo.labelid;
+ }
+}
\ No newline at end of file
--- /dev/null
+
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-29 15:51:45
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-29 17:56:44
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_other/src/TraingOtherModel.cpp
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#include "traing/training_list_other/include/TraingOtherModel.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 "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include "language/font/ui_resource_string.h"
+namespace OHOS
+{
+
+ TraingOtherModel::TraingOtherModel() {}
+
+ TraingOtherModel::~TraingOtherModel() {}
+
+ TraingOtherModel &TraingOtherModel::GetInstance()
+ {
+ static TraingOtherModel instance;
+ return instance;
+ }
+
+ void TraingOtherModel::InitTraingOtherListItem()
+ {
+ TraingOtherItem defaultItems[] = {
+ {VIEW_TRAININGNOMAL, STR_OTHER_ELEVATOR},
+ {VIEW_TRAININGNOMAL, STR_OTHER_ESCALATOR},
+ {VIEW_TRAININGNOMAL, STR_OTHER_GARDENING},
+ {VIEW_TRAININGNOMAL, STR_OTHER_HORSEWORK},
+ {VIEW_TRAININGNOMAL, STR_OTHER_INVEHICLE},
+ {VIEW_TRAININGNOMAL, STR_OTHER_MEDITATION},
+ {VIEW_TRAININGNOMAL, STR_OTHER_STILL},
+ {VIEW_TRAININGNOMAL, STR_OTHER_TILTING},
+ {VIEW_TRAININGNOMAL, STR_OTHER_WHEELCHAIR}};
+
+ for (int i = 0; i < TraingOtherListMaxNum; i++)
+ {
+ TraingOthers[i] = defaultItems[i];
+ }
+ }
+
+ const TraingOtherItem *TraingOtherModel::GetTraingOtherlistItems() const
+ {
+ return TraingOthers;
+ }
+ uint8_t TraingOtherModel::GetTraingOtherListNum() const
+ {
+ return TraingOtherListMaxNum;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-19 17:37:19
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-26 19:51:06
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_other/src/TraingOtherPresenter.cpp
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-19 17:37:19
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-26 14:23:32
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/src/TraingOtherPresenter.cpp
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#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/training_list_other/include/TraingOtherItemView.h"
+#include "traing/training_list_other/include/TraingOtherPresenter.h"
+#include "traing/training_list_other/include/TraingOtherView.h"
+#include "traing/include/TraingModel.h"
+// #include "TraingOtherView.h"
+
+namespace OHOS
+{
+ extern const char *Other_buttons[];
+ extern char *Other_text[];
+
+ // 当前Presenter属性实例化的内存指针
+ static TraingOtherPresenter *g_pTraingOtherPresenter = nullptr;
+
+ TraingOtherPresenter::TraingOtherPresenter()
+ {
+ p_TraingOtherModel = &TraingOtherModel::GetInstance();
+ g_pTraingOtherPresenter = this;
+ }
+
+ TraingOtherPresenter::~TraingOtherPresenter()
+ {
+
+ g_pTraingOtherPresenter = nullptr;
+ }
+
+ TraingOtherPresenter *TraingOtherPresenter::GetInstance()
+ {
+
+ return g_pTraingOtherPresenter;
+ }
+
+ void TraingOtherPresenter::OnStart()
+ {
+ p_TraingOtherModel->InitTraingOtherListItem();
+ Presenter<TraingOtherView>::OnStart();
+ }
+
+ void TraingOtherPresenter::OnPause(void)
+ {
+ Presenter<TraingOtherView>::OnPause();
+ }
+
+ void TraingOtherPresenter::OnResume(void)
+ {
+ if (view_ == nullptr)
+ {
+ return;
+ }
+ const TraingOtherItem *itemInfo = p_TraingOtherModel->GetTraingOtherlistItems();
+ for (int i = 0; i < p_TraingOtherModel->GetTraingOtherListNum(); i++)
+ {
+ view_->AddToTraingOtherList(itemInfo[i]);
+ }
+ Presenter<TraingOtherView>::OnResume();
+ }
+
+ void TraingOtherPresenter::OnStop(void)
+ {
+
+ Presenter<TraingOtherView>::OnStop();
+ }
+ bool TraingOtherPresenter::OnDrag(UIView &view, const DragEvent &event)
+ {
+ return true;
+ }
+ bool TraingOtherPresenter::OnDragEnd(UIView &view, const DragEvent &event)
+ {
+ if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
+ {
+ NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGMORE);
+ }
+ UNUSED(view);
+ return true;
+ }
+
+ bool TraingOtherPresenter::OnClick(UIView &view, const ClickEvent &event)
+ {
+ UNUSED(event);
+ TraingOtherItemView *itemView = static_cast<TraingOtherItemView *>(&view);
+ AppViewId viewId = itemView->GetTraingOtherIndex();
+ UIResourceTextId sportid = itemView->GetTraingOtherId();
+ TraingModel::GetInstance()->SetSportEvent(sportid);
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnClick viewid = %d\n", viewId);
+ if (viewId < VIEW_MAX_INTER_APP)
+ {
+ NativeAbility::GetInstance().ChangeSlice(viewId);
+ return true;
+ }
+ return false;
+ }
+
+}
--- /dev/null
+#include "traing/training_list_other/include/TraingOtherView.h"
+#include "traing/training_list_other/include/TraingOtherPresenter.h"
+#include "traing/include/TraingModel.h"
+#include "traing/Training_UiConfig.h"
+
+#include "components/ui_label_ext.h"
+#include "language/font/ui_resource_string.h"
+#include "UiConfig.h"
+#include "wearable_log.h"
+
+namespace OHOS
+{
+ static constexpr uint8_t NUM_2 = 2;
+ static TraingOtherView *g_pTraingOtherView{nullptr};
+ /* --------------------------------- List --------------------------------- */
+ static constexpr int16_t Other_LIST_POSITION_X = 43;
+ static constexpr int16_t Other_LIST_POSITION_Y = 120;
+ static constexpr int16_t Other_SCROLLBLANKSIZE = 35; // 设置此滚动视图的空白大小。
+ static constexpr int16 MAX_SCR_DIS = 1000;
+ static constexpr int16 LIST_POS = 20;
+ static constexpr int16 SNUM_2 = 2;
+
+ TraingOtherView::TraingOtherView()
+ {
+ g_pTraingOtherView = this;
+ }
+
+ TraingOtherView::~TraingOtherView()
+ {
+ if (viewInitStatus == true)
+ {
+ DeInitView();
+ }
+ g_pTraingOtherView = nullptr;
+ }
+
+ TraingOtherView *TraingOtherView::GetInstance()
+ {
+ return g_pTraingOtherView;
+ }
+ /// @param item
+ void TraingOtherView::AddToTraingOtherList(const TraingOtherItem &item)
+ {
+ p_TraingOtherListAdapter->AddItem(item);
+ }
+ void TraingOtherView::InitView()
+ {
+ if (scrollView == nullptr)
+ {
+ scrollView = new UIScrollView();
+ }
+ scrollView->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+ // scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+ scrollView->SetScrollBlankSize(20);
+ // scrollView->SetReboundSize(100);
+ scrollView->SetTouchable(true);
+ scrollView->SetDraggable(true);
+ scrollView->SetDirection(1);
+ draglistener = static_cast<UIView::OnDragListener *>(TraingOtherPresenter::GetInstance());
+ scrollView->SetOnDragListener(draglistener);
+
+ /* -------------------------------------------------------------------------- */
+ // 初始化Lable
+ TraingModel::GetInstance()->InitLabel(title, 173, 52, 200, 60, "label1", "其他运动", DEFAULT_VECTOR_FONT_FILENAME, 30);
+ scrollView->Add(title);
+ // UIList 的适配器
+ p_TraingOtherListAdapter = new TraingOtherAdapter();
+ p_TraingOtherListAdapter->SetItemClickListener(presenter_);
+ if (TraingOtherList == nullptr)
+ {
+ TraingOtherList = new UIList();
+ }
+ TraingOtherList->SetPosition(Other_LIST_POSITION_X, Other_LIST_POSITION_Y);
+ TraingOtherList->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+ // TraingOtherList->SetScrollBlankSize(Other_SCROLLBLANKSIZE);
+ TraingOtherList->SetSelectPosition(HORIZONTAL_RESOLUTION / SNUM_2); // middle position
+ TraingOtherList->SetDraggable(true);
+ TraingOtherList->SetThrowDrag(false);
+ TraingOtherList->EnableAutoAlign(true);
+ TraingOtherList->SetElastic(true); // 设置回弹效果
+ TraingOtherList->SetMaxScrollDistance(MAX_SCR_DIS);
+ TraingOtherList->SetYScrollBarVisible(true); // 设置滑动滚动条
+
+ // 增加表冠控制
+ TraingOtherList->SetRotateFactor(2);
+ TraingOtherList->RequestFocus();
+ }
+ UIList *TraingOtherView::GetList()
+ {
+ return TraingOtherList;
+ }
+ void TraingOtherView::DeInitView()
+ {
+ // scrollView-> RemoveAll();
+ RemoveAll();
+ delete title;
+ title = nullptr;
+
+ delete TraingOtherList;
+ TraingOtherList = nullptr;
+
+ delete scrollView;
+ scrollView = nullptr;
+
+ delete draglistener;
+ draglistener = nullptr;
+ }
+
+ void TraingOtherView::PreLoad(void)
+ {
+ if (!viewInitStatus)
+ {
+ InitView();
+ viewInitStatus = true;
+ }
+ }
+
+ /// @brief 页面启动时需要执行的代码逻辑
+ void TraingOtherView::OnStart()
+ {
+ View<TraingOtherPresenter>::OnStart();
+ BaseView::RootView(Color::Black().full);
+ PreLoad();
+ }
+
+ /// @brief 创建页面的视图。
+ void TraingOtherView::OnSetUpView()
+ {
+ View<TraingOtherPresenter>::OnSetUpView();
+ scrollView->Add(title);
+ scrollView->Add(TraingOtherList);
+ scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+ RootView::GetInstance()->Add(scrollView);
+ TraingOtherList->SetAdapter(p_TraingOtherListAdapter);
+ // TraingOtherList->RefreshList(); // 刷新列表
+ Draw();
+ }
+
+ /// @brief 销毁页面的视图。
+ void TraingOtherView::OnTearDownView()
+ {
+ View<TraingOtherPresenter>::OnTearDownView();
+ return;
+ }
+
+ /// @brief 页面结束时需要执行的销毁逻辑。
+ void TraingOtherView::OnStop()
+ {
+ View<TraingOtherPresenter>::OnStop();
+ RootView::GetInstance()->RemoveAll();
+ RootView::GetInstance()->ClearFocus();
+ return;
+ }
+}
\ No newline at end of file
/* -------------------------------------------------------------------------- */
// 初始化Lable
- TraingModel::GetInstance()->InitLabel(title, 173, 52, 200, 60, "label1", "极限运动", DEFAULT_VECTOR_FONT_FILENAME, 30);
+ TraingModel::GetInstance()->InitLabel(title, 173, 52, 200, 60, "label1", "休闲运动", DEFAULT_VECTOR_FONT_FILENAME, 30);
scrollView->Add(title);
// UIList 的适配器
p_TraingRestListAdapter = new TraingRestAdapter();