-/***
- * @Author: Caisking 3449750381@qq.com
- * @Date: 2024-03-27 15:24:12
- * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-03-28 16:46:53
- * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_dance/include/TraingDanceItemView.h
- * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
- */
-/***
- * @Author: Caisking 3449750381@qq.com
- * @Date: 2024-03-27 15:24:12
- * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-03-28 16:42:47
- * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_dance/include/TraingDanceItemView.h
- * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
- */
+
#ifndef TraingDance_ITEM_VIEW_H
#define TraingDance_ITEM_VIEW_H
TraingDanceModel(const TraingDanceModel &);
TraingDanceModel &operator=(const TraingDanceModel &);
virtual ~TraingDanceModel();
- static const uint16_t TraingDanceListMaxNum = 10;
+ static const uint16_t TraingDanceListMaxNum = 12;
TraingDanceItem TraingDances[TraingDanceListMaxNum] = {VIEW_INVALID, STR_DANCING_GENERAL};
// std::map<int, AppViewId> TraingDanceIdToViewId;
bool btConnectStatus{false};
#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_dance/include/TraingDanceAdapter.h"
#include "traing/training_list_dance/include/TraingDanceModel.h"
-#include "components/ui_label_button_ext.h"
-#include "components/ui_label_ext.h"
-#include"ui_resource_string.h"
-
-namespace OHOS
-{
- class TraingDancePresenter;
- class TraingDanceModel;
- class TraingDanceView : public View<TraingDancePresenter>, public UIViewGroup
- {
-
- public:
- TraingDanceView();
- virtual ~TraingDanceView();
- static TraingDanceView *GetInstance(void);
-
- void OnStart() override;
- void OnSetUpView() override;
- void OnTearDownView() override;
- void OnStop() override;
-
- UIList *GetList();
- void AddToTraingDanceList(const TraingDanceItem &item);
-
- private:
- void InitView(void);
- void DeInitView(void);
- void PreLoad(void);
-
- private:
- UIScrollView *scrollView = nullptr;
- UILabelExt *title{nullptr};
- TraingDanceAdapter *p_TraingDanceListAdapter{nullptr};
- UIList *TraingDanceList = nullptr;
- UIView::OnDragListener *draglistener{nullptr};
-
- TraingDancePresenter *g_TraingDancePresenter{nullptr};
- TraingDanceModel *g_TraingDanceModel{nullptr};
- bool viewInitStatus{false};
- };
+#include "ui_resource_string.h"
+
+namespace OHOS {
+class TraingDancePresenter;
+class TraingDanceModel;
+class TraingDanceView : public View<TraingDancePresenter>, public UIViewGroup {
+
+public:
+ TraingDanceView();
+ virtual ~TraingDanceView();
+ static TraingDanceView *GetInstance(void);
+
+ void OnStart() override;
+ void OnSetUpView() override;
+ void OnTearDownView() override;
+ void OnStop() override;
+
+ UIList *GetList();
+ void AddToTraingDanceList(const TraingDanceItem &item);
+
+private:
+ void InitView(void);
+ void InitList();
+ void InitScrollView();
+ void DeInitView(void);
+ void PreLoad(void);
+ void SetKeyActListener(void);
+
+private:
+ UIScrollView *scrollView = nullptr;
+ TraingDanceAdapter *p_TraingDanceListAdapter{nullptr};
+ UIList *TraingDanceList = nullptr;
+ bool viewInitStatus{false};
+};
} // namespace OHOS
#endif
\ No newline at end of file
-/***
- * @Author: Caisking 3449750381@qq.com
- * @Date: 2024-03-27 15:25:02
- * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-03-29 11:45:56
- * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_dance/src/TraingDanceItemView.cpp
- * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
- */
-
#include "traing/training_list_dance/include/TraingDanceItemView.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
-{
-
- TraingDanceItemView::TraingDanceItemView()
- {
- 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);
- }
-
- TraingDanceItemView::~TraingDanceItemView()
- {
- Remove(&sbackground);
- Remove(&sicon);
- Remove(&sLabel);
- }
-
- /// @brief 设置item的信息
- /// @param itemInfo
- void TraingDanceItemView::SetItemInfo(const TraingDanceItem itemInfo)
- {
- sItemInfo = itemInfo;
- sLabel.SetTextId(itemInfo.labelid);
- }
-
- /// @brief 设置每一个itemview上的组件
- void TraingDanceItemView::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 TraingDanceItemView::GetTraingDanceIndex()
- {
- return sItemInfo.id;
- }
- UIResourceTextId TraingDanceItemView::GetTraingDanceId()
- {
- return sItemInfo.labelid;
- }
-}
\ No newline at end of file
+
+namespace OHOS {
+
+TraingDanceItemView::TraingDanceItemView() {
+ 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);
+}
+
+TraingDanceItemView::~TraingDanceItemView() {
+ Remove(&sbackground);
+ Remove(&sicon);
+ Remove(&sLabel);
+}
+
+/// @brief 设置item的信息
+/// @param itemInfo
+void TraingDanceItemView::SetItemInfo(const TraingDanceItem itemInfo) {
+ sItemInfo = itemInfo;
+
+ // 先设置所有视图的可见性
+ bool isVisible = false;
+ bool label_isVisible = false;
+ uint32_t color = Color::White().full;
+ SetTouchable(false); // 默认不触摸
+
+ switch (itemInfo.labelid) {
+ case STR_DANCING_TITLE:
+ 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_DANCING_LIST:
+ 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_DANCING_TITLE) {
+ sLabel.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ } else {
+ sLabel.SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);
+ }
+}
+
+/// @brief 设置每一个itemview上的组件
+void TraingDanceItemView::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 TraingDanceItemView::GetTraingDanceIndex() { return sItemInfo.id; }
+
+/// @brief 获取list中每个组件的运动Id
+/// @return 返回下标
+UIResourceTextId TraingDanceItemView::GetTraingDanceId() {
+ return sItemInfo.labelid;
+}
+
+} // namespace OHOS
\ No newline at end of file
-/***
- * @Author: Caisking 3449750381@qq.com
- * @Date: 2024-03-27 15:25:17
- * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-03-27 15:42:56
- * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_dance/src/TraingDanceModel.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 18:34:15
- * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-03-26 18:36:25
- * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_dance/src/TraingDanceModel.cpp
- * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
- */
+
#include "traing/training_list_dance/include/TraingDanceModel.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
-{
-
- TraingDanceModel::TraingDanceModel() {}
-
- TraingDanceModel::~TraingDanceModel() {}
-
- TraingDanceModel &TraingDanceModel::GetInstance()
- {
- static TraingDanceModel instance;
- return instance;
- }
-
- // static char *text[] = {"一般舞蹈", "肚皮舞", "爵士舞", "拉丁舞", "芭蕾", "街舞", "广场舞", "尊巴", "社交舞", "踢踏舞"};
-
- void TraingDanceModel::InitTraingDanceListItem()
- {
- TraingDances[0] = {VIEW_TRAININGNOMAL, STR_DANCING_GENERAL};
- TraingDances[1] = {VIEW_TRAININGNOMAL, STR_DANCING_BELLY};
- TraingDances[2] = {VIEW_TRAININGNOMAL, STR_DANCING_JAZZ};
- TraingDances[3] = {VIEW_TRAININGNOMAL, STR_DANCING_LATIN};
- TraingDances[4] = {VIEW_TRAININGNOMAL, STR_DANCING_BALLET};
- TraingDances[5] = {VIEW_TRAININGNOMAL, STR_DANCING_STREET};
- TraingDances[6] = {VIEW_TRAININGNOMAL, STR_DANCING_PUBLICSQUARE};
- TraingDances[7] = {VIEW_TRAININGNOMAL, STR_DANCING_ZUMBA};
- TraingDances[8] = {VIEW_TRAININGNOMAL, STR_DANCING_SOCIALDANCE};
- TraingDances[9] = {VIEW_TRAININGNOMAL, STR_DANCING_TAPDANCE};
- }
-
- const TraingDanceItem *TraingDanceModel::GetTraingDancelistItems() const
- {
- return TraingDances;
- }
- uint8_t TraingDanceModel::GetTraingDanceListNum() const
- {
- return TraingDanceListMaxNum;
- }
-
-}
\ No newline at end of file
+#include "ui_resource_string.h"
+namespace OHOS {
+
+TraingDanceModel::TraingDanceModel() {}
+
+TraingDanceModel::~TraingDanceModel() {}
+
+TraingDanceModel &TraingDanceModel::GetInstance() {
+ static TraingDanceModel instance;
+ return instance;
+}
+
+// static char *text[] = {"一般舞蹈", "肚皮舞", "爵士舞", "拉丁舞", "芭蕾",
+// "街舞", "广场舞", "尊巴", "社交舞", "踢踏舞"};
+
+void TraingDanceModel::InitTraingDanceListItem() {
+ int index = 0;
+
+ // 为 TraingDances 数组赋值
+ TraingDances[index++] = {VIEW_TRAININGNOMAL, STR_DANCING_TITLE}; // title
+ TraingDances[index++] = {VIEW_TRAININGNOMAL, STR_DANCING_GENERAL}; // general
+ TraingDances[index++] = {VIEW_TRAININGNOMAL, STR_DANCING_BELLY}; // belly
+ TraingDances[index++] = {VIEW_TRAININGNOMAL, STR_DANCING_JAZZ}; // jazz
+ TraingDances[index++] = {VIEW_TRAININGNOMAL, STR_DANCING_LATIN}; // latin
+ TraingDances[index++] = {VIEW_TRAININGNOMAL, STR_DANCING_BALLET}; // ballet
+ TraingDances[index++] = {VIEW_TRAININGNOMAL, STR_DANCING_STREET}; // street
+ TraingDances[index++] = {VIEW_TRAININGNOMAL,
+ STR_DANCING_PUBLICSQUARE}; // public square
+ TraingDances[index++] = {VIEW_TRAININGNOMAL, STR_DANCING_ZUMBA}; // zumba
+ TraingDances[index++] = {VIEW_TRAININGNOMAL,
+ STR_DANCING_SOCIALDANCE}; // social dance
+ TraingDances[index++] = {VIEW_TRAININGNOMAL,
+ STR_DANCING_TAPDANCE}; // tap dance
+ TraingDances[index] = {VIEW_TRAININGNOMAL, STR_DANCING_LIST}; // end
+}
+
+const TraingDanceItem *TraingDanceModel::GetTraingDancelistItems() const {
+ return TraingDances;
+}
+uint8_t TraingDanceModel::GetTraingDanceListNum() const {
+ return TraingDanceListMaxNum;
+}
+
+} // namespace OHOS
\ No newline at end of file
-#include "traing/training_list_dance/include/TraingDanceView.h"
-#include "traing/training_list_dance/include/TraingDancePresenter.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_dance/include/TraingDancePresenter.h"
+#include "traing/training_list_dance/include/TraingDanceView.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 TraingDanceView *g_pTraingDanceView{nullptr};
- /* --------------------------------- List --------------------------------- */
- static constexpr int16_t Dance_LIST_POSITION_X = 43;
- static constexpr int16_t Dance_LIST_POSITION_Y = 120;
- static constexpr int16_t Dance_SCROLLBLANKSIZE = 35; // 设置此滚动视图的空白大小。
- static constexpr int16 MAX_SCR_DIS = 1000;
- static constexpr int16 LIST_POS = 20;
- static constexpr int16 SNUM_2 = 2;
-
- TraingDanceView::TraingDanceView()
- {
- g_pTraingDanceView = this;
- }
+namespace OHOS {
+static TraingDanceView *g_pTraingDanceView{nullptr};
- TraingDanceView::~TraingDanceView()
- {
- if (viewInitStatus == true)
- {
- DeInitView();
- }
- g_pTraingDanceView = nullptr;
- }
+TraingDanceView::TraingDanceView() { g_pTraingDanceView = this; }
- TraingDanceView *TraingDanceView::GetInstance()
- {
- return g_pTraingDanceView;
- }
- /// @param item
- void TraingDanceView::AddToTraingDanceList(const TraingDanceItem &item)
- {
- p_TraingDanceListAdapter->AddItem(item);
- }
- static void SetKeyActListener()
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetKeyActListener");
- // 增加按键监听
- RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::TraingDancePresenter::GetInstance();
- RootView::GetInstance()->SetOnKeyActListener(keyactListener);
- }
- void TraingDanceView::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_DANCING_TITLE, DEFAULT_VECTOR_FONT_FILENAME, 30);
- title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full);
- scrollView->Add(title);
-
- title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full);
- scrollView->Add(title);
- }
- // UIList 的适配器
- if (p_TraingDanceListAdapter == nullptr)
- {
- p_TraingDanceListAdapter = new TraingDanceAdapter();
- p_TraingDanceListAdapter->SetItemClickListener(presenter_);
- }
- // 初始化列表
- if (TraingDanceList == nullptr)
- {
- TraingDanceList = new UIList();
- TraingDanceList->SetPosition(43, 120, 466, 466);
- TraingDanceList->SetThrowDrag(true);
- TraingDanceList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
- TraingDanceList->SetMaxScrollDistance(1000);
- TraingDanceList->SetSwipeACCLevel(800);
- TraingDanceList->SetDragACCLevel(5);
- // 增加表冠控制
- TraingDanceList->SetRotateFactor(2);
- TraingDanceList->RequestFocus();
- }
- }
- UIList *TraingDanceView::GetList()
- {
- return TraingDanceList;
- }
- void TraingDanceView::DeInitView()
- {
- // scrollView-> RemoveAll();
- RemoveAll();
- delete title;
- title = nullptr;
+TraingDanceView::~TraingDanceView() { g_pTraingDanceView = nullptr; }
- delete TraingDanceList;
- TraingDanceList = nullptr;
+TraingDanceView *TraingDanceView::GetInstance() { return g_pTraingDanceView; }
- delete scrollView;
- scrollView = nullptr;
+void TraingDanceView::AddToTraingDanceList(const TraingDanceItem &item) {
+ if (p_TraingDanceListAdapter) {
+ p_TraingDanceListAdapter->AddItem(item);
+ }
+}
- delete draglistener;
- draglistener = nullptr;
- }
+void TraingDanceView::SetKeyActListener() {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetKeyActListener");
+ auto keyActListener = static_cast<RootView::OnKeyActListener *>(
+ TraingDancePresenter::GetInstance());
+ RootView::GetInstance()->SetOnKeyActListener(keyActListener);
+}
- void TraingDanceView::PreLoad(void)
- {
- if (!viewInitStatus)
- {
- InitView();
- viewInitStatus = true;
- }
- }
+void TraingDanceView::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);
+}
- /// @brief 页面启动时需要执行的代码逻辑
- void TraingDanceView::OnStart()
- {
- View<TraingDancePresenter>::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_);
- }
+void TraingDanceView::InitList() {
+ if (p_TraingDanceListAdapter == nullptr) {
+ p_TraingDanceListAdapter = new TraingDanceAdapter();
+ }
+ p_TraingDanceListAdapter->SetItemClickListener(presenter_);
+
+ if (TraingDanceList == nullptr) {
+ TraingDanceList = new UIList();
+ }
+ TraingDanceList->SetPosition(43, 0, HORIZONTAL_RESOLUTION,
+ VERTICAL_RESOLUTION);
+ TraingDanceList->SetThrowDrag(true);
+ TraingDanceList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+ TraingDanceList->SetMaxScrollDistance(1000);
+ TraingDanceList->SetSwipeACCLevel(800);
+ TraingDanceList->SetDragACCLevel(5);
+ TraingDanceList->SetRotateFactor(1);
+ TraingDanceList->RequestFocus();
+}
+
+void TraingDanceView::InitView() {
+ InitScrollView();
+ InitList();
+ SetKeyActListener();
+}
- /// @brief 创建页面的视图。
- void TraingDanceView::OnSetUpView()
- {
- View<TraingDancePresenter>::OnSetUpView();
- if (TraingDanceList != nullptr && p_TraingDanceListAdapter != nullptr)
- {
- scrollView->Add(TraingDanceList);
- scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
- RootView::GetInstance()->Add(scrollView);
- TraingDanceList->SetAdapter(p_TraingDanceListAdapter);
+void TraingDanceView::DeInitView() {
+ if (viewInitStatus) {
+ if (container_) {
+ container_->RemoveAll();
+ if (scrollView) {
+ scrollView->RemoveAll();
+ if (p_TraingDanceListAdapter) {
+ delete p_TraingDanceListAdapter;
+ p_TraingDanceListAdapter = nullptr;
}
- Draw();
+ if (TraingDanceList) {
+ delete TraingDanceList;
+ TraingDanceList = nullptr;
+ }
+ delete scrollView;
+ scrollView = nullptr;
+ }
}
+ delete container_;
+ container_ = nullptr;
+ }
+}
- /// @brief 销毁页面的视图。
- void TraingDanceView::OnTearDownView()
- {
- View<TraingDancePresenter>::OnTearDownView();
- return;
- }
+void TraingDanceView::PreLoad() {
+ if (!viewInitStatus) {
+ InitView();
+ viewInitStatus = true;
+ }
+}
- /// @brief 页面结束时需要执行的销毁逻辑。
- void TraingDanceView::OnStop()
- {
- View<TraingDancePresenter>::OnStop();
+void TraingDanceView::OnStart() {
+ View<TraingDancePresenter>::OnStart();
+ SetContainerView(new UIViewGroup());
+ container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(),
+ Screen::GetInstance().GetHeight());
+ BaseView::RootView(Color::Black().full);
+ PreLoad();
+ SetContainerView(container_);
+}
- if (container_ != nullptr)
- {
- container_->RemoveAll();
- delete container_;
- container_ = nullptr;
- }
- RootView::GetInstance()->ClearOnKeyActListener();
- RootView::GetInstance()->RemoveAll();
- return;
+void TraingDanceView::OnSetUpView() {
+ View<TraingDancePresenter>::OnSetUpView();
+ if (scrollView && TraingDanceList) {
+ scrollView->Add(TraingDanceList);
+ scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+ container_->Add(scrollView);
+ if (p_TraingDanceListAdapter) {
+ TraingDanceList->SetAdapter(p_TraingDanceListAdapter);
}
-}
\ No newline at end of file
+ Draw();
+ }
+}
+
+void TraingDanceView::OnTearDownView() {
+ View<TraingDancePresenter>::OnTearDownView();
+}
+
+void TraingDanceView::OnStop() {
+ View<TraingDancePresenter>::OnStop();
+ RootView::GetInstance()->ClearOnKeyActListener();
+ DeInitView();
+ RootView::GetInstance()->RemoveAll();
+}
+} // namespace OHOS
\ No newline at end of file