TraingRestModel(const TraingRestModel &);
TraingRestModel &operator=(const TraingRestModel &);
virtual ~TraingRestModel();
- static const uint16_t TraingRestListMaxNum = 24;
+ static const uint16_t TraingRestListMaxNum = 26;
TraingRestItem TraingRests[TraingRestListMaxNum] = {VIEW_INVALID, STR_EXERCISE_GENERAL};
// std::map<int, AppViewId> TraingRestIdToViewId;
bool btConnectStatus{false};
-/***
+/***
* @Author: Caisking 3449750381@qq.com
* @Date: 2024-03-19 17:37:18
* @LastEditors: Caisking 3449750381@qq.com
* @LastEditTime: 2024-03-29 15:55:33
- * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_rest/include/TraingRestView.h
- * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ * @FilePath:
+ * /sdk/application/wearable/fd230app/nativeui/traing/training_list_rest/include/TraingRestView.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置
+ * 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
#ifndef TraingRest_VIEW_H
#include "BaseView.h"
#include "View.h"
-#include "components/ui_view_group.h"
-#include "components/ui_scroll_view.h"
+#include "components/ui_label_button_ext.h"
+#include "components/ui_label_ext.h"
#include "components/ui_list.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_view_group.h"
#include "traing/training_list_rest/include/TraingRestAdapter.h"
#include "traing/training_list_rest/include/TraingRestModel.h"
-#include "components/ui_label_button_ext.h"
-#include "components/ui_label_ext.h"
-#include"ui_resource_string.h"
-
-namespace OHOS
-{
- class TraingRestPresenter;
- class TraingRestModel;
- class TraingRestView : public View<TraingRestPresenter>, public UIViewGroup
- {
-
- public:
- TraingRestView();
- virtual ~TraingRestView();
- static TraingRestView *GetInstance(void);
-
- void OnStart() override;
- void OnSetUpView() override;
- void OnTearDownView() override;
- void OnStop() override;
-
- UIList *GetList();
- void AddToTraingRestList(const TraingRestItem &item);
-
- private:
- void InitView(void);
- void DeInitView(void);
- void PreLoad(void);
-
- private:
- UIScrollView *scrollView = nullptr;
- UILabelExt *title{nullptr};
- TraingRestAdapter *p_TraingRestListAdapter{nullptr};
- UIList *TraingRestList = nullptr;
- UIView::OnDragListener *draglistener{nullptr};
-
- TraingRestPresenter *g_TraingRestPresenter{nullptr};
- TraingRestModel *g_TraingRestModel{nullptr};
- bool viewInitStatus{false};
- };
+#include "ui_resource_string.h"
+
+namespace OHOS {
+class TraingRestPresenter;
+class TraingRestModel;
+class TraingRestView : public View<TraingRestPresenter>, public UIViewGroup {
+
+public:
+ TraingRestView();
+ virtual ~TraingRestView();
+ static TraingRestView *GetInstance(void);
+
+ void OnStart() override;
+ void OnSetUpView() override;
+ void OnTearDownView() override;
+ void OnStop() override;
+
+ UIList *GetList();
+ void AddToTraingRestList(const TraingRestItem &item);
+
+private:
+ void InitView(void);
+ void DeInitView(void);
+ void InitList();
+ void InitScrollView();
+ void SetKeyActListener(void);
+ void PreLoad(void);
+
+private:
+ UIScrollView *scrollView = nullptr;
+ TraingRestAdapter *p_TraingRestListAdapter{nullptr};
+ UIList *TraingRestList = nullptr;
+ bool viewInitStatus{false};
+};
} // namespace OHOS
#endif
\ No newline at end of file
-/***
- * @Date: 2024-04-15 10:55:58
- * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-09-07 11:27:11
- * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_rest/src/TraingRestItemView.cpp
- */
-/***
- * @Author: Caisking 3449750381@qq.com
- * @Date: 2024-03-29 15:19:06
- * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-09-07 11:24:37
- * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_rest/src/TraingRestItemView.cpp
- * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
- */
-/***
- * @Author: Caisking 3449750381@qq.com
- * @Date: 2024-03-26 17:05:30
- * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-03-29 11:18:05
- * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_rest/src/TraingRestItemView.cpp
- * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%A
- */
-
#include "traing/training_list_rest/include/TraingRestItemView.h"
+#include "UiConfig.h"
+#include "traing/Training_UiConfig.h"
#include "traing/include/TraingModel.h"
#include "uicomponents/UIComponents.h"
-#include "traing/Training_UiConfig.h"
-#include "components/ui_label_ext.h"
-#include "ui_resource_string.h"
-#include "UiConfig.h"
-namespace OHOS
-{
-
- TraingRestItemView::TraingRestItemView()
- {
- 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);
- }
-
- TraingRestItemView::~TraingRestItemView()
- {
- Remove(&sbackground);
- Remove(&sicon);
- Remove(&sLabel);
- }
-
- /// @brief 设置item的信息
- /// @param itemInfo
- void TraingRestItemView::SetItemInfo(const TraingRestItem itemInfo)
- {
- sItemInfo = itemInfo;
- sLabel.SetTextId(itemInfo.labelid);
- }
-
- /// @brief 设置每一个itemview上的组件
- void TraingRestItemView::SetUpChild()
- {
- sbackground.SetSrc(PNG_SETTING_BACKGROUND_IMAGE);
-
- sicon.SetPosition(330, 40);
- sicon.SetSrc(ICON_IMAGE);
- sicon.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE);
-
- sLabel.SetPosition(40, 33, 240, 35);
- sLabel.SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
- sLabel.SetRollSpeed(70);
-//sLabel.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
-
- sLabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
- }
-
- /// @brief 获取list的中每个组件的在list的下标
- /// @return 返回下标
- AppViewId TraingRestItemView::GetTraingRestIndex()
- {
- return sItemInfo.id;
- }
- UIResourceTextId TraingRestItemView::GetTraingRestId()
- {
- return sItemInfo.labelid;
- }
-}
\ No newline at end of file
+
+namespace OHOS {
+
+TraingRestItemView::TraingRestItemView() {
+ 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);
+}
+
+TraingRestItemView::~TraingRestItemView() {
+ Remove(&sbackground);
+ Remove(&sicon);
+ Remove(&sLabel);
+}
+
+/// @brief 设置item的信息
+/// @param itemInfo
+void TraingRestItemView::SetItemInfo(const TraingRestItem itemInfo) {
+ sItemInfo = itemInfo;
+
+ // 先设置所有视图的可见性
+ bool isVisible = false;
+ bool label_isVisible = false;
+ uint32_t color = Color::White().full;
+ SetTouchable(false); // 默认不触摸
+
+ switch (itemInfo.labelid) {
+ case STR_RECREATIONAL_LIST:
+ sLabel.SetTextId(itemInfo.labelid);
+ sLabel.SetPosition(90, 50, 200, 35);
+ isVisible = false;
+ label_isVisible = true; // 只有label可见
+ color = Color::Green().full; // 设置label为绿色
+ SetHeight(120);
+ break;
+
+ case STR_MAX_ID:
+ isVisible = false; // 全部不可见
+ label_isVisible = false;
+ SetHeight(60);
+ break;
+
+ default:
+ sLabel.SetTextId(itemInfo.labelid);
+ sLabel.SetPosition(40, 33, 240, 35);
+ isVisible = true; // 所有元素可见
+ label_isVisible = true;
+ SetHeight(120);
+ SetTouchable(true);
+ break;
+ }
+
+ // 设置各个组件的可见性
+ sLabel.SetVisible(label_isVisible);
+ sicon.SetVisible(isVisible);
+ sbackground.SetVisible(isVisible);
+ sLabel.SetStyle(STYLE_TEXT_COLOR, color);
+
+ // 调整对齐方式
+ if (itemInfo.labelid == STR_RECREATIONAL_LIST) {
+ sLabel.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ } else {
+ sLabel.SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);
+ }
+}
+
+/// @brief 设置每一个itemview上的组件
+void TraingRestItemView::SetUpChild() {
+ sbackground.SetSrc(PNG_SETTING_BACKGROUND_IMAGE);
+
+ sicon.SetPosition(330, 40);
+ sicon.SetSrc(ICON_IMAGE);
+ sicon.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE);
+
+ sLabel.SetPosition(40, 33, 240, 35);
+ sLabel.SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
+ sLabel.SetRollSpeed(70);
+ sLabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+}
+
+/// @brief 获取list中每个组件的下标
+/// @return 返回下标
+AppViewId TraingRestItemView::GetTraingRestIndex() { return sItemInfo.id; }
+
+/// @brief 获取list中每个组件的运动Id
+/// @return 返回下标
+UIResourceTextId TraingRestItemView::GetTraingRestId() {
+ return sItemInfo.labelid;
+}
+
+} // namespace OHOS
\ No newline at end of file
* @Date: 2024-04-15 10:55:58
* @LastEditors: Caisking 3449750381@qq.com
* @LastEditTime: 2024-09-06 19:00:18
- * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_rest/src/TraingRestModel.cpp
+ * @FilePath:
+ * /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_rest/src/TraingRestModel.cpp
*/
#include "traing/training_list_rest/include/TraingRestModel.h"
+#include "AppViewIDs.h"
+#include "UiConfig.h"
#include "common/image_cache_manager.h"
#include "components/ui_label_ext.h"
-#include "ui_resource_string.h"
-#include "UiConfig.h"
#include "ui_resource_image.h"
-#include "AppViewIDs.h"
-#include "components/ui_label_ext.h"
#include "ui_resource_string.h"
-namespace OHOS
-{
+namespace OHOS {
- TraingRestModel::TraingRestModel() {}
+TraingRestModel::TraingRestModel() {}
- TraingRestModel::~TraingRestModel() {}
+TraingRestModel::~TraingRestModel() {}
- TraingRestModel &TraingRestModel::GetInstance()
- {
- static TraingRestModel instance;
- return instance;
- }
+TraingRestModel &TraingRestModel::GetInstance() {
+ static TraingRestModel instance;
+ return instance;
+}
- void TraingRestModel::InitTraingRestListItem()
- {
- TraingRestItem defaultItems[] = {
- {VIEW_TRAININGNOMAL, STR_RECREATIONAL_SPORTS},
- {VIEW_TRAININGNOMAL, STR_RECREATIONAL_SKATING},
- {VIEW_TRAININGNOMAL, STR_RECREATIONAL_MARTIALARTS},
- {VIEW_TRAININGNOMAL, STR_RECREATIONAL_TAICHI},
- {VIEW_TRAININGNOMAL, STR_RECREATIONAL_HULAHOOP},
- {VIEW_TRAININGNOMAL, STR_RECREATIONAL_DISCSPORT},
- {VIEW_TRAININGNOMAL, STR_RECREATIONAL_DARTS},
- {VIEW_TRAININGNOMAL, STR_RECREATIONAL_ARCHERY},
- {VIEW_TRAININGNOMAL, STR_RECREATIONAL_HORSERIDING},
- {VIEW_TRAININGNOMAL, STR_RECREATIONAL_BATTLEGAME},
- {VIEW_TRAININGNOMAL, STR_RECREATIONAL_KITE},
- {VIEW_TRAININGNOMAL, STR_RECREATIONAL_TUGOFWAR},
- {VIEW_TRAININGNOMAL, STR_RECREATIONAL_SWING},
- {VIEW_TRAININGNOMAL, STR_RECREATIONAL_STAIRCLIMBING},
- {VIEW_TRAININGNOMAL, STR_RECREATIONAL_OBSTACLERACE},
- {VIEW_TRAININGNOMAL, STR_RECREATIONAL_FISHING},
- {VIEW_TRAININGNOMAL, STR_RECREATIONAL_HUNTING},
- {VIEW_TRAININGNOMAL, STR_RECREATIONAL_SCOOTERRIDING},
- {VIEW_TRAININGNOMAL, STR_RECREATIONAL_PARAGLIDING},
- {VIEW_TRAININGNOMAL, STR_RECREATIONAL_TEAMSPORTS},
- {VIEW_TRAININGNOMAL, STR_RECREATIONAL_FINESSGAMING},
- {VIEW_TRAININGNOMAL, STR_RECREATIONAL_HIKING},
- {VIEW_TRAININGNOMAL, STR_RECREATIONAL_EQUESTRIANSPORTS},
- {VIEW_TRAININGNOMAL, STR_RECREATIONAL_PLAY}};
+void TraingRestModel::InitTraingRestListItem() {
+ TraingRestItem defaultItems[] = {
+ {VIEW_TRAININGNOMAL, STR_RECREATIONAL_LIST},
+ {VIEW_TRAININGNOMAL, STR_RECREATIONAL_SPORTS},
+ {VIEW_TRAININGNOMAL, STR_RECREATIONAL_SKATING},
+ {VIEW_TRAININGNOMAL, STR_RECREATIONAL_MARTIALARTS},
+ {VIEW_TRAININGNOMAL, STR_RECREATIONAL_TAICHI},
+ {VIEW_TRAININGNOMAL, STR_RECREATIONAL_HULAHOOP},
+ {VIEW_TRAININGNOMAL, STR_RECREATIONAL_DISCSPORT},
+ {VIEW_TRAININGNOMAL, STR_RECREATIONAL_DARTS},
+ {VIEW_TRAININGNOMAL, STR_RECREATIONAL_ARCHERY},
+ {VIEW_TRAININGNOMAL, STR_RECREATIONAL_HORSERIDING},
+ {VIEW_TRAININGNOMAL, STR_RECREATIONAL_BATTLEGAME},
+ {VIEW_TRAININGNOMAL, STR_RECREATIONAL_KITE},
+ {VIEW_TRAININGNOMAL, STR_RECREATIONAL_TUGOFWAR},
+ {VIEW_TRAININGNOMAL, STR_RECREATIONAL_SWING},
+ {VIEW_TRAININGNOMAL, STR_RECREATIONAL_STAIRCLIMBING},
+ {VIEW_TRAININGNOMAL, STR_RECREATIONAL_OBSTACLERACE},
+ {VIEW_TRAININGNOMAL, STR_RECREATIONAL_FISHING},
+ {VIEW_TRAININGNOMAL, STR_RECREATIONAL_HUNTING},
+ {VIEW_TRAININGNOMAL, STR_RECREATIONAL_SCOOTERRIDING},
+ {VIEW_TRAININGNOMAL, STR_RECREATIONAL_PARAGLIDING},
+ {VIEW_TRAININGNOMAL, STR_RECREATIONAL_TEAMSPORTS},
+ {VIEW_TRAININGNOMAL, STR_RECREATIONAL_FINESSGAMING},
+ {VIEW_TRAININGNOMAL, STR_RECREATIONAL_HIKING},
+ {VIEW_TRAININGNOMAL, STR_RECREATIONAL_EQUESTRIANSPORTS},
+ {VIEW_TRAININGNOMAL, STR_RECREATIONAL_PLAY},
+ {VIEW_TRAININGNOMAL, STR_MAX_ID},
+ };
- for (int i = 0; i < TraingRestListMaxNum; i++)
- {
- TraingRests[i] = defaultItems[i];
- }
- }
+ for (int i = 0; i < TraingRestListMaxNum; i++) {
+ TraingRests[i] = defaultItems[i];
+ }
+}
- const TraingRestItem *TraingRestModel::GetTraingRestlistItems() const
- {
- return TraingRests;
- }
- uint8_t TraingRestModel::GetTraingRestListNum() const
- {
- return TraingRestListMaxNum;
- }
+const TraingRestItem *TraingRestModel::GetTraingRestlistItems() const {
+ return TraingRests;
+}
+uint8_t TraingRestModel::GetTraingRestListNum() const {
+ return TraingRestListMaxNum;
+}
-}
\ No newline at end of file
+} // namespace OHOS
\ No newline at end of file
-#include "traing/training_list_rest/include/TraingRestView.h"
-#include "traing/training_list_rest/include/TraingRestPresenter.h"
-#include "traing/include/TraingModel.h"
-#include "uicomponents/UIComponents.h"
-#include "traing/Training_UiConfig.h"
-
+#include "UiConfig.h"
#include "components/ui_label_ext.h"
+#include "traing/Training_UiConfig.h"
+#include "traing/include/TraingModel.h"
+#include "traing/training_list_rest/include/TraingRestPresenter.h"
+#include "traing/training_list_rest/include/TraingRestView.h"
#include "ui_resource_string.h"
-#include "UiConfig.h"
+#include "uicomponents/UIComponents.h"
#include "wearable_log.h"
+#include <memory>
-namespace OHOS
-{
- static constexpr uint8_t NUM_2 = 2;
- static TraingRestView *g_pTraingRestView{nullptr};
- /* --------------------------------- List --------------------------------- */
- static constexpr int16_t Rest_LIST_POSITION_X = 43;
- static constexpr int16_t Rest_LIST_POSITION_Y = 120;
- static constexpr int16_t Rest_SCROLLBLANKSIZE = 35; // 设置此滚动视图的空白大小。
- static constexpr int16 MAX_SCR_DIS = 1000;
- static constexpr int16 LIST_POS = 20;
- static constexpr int16 SNUM_2 = 2;
-
- TraingRestView::TraingRestView()
- {
- g_pTraingRestView = this;
- }
+namespace OHOS {
+static TraingRestView *g_pTraingRestView{nullptr};
- TraingRestView::~TraingRestView()
- {
- if (viewInitStatus == true)
- {
- DeInitView();
- }
- g_pTraingRestView = nullptr;
- }
+TraingRestView::TraingRestView() { g_pTraingRestView = this; }
- TraingRestView *TraingRestView::GetInstance()
- {
- return g_pTraingRestView;
- }
- /// @param item
- void TraingRestView::AddToTraingRestList(const TraingRestItem &item)
- {
- p_TraingRestListAdapter->AddItem(item);
- }
+TraingRestView::~TraingRestView() { g_pTraingRestView = nullptr; }
- static void SetKeyActListener()
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetKeyActListener");
- // 增加按键监听
- RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::TraingRestPresenter::GetInstance();
- RootView::GetInstance()->SetOnKeyActListener(keyactListener);
- }
- void TraingRestView::InitView()
- {
- if (scrollView == nullptr)
- {
- scrollView = new UIScrollView();
- if (scrollView == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "scrollView new fail!");
- return;
- }
- scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
- scrollView->SetScrollBlankSize(50);
- // scrollView->SetReboundSize(35);
- scrollView->SetHorizontalScrollState(false);
- scrollView->RequestFocus();
- scrollView->SetRotateFactor(1.0);
- scrollView->SetMaxScrollDistance(1000);
- scrollView->SetDragACCLevel(5);
- scrollView->SetSwipeACCLevel(800); /*设置手指抬起屏幕后的补偿距离。*/
- scrollView->SetTouchable(true);
- scrollView->SetDraggable(true);
- container_->Add(scrollView);
- }
- /* -------------------------------------------------------------------------- */
- // 初始化Lable 暂时不添加
- if (title == nullptr)
- {
- InitLabelExt(title, 135, 52, 200, 60, "label1", STR_RECREATIONAL_LIST, DEFAULT_VECTOR_FONT_FILENAME, 30);
- title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full);
- scrollView->Add(title);
- }
- // UIList 的适配器
- if (p_TraingRestListAdapter == nullptr)
- {
- p_TraingRestListAdapter = new TraingRestAdapter();
- p_TraingRestListAdapter->SetItemClickListener(presenter_);
- }
- // 初始化列表
- if (TraingRestList == nullptr)
- {
- TraingRestList = new UIList();
- TraingRestList->SetPosition(43, 120, 466, 466);
- TraingRestList->SetThrowDrag(true);
- TraingRestList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
- TraingRestList->SetMaxScrollDistance(1000);
- TraingRestList->SetSwipeACCLevel(800);
- TraingRestList->SetDragACCLevel(5);
- // 增加表冠控制
- TraingRestList->SetRotateFactor(2);
- TraingRestList->RequestFocus();
- }
- }
- UIList *TraingRestView::GetList()
- {
- return TraingRestList;
- }
- void TraingRestView::DeInitView()
- {
- scrollView->RemoveAll();
- // RemoveAll();
- delete title;
- title = nullptr;
+TraingRestView *TraingRestView::GetInstance() {
+ return g_pTraingRestView;
+}
- delete TraingRestList;
- TraingRestList = nullptr;
+void TraingRestView::AddToTraingRestList(const TraingRestItem &item) {
+ if (p_TraingRestListAdapter) {
+ p_TraingRestListAdapter->AddItem(item);
+ }
+}
- delete scrollView;
- scrollView = nullptr;
+void TraingRestView::SetKeyActListener() {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetKeyActListener");
+ auto keyActListener = static_cast<RootView::OnKeyActListener *>(
+ TraingRestPresenter::GetInstance());
+ RootView::GetInstance()->SetOnKeyActListener(keyActListener);
+}
- delete draglistener;
- draglistener = nullptr;
- }
+void TraingRestView::InitScrollView() {
+ if (scrollView == nullptr) {
+ scrollView = new UIScrollView();
+ }
+ scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(),
+ Screen::GetInstance().GetHeight());
+ scrollView->SetTouchable(true);
+ scrollView->SetDraggable(true);
+ scrollView->SetDirection(1);
+ scrollView->SetHorizontalScrollState(false);
+ scrollView->SetOnDragListener(presenter_);
+ scrollView->SetYScrollBarVisible(true);
+}
- void TraingRestView::PreLoad(void)
- {
- if (!viewInitStatus)
- {
- InitView();
- viewInitStatus = true;
- }
- }
+void TraingRestView::InitList() {
+ if (p_TraingRestListAdapter == nullptr) {
+ p_TraingRestListAdapter = new TraingRestAdapter();
+ }
+ p_TraingRestListAdapter->SetItemClickListener(presenter_);
- /// @brief 页面启动时需要执行的代码逻辑
- void TraingRestView::OnStart()
- {
- View<TraingRestPresenter>::OnStart();
- BaseView::RootView(Color::Black().full);
- SetContainerView(new UIViewGroup());
- container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
- container_->SetOnDragListener(presenter_);
- container_->SetTouchable(true);
- container_->SetDraggable(true);
- PreLoad();
- RootView::GetInstance()->SetOnKeyActListener(presenter_);
- }
+ if (TraingRestList == nullptr) {
+ TraingRestList = new UIList();
+ }
+ TraingRestList->SetPosition(43, 0, HORIZONTAL_RESOLUTION,
+ VERTICAL_RESOLUTION);
+ TraingRestList->SetThrowDrag(true);
+ TraingRestList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+ TraingRestList->SetMaxScrollDistance(1000);
+ TraingRestList->SetSwipeACCLevel(800);
+ TraingRestList->SetDragACCLevel(5);
+ TraingRestList->SetRotateFactor(1);
+ TraingRestList->RequestFocus();
+}
- /// @brief 创建页面的视图。
- void TraingRestView::OnSetUpView()
- {
- View<TraingRestPresenter>::OnSetUpView();
- if (TraingRestList != nullptr && p_TraingRestListAdapter != nullptr)
- {
- scrollView->Add(TraingRestList);
- scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
- RootView::GetInstance()->Add(scrollView);
- TraingRestList->SetAdapter(p_TraingRestListAdapter);
+void TraingRestView::InitView() {
+ InitScrollView();
+ InitList();
+ SetKeyActListener();
+}
+
+void TraingRestView::DeInitView() {
+ if (viewInitStatus) {
+ if (container_) {
+ container_->RemoveAll();
+ if (scrollView) {
+ scrollView->RemoveAll();
+ if (p_TraingRestListAdapter) {
+ delete p_TraingRestListAdapter;
+ p_TraingRestListAdapter = nullptr;
+ }
+ if (TraingRestList) {
+ delete TraingRestList;
+ TraingRestList = nullptr;
}
- Draw();
+ delete scrollView;
+ scrollView = nullptr;
+ }
}
+ delete container_;
+ container_ = nullptr;
+ }
+}
- /// @brief 销毁页面的视图。
- void TraingRestView::OnTearDownView()
- {
- View<TraingRestPresenter>::OnTearDownView();
- return;
- }
+void TraingRestView::PreLoad() {
+ if (!viewInitStatus) {
+ InitView();
+ viewInitStatus = true;
+ }
+}
- /// @brief 页面结束时需要执行的销毁逻辑。
- void TraingRestView::OnStop()
- {
- View<TraingRestPresenter>::OnStop();
- if (container_ != nullptr)
- {
- container_->RemoveAll();
- delete container_;
- container_ = nullptr;
- }
- RootView::GetInstance()->ClearOnKeyActListener();
- RootView::GetInstance()->RemoveAll();
- return;
+void TraingRestView::OnStart() {
+ View<TraingRestPresenter>::OnStart();
+ SetContainerView(new UIViewGroup());
+ container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(),
+ Screen::GetInstance().GetHeight());
+ BaseView::RootView(Color::Black().full);
+ PreLoad();
+ SetContainerView(container_);
+}
+
+void TraingRestView::OnSetUpView() {
+ View<TraingRestPresenter>::OnSetUpView();
+ if (scrollView && TraingRestList) {
+ scrollView->Add(TraingRestList);
+ scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+ container_->Add(scrollView);
+ if (p_TraingRestListAdapter) {
+ TraingRestList->SetAdapter(p_TraingRestListAdapter);
}
-}
\ No newline at end of file
+ Draw();
+ }
+}
+
+void TraingRestView::OnTearDownView() {
+ View<TraingRestPresenter>::OnTearDownView();
+}
+
+void TraingRestView::OnStop() {
+ View<TraingRestPresenter>::OnStop();
+ RootView::GetInstance()->ClearOnKeyActListener();
+ DeInitView();
+ RootView::GetInstance()->RemoveAll();
+}
+} // namespace OHOS
\ No newline at end of file