训练:修改“冰上运动”列表
authorCaisking <3449750381@qq.com>
Sat, 5 Oct 2024 05:14:18 +0000 (13:14 +0800)
committerCaisking <3449750381@qq.com>
Sat, 5 Oct 2024 05:14:18 +0000 (13:14 +0800)
code/sdk/application/wearable/fd230app/nativeui/traing/training_list_ice/include/TraingIceModel.h
code/sdk/application/wearable/fd230app/nativeui/traing/training_list_ice/include/TraingIceView.h
code/sdk/application/wearable/fd230app/nativeui/traing/training_list_ice/src/TraingIceItemView.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/training_list_ice/src/TraingIceModel.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/training_list_ice/src/TraingIceView.cpp

index 492d677..7ce9b80 100644 (file)
@@ -29,7 +29,7 @@ namespace OHOS
         TraingIceModel(const TraingIceModel &);
         TraingIceModel &operator=(const TraingIceModel &);
         virtual ~TraingIceModel();
-        static const uint16_t TraingIceListMaxNum = 12;
+        static const uint16_t TraingIceListMaxNum = 14;
         TraingIceItem TraingIces[TraingIceListMaxNum] = {VIEW_INVALID, STR_ICE_SPORTS};
         // std::map<int, AppViewId> TraingIceIdToViewId;
         bool btConnectStatus{false};
index f217783..fe9f502 100644 (file)
@@ -4,50 +4,47 @@
 
 #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_ice/include/TraingIceAdapter.h"
 #include "traing/training_list_ice/include/TraingIceModel.h"
-#include "components/ui_label_button_ext.h"
-#include "components/ui_label_ext.h"
-#include"ui_resource_string.h"
-
-namespace OHOS
-{
-    class TraingIcePresenter;
-    class TraingIceModel;
-    class TraingIceView : public View<TraingIcePresenter>, public UIViewGroup
-    {
-
-    public:
-        TraingIceView();
-        virtual ~TraingIceView();
-        static TraingIceView *GetInstance(void);
-
-        void OnStart() override;
-        void OnSetUpView() override;
-        void OnTearDownView() override;
-        void OnStop() override;
-
-        UIList *GetList();
-        void AddToTraingIceList(const TraingIceItem &item);
-
-    private:
-        void InitView(void);
-        void DeInitView(void);
-        void PreLoad(void);
-
-    private:
-        UIScrollView *scrollView = nullptr;
-        UILabelExt *title{nullptr};
-        TraingIceAdapter *p_TraingIceListAdapter{nullptr};
-        UIList *TraingIceList = nullptr;
-        UIView::OnDragListener *draglistener{nullptr};
-
-        TraingIcePresenter *g_TraingIcePresenter{nullptr};
-        TraingIceModel *g_TraingIceModel{nullptr};
-        bool viewInitStatus{false};
-    };
+#include "ui_resource_string.h"
+
+namespace OHOS {
+class TraingIcePresenter;
+class TraingIceModel;
+class TraingIceView : public View<TraingIcePresenter>, public UIViewGroup {
+
+public:
+  TraingIceView();
+  virtual ~TraingIceView();
+  static TraingIceView *GetInstance(void);
+
+  void OnStart() override;
+  void OnSetUpView() override;
+  void OnTearDownView() override;
+  void OnStop() override;
+
+  UIList *GetList();
+  void AddToTraingIceList(const TraingIceItem &item);
+
+private:
+  void InitView(void);
+  void DeInitView(void);
+  void InitList();
+  void InitScrollView();
+  void SetKeyActListener(void);
+  void PreLoad(void);
+
+private:
+  UIScrollView *scrollView = nullptr;
+  TraingIceAdapter *p_TraingIceListAdapter{nullptr};
+  UIList *TraingIceList = nullptr;
+
+  bool viewInitStatus{false};
+};
 } // namespace OHOS
 #endif
\ No newline at end of file
index 1669f9f..af8e218 100644 (file)
-/***
- * @Author: Caisking 3449750381@qq.com
- * @Date: 2024-03-27 11:13:16
- * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-03-29 11:47:02
- * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_ice/src/TraingIceItemView.cpp
- * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
- */
-
 #include "traing/training_list_ice/include/TraingIceItemView.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
-{
-
-    TraingIceItemView::TraingIceItemView()
-    {
-        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);
-    }
-
-    TraingIceItemView::~TraingIceItemView()
-    {
-        Remove(&sbackground);
-        Remove(&sicon);
-        Remove(&sLabel);
-    }
-
-    /// @brief 设置item的信息
-    /// @param itemInfo
-    void TraingIceItemView::SetItemInfo(const TraingIceItem itemInfo)
-    {
-        sItemInfo = itemInfo;
-        sLabel.SetTextId(itemInfo.labelid);
-    }
-
-    /// @brief 设置每一个itemview上的组件
-    void TraingIceItemView::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 TraingIceItemView::GetTraingIceIndex()
-    {
-        return sItemInfo.id;
-    }
-
-    UIResourceTextId TraingIceItemView::GetTraingIceId()
-    {
-        return sItemInfo.labelid;
-    }
-}
\ No newline at end of file
+
+namespace OHOS {
+
+TraingIceItemView::TraingIceItemView() {
+  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);
+}
+
+TraingIceItemView::~TraingIceItemView() {
+  Remove(&sbackground);
+  Remove(&sicon);
+  Remove(&sLabel);
+}
+
+/// @brief 设置item的信息
+/// @param itemInfo
+void TraingIceItemView::SetItemInfo(const TraingIceItem itemInfo) {
+  sItemInfo = itemInfo;
+
+  // 先设置所有视图的可见性
+  bool isVisible = false;
+  bool label_isVisible = false;
+  uint32_t color = Color::White().full;
+  SetTouchable(false); // 默认不触摸
+
+  switch (itemInfo.labelid) {
+  case STR_ICE_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_ICE_LIST) {
+    sLabel.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+  } else {
+    sLabel.SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);
+  }
+}
+
+/// @brief 设置每一个itemview上的组件
+void TraingIceItemView::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 TraingIceItemView::GetTraingIceIndex() { return sItemInfo.id; }
+
+/// @brief 获取list中每个组件的运动Id
+/// @return 返回下标
+UIResourceTextId TraingIceItemView::GetTraingIceId() {
+  return sItemInfo.labelid;
+}
+
+} // namespace OHOS
\ No newline at end of file
index 5aed3fe..b2d16f8 100644 (file)
@@ -3,57 +3,62 @@
  * @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_ice/src/TraingIceModel.cpp
- * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ * @FilePath:
+ * /sdk/application/wearable/fd230app/nativeui/traing/training_list_ice/src/TraingIceModel.cpp
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置
+ * 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
 
 #include "traing/training_list_ice/include/TraingIceModel.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
-{
-
-    TraingIceModel::TraingIceModel() {}
-
-    TraingIceModel::~TraingIceModel() {}
-
-    TraingIceModel &TraingIceModel::GetInstance()
-    {
-        static TraingIceModel instance;
-        return instance;
-    }
-
-    static char *text[] = {"一般冰上运动", "溜冰", "冰球", "冰石壶/冰壶", "雪上摩托车", "雪橇", "冬季两项", "越野滑雪", "滑雪", "单板滑雪/滑雪板", "雪鞋健行", "雪地运动"};
-
-    void TraingIceModel::InitTraingIceListItem()
-    {
-        TraingIces[0] = {VIEW_TRAININGNOMAL, STR_ICE_SPORTS};
-        TraingIces[1] = {VIEW_TRAININGNOMAL, STR_ICE_SKATING};
-        TraingIces[2] = {VIEW_TRAININGNOMAL, STR_ICE_HOCKEY};
-        TraingIces[3] = {VIEW_TRAININGNOMAL, STR_ICE_CURLING};
-        TraingIces[4] = {VIEW_TRAININGNOMAL, STR_ICE_SNOWMOBILING};
-        TraingIces[5] = {VIEW_TRAININGNOMAL, STR_ICE_SLED};
-        TraingIces[6] = {VIEW_TRAININGNOMAL, STR_ICE_BIATHLON};
-        TraingIces[7] = {VIEW_TRAININGNOMAL, STR_ICE_CROSSCOUNTRYSKING};
-        TraingIces[8] = {VIEW_TRAININGNOMAL, STR_ICE_SKIING};
-        TraingIces[9] = {VIEW_TRAININGNOMAL, STR_ICE_SNOWBOARDING};
-        TraingIces[10] = {VIEW_TRAININGNOMAL, STR_ICE_SNOWSHOEING};
-        TraingIces[11] = {VIEW_TRAININGNOMAL, STR_ICE_SNOWSPORTS};
-    }
-
-    const TraingIceItem *TraingIceModel::GetTraingIcelistItems() const
-    {
-        return TraingIces;
-    }
-    uint8_t TraingIceModel::GetTraingIceListNum() const
-    {
-        return TraingIceListMaxNum;
-    }
-
-}
\ No newline at end of file
+namespace OHOS {
+
+TraingIceModel::TraingIceModel() {}
+
+TraingIceModel::~TraingIceModel() {}
+
+TraingIceModel &TraingIceModel::GetInstance() {
+  static TraingIceModel instance;
+  return instance;
+}
+// static char *text[] = {"一般冰上运动", "溜冰", "冰球", "冰石壶/冰壶",
+// "雪上摩托车", "雪橇", "冬季两项", "越野滑雪", "滑雪", "单板滑雪/滑雪板",
+// "雪鞋健行", "雪地运动"};
+
+// 使用一个数组来存储文本字符串
+UIResourceTextId iceSports[] = {STR_ICE_LIST,
+                                STR_ICE_SPORTS,
+                                STR_ICE_SKATING,
+                                STR_ICE_HOCKEY,
+                                STR_ICE_CURLING,
+                                STR_ICE_SNOWMOBILING,
+                                STR_ICE_SLED,
+                                STR_ICE_BIATHLON,
+                                STR_ICE_CROSSCOUNTRYSKING,
+                                STR_ICE_SKIING,
+                                STR_ICE_SNOWBOARDING,
+                                STR_ICE_SNOWSHOEING,
+                                STR_ICE_SNOWSPORTS,
+                                STR_MAX_ID};
+void TraingIceModel::InitTraingIceListItem() {
+
+  // 使用循环来初始化 TraingIces 数组
+  for (int index = 0; index < sizeof(iceSports) / sizeof(iceSports[0]);
+       ++index) {
+    TraingIces[index] = {VIEW_TRAININGNOMAL, iceSports[index]};
+  }
+}
+
+const TraingIceItem *TraingIceModel::GetTraingIcelistItems() const {
+  return TraingIces;
+}
+uint8_t TraingIceModel::GetTraingIceListNum() const {
+  return TraingIceListMaxNum;
+}
+
+} // namespace OHOS
\ No newline at end of file
index 15cdc48..ad820d3 100644 (file)
-/***
- * @Author: Caisking 3449750381@qq.com
- * @Date: 2024-03-26 09:46:17
- * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-03-29 12:06:57
- * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_ice/src/TraingIceView.cpp
- * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
- */
-#include "traing/training_list_ice/include/TraingIceView.h"
-#include "traing/training_list_ice/include/TraingIcePresenter.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_ice/include/TraingIcePresenter.h"
+#include "traing/training_list_ice/include/TraingIceView.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 TraingIceView *g_pTraingIceView{nullptr};
-    /* --------------------------------- List --------------------------------- */
-    static constexpr int16_t Ice_LIST_POSITION_X = 43;
-    static constexpr int16_t Ice_LIST_POSITION_Y = 120;
-    static constexpr int16_t Ice_SCROLLBLANKSIZE = 35; // 设置此滚动视图的空白大小。
-    static constexpr int16 MAX_SCR_DIS = 1000;
-    static constexpr int16 LIST_POS = 20;
-    static constexpr int16 SNUM_2 = 2;
-
-    TraingIceView::TraingIceView()
-    {
-        g_pTraingIceView = this;
-    }
+namespace OHOS {
+static TraingIceView *g_pTraingIceView{nullptr};
 
-    TraingIceView::~TraingIceView()
-    {
-        if (viewInitStatus == true)
-        {
-            DeInitView();
-        }
-        g_pTraingIceView = nullptr;
-    }
+TraingIceView::TraingIceView() { g_pTraingIceView = this; }
 
-    TraingIceView *TraingIceView::GetInstance()
-    {
-        return g_pTraingIceView;
-    }
-    /// @param item
-    void TraingIceView::AddToTraingIceList(const TraingIceItem &item)
-    {
-        p_TraingIceListAdapter->AddItem(item);
-    }
-    static void SetKeyActListener()
-    {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetKeyActListener");
-        // 增加按键监听
-        RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::TraingIcePresenter::GetInstance();
-        RootView::GetInstance()->SetOnKeyActListener(keyactListener);
-    }
-    void TraingIceView::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_ICE_LIST, DEFAULT_VECTOR_FONT_FILENAME, 30);
-            title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full);
-            scrollView->Add(title);
-        }
-        // UIList 的适配器
-        if (p_TraingIceListAdapter == nullptr)
-        {
-            p_TraingIceListAdapter = new TraingIceAdapter();
-            p_TraingIceListAdapter->SetItemClickListener(presenter_);
-        }
-        // 初始化列表
-        if (TraingIceList == nullptr)
-        {
-            TraingIceList = new UIList();
-            TraingIceList->SetPosition(43, 120, 466, 466);
-            TraingIceList->SetThrowDrag(true);
-            TraingIceList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
-            TraingIceList->SetMaxScrollDistance(1000);
-            TraingIceList->SetSwipeACCLevel(800);
-            TraingIceList->SetDragACCLevel(5);
-            // 增加表冠控制
-            TraingIceList->SetRotateFactor(2);
-            TraingIceList->RequestFocus();
-        }
-    }
-    UIList *TraingIceView::GetList()
-    {
-        return TraingIceList;
-    }
-    void TraingIceView::DeInitView()
-    {
-        scrollView->RemoveAll();
-        // RemoveAll();
-        delete title;
-        title = nullptr;
+TraingIceView::~TraingIceView() { g_pTraingIceView = nullptr; }
 
-        delete TraingIceList;
-        TraingIceList = nullptr;
+TraingIceView *TraingIceView::GetInstance() {
+  return g_pTraingIceView;
+}
 
-        delete scrollView;
-        scrollView = nullptr;
+void TraingIceView::AddToTraingIceList(const TraingIceItem &item) {
+  if (p_TraingIceListAdapter) {
+    p_TraingIceListAdapter->AddItem(item);
+  }
+}
 
-        delete draglistener;
-        draglistener = nullptr;
-    }
+void TraingIceView::SetKeyActListener() {
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetKeyActListener");
+  auto keyActListener = static_cast<RootView::OnKeyActListener *>(
+      TraingIcePresenter::GetInstance());
+  RootView::GetInstance()->SetOnKeyActListener(keyActListener);
+}
 
-    void TraingIceView::PreLoad(void)
-    {
-        if (!viewInitStatus)
-        {
-            InitView();
-            viewInitStatus = true;
-        }
-    }
+void TraingIceView::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 TraingIceView::OnStart()
-    {
-        View<TraingIcePresenter>::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 TraingIceView::InitList() {
+  if (p_TraingIceListAdapter == nullptr) {
+    p_TraingIceListAdapter = new TraingIceAdapter();
+  }
+  p_TraingIceListAdapter->SetItemClickListener(presenter_);
+
+  if (TraingIceList == nullptr) {
+    TraingIceList = new UIList();
+  }
+  TraingIceList->SetPosition(43, 0, HORIZONTAL_RESOLUTION,
+                                 VERTICAL_RESOLUTION);
+  TraingIceList->SetThrowDrag(true);
+  TraingIceList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+  TraingIceList->SetMaxScrollDistance(1000);
+  TraingIceList->SetSwipeACCLevel(800);
+  TraingIceList->SetDragACCLevel(5);
+  TraingIceList->SetRotateFactor(1);
+  TraingIceList->RequestFocus();
+}
 
-    /// @brief 创建页面的视图。
-    void TraingIceView::OnSetUpView()
-    {
-        View<TraingIcePresenter>::OnSetUpView();
-        if (TraingIceList != nullptr && p_TraingIceListAdapter != nullptr)
-        {
-            scrollView->Add(TraingIceList);
-            scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
-            RootView::GetInstance()->Add(scrollView);
-            TraingIceList->SetAdapter(p_TraingIceListAdapter);
+void TraingIceView::InitView() {
+  InitScrollView();
+  InitList();
+  SetKeyActListener();
+}
+
+void TraingIceView::DeInitView() {
+  if (viewInitStatus) {
+    if (container_) {
+      container_->RemoveAll();
+      if (scrollView) {
+        scrollView->RemoveAll();
+        if (p_TraingIceListAdapter) {
+          delete p_TraingIceListAdapter;
+          p_TraingIceListAdapter = nullptr;
+        }
+        if (TraingIceList) {
+          delete TraingIceList;
+          TraingIceList = nullptr;
         }
-        Draw();
+        delete scrollView;
+        scrollView = nullptr;
+      }
     }
+    delete container_;
+    container_ = nullptr;
+  }
+}
 
-    /// @brief 销毁页面的视图。
-    void TraingIceView::OnTearDownView()
-    {
-        View<TraingIcePresenter>::OnTearDownView();
-        return;
-    }
+void TraingIceView::PreLoad() {
+  if (!viewInitStatus) {
+    InitView();
+    viewInitStatus = true;
+  }
+}
 
-    /// @brief 页面结束时需要执行的销毁逻辑。
-    void TraingIceView::OnStop()
-    {
-        View<TraingIcePresenter>::OnStop();
-        if (container_ != nullptr)
-        {
-            container_->RemoveAll();
-            delete container_;
-            container_ = nullptr;
-        }
-        RootView::GetInstance()->ClearOnKeyActListener();
-        RootView::GetInstance()->RemoveAll();
-        return;
+void TraingIceView::OnStart() {
+  View<TraingIcePresenter>::OnStart();
+  SetContainerView(new UIViewGroup());
+  container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(),
+                          Screen::GetInstance().GetHeight());
+  BaseView::RootView(Color::Black().full);
+  PreLoad();
+  SetContainerView(container_);
+}
+
+void TraingIceView::OnSetUpView() {
+  View<TraingIcePresenter>::OnSetUpView();
+  if (scrollView && TraingIceList) {
+    scrollView->Add(TraingIceList);
+    scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+    container_->Add(scrollView);
+    if (p_TraingIceListAdapter) {
+      TraingIceList->SetAdapter(p_TraingIceListAdapter);
     }
-}
\ No newline at end of file
+    Draw();
+  }
+}
+
+void TraingIceView::OnTearDownView() {
+  View<TraingIcePresenter>::OnTearDownView();
+}
+
+void TraingIceView::OnStop() {
+  View<TraingIcePresenter>::OnStop();
+  RootView::GetInstance()->ClearOnKeyActListener();
+  DeInitView();
+  RootView::GetInstance()->RemoveAll();
+}
+} // namespace OHOS
\ No newline at end of file