Merge #908 into sdk602patch0626 from refs/changes/908/head 903/target/2
author袁清梦 <3449750381@qq.com>
Sat, 7 Sep 2024 09:52:51 +0000 (09:52 +0000)
committersnickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Sat, 7 Sep 2024 09:52:51 +0000 (09:52 +0000)
Code review from 袁清梦

* refs/changes/908/head: (15 commits squashed)

  - 增加多国语言自动翻译脚本:待完善

  - 修复心率测量发生的死机

  - Merge branch &#39;sdk602patch0626&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626

  - #440运动-健身类-少了循环训练

  - #439运动-健身类 排序问题 室外走路,跑步,骑行不在顶部,需要把常用的放在顶部

  - #445 运动-休闲运动-少了对战游戏

  - Merge branch &#39;sdk602patch0626&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626

  - #447 运动结束界面添加提示语

  - #441运动-健身类有遮挡

  - #442运动-所有类底部有遮挡

  - #443运动-类别界面-上滑会有短暂回弹

  - #444运动类界面-右滑返回上一级界面有界面晃动

  - #207运动界面进行触摸进出操作,界面会抖动,卡顿

  - #438运动-健身类上下滑动,健身运动会跟着跳动

  - Merge branch &#39;sdk602patch0626&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626

Signed-off-by: Caisking <3449750381@qq.com>
Reviewed-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Merged-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/908
code/sdk/application/wearable/fd230app/nativeui/traing/Training_UiConfig.h
code/sdk/application/wearable/fd230app/nativeui/traing/training_list_aquatic/src/TraingAquaticView.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/training_list_ball/src/TraingBallView.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/training_list_dance/src/TraingDanceView.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/training_list_fitness/src/TraingFitnessView.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/training_list_ice/src/TraingIceView.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/training_list_limit/src/TraingLimitView.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/training_list_more/src/TraingMoreView.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/training_list_other/src/TraingOtherView.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/training_list_rest/src/TraingRestView.cpp

index 228b8da..181207c 100644 (file)
@@ -9,7 +9,6 @@
 namespace OHOS
 {
 
-
 // Paths for different icons in the Training folder
 #define ICON36 "/user/res/Training/icon_36x36"
 #define ICON60 "/user/res/Training/icon_60x60"
@@ -17,7 +16,8 @@ namespace OHOS
 #define ICON54 "user/res/Training/icon_54x79"
 #define MODULES "/user/res/Training/modules"
 #define TRAINING_GIF "/user/res/Training/training_GIF"
-
+    static constexpr int16_t MAX_SCROLL_DIS = 1000;
+    static constexpr int16 ROTATE_FACTOR_2 = 2;
     // Icons in the icon_36x36 folder
     static constexpr const char *BALL_IMAGE = ICON36 "/Ball.bin";
     static constexpr const char *DANCE_IMAGE = ICON36 "/Dance.bin";
index db9f090..bc20daa 100644 (file)
@@ -55,47 +55,53 @@ namespace OHOS
     {
         if (scrollView == nullptr)
         {
-            scrollView = new UIScrollView();
+                 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);
         }
-        scrollView->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
-        // scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
-        // scrollView->SetScrollBlankSize(52);
-        scrollView->SetReboundSize(50);
-        scrollView->SetTouchable(true);
-        scrollView->SetDraggable(true);
-        scrollView->SetDirection(1);
-        draglistener = static_cast<UIView::OnDragListener *>(TraingAquaticPresenter::GetInstance());
-        scrollView->SetOnDragListener(draglistener);
-
         /* -------------------------------------------------------------------------- */
-        // 初始化Lable
-        InitLabelExt(title, 135, 52, 200, 60, "label1", STR_WATER_LIST, DEFAULT_VECTOR_FONT_FILENAME, 30);
-        title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full);
-        scrollView->Add(title);
+        // 初始化Lable 暂时不添加
+        if (title == nullptr)
+        {
+            InitLabelExt(title, 135, 52, 200, 60, "label1", STR_WATER_LIST, DEFAULT_VECTOR_FONT_FILENAME, 30);
+            title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full);
+            scrollView->Add(title);
+        }
         // UIList 的适配器
-        p_TraingAquaticListAdapter = new TraingAquaticAdapter();
-        p_TraingAquaticListAdapter->SetItemClickListener(presenter_);
+        if (p_TraingAquaticListAdapter == nullptr)
+        {
+            p_TraingAquaticListAdapter = new TraingAquaticAdapter();
+            p_TraingAquaticListAdapter->SetItemClickListener(presenter_);
+        }
+        // 初始化列表
         if (TraingAquaticList == nullptr)
         {
             TraingAquaticList = new UIList();
+            TraingAquaticList->SetPosition(43, 120, 466, 466);
+            TraingAquaticList->SetThrowDrag(true);
+            TraingAquaticList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+            TraingAquaticList->SetMaxScrollDistance(1000);
+            TraingAquaticList->SetSwipeACCLevel(800);
+            TraingAquaticList->SetDragACCLevel(5);
+            // 增加表冠控制
+            TraingAquaticList->SetRotateFactor(2);
+            TraingAquaticList->RequestFocus();
         }
-        TraingAquaticList->SetPosition(Aquatic_LIST_POSITION_X, Aquatic_LIST_POSITION_Y);
-        TraingAquaticList->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
-        TraingAquaticList->SetScrollBlankSize(Aquatic_SCROLLBLANKSIZE);
-        TraingAquaticList->SetSelectPosition(HORIZONTAL_RESOLUTION / SNUM_2); // middle position
-        TraingAquaticList->SetReboundSize(50);
-        TraingAquaticList->SetDraggable(true);
-        TraingAquaticList->SetThrowDrag(true);
-        TraingAquaticList->EnableAutoAlign(true);
-        TraingAquaticList->SetElastic(true); // 设置回弹效果
-        TraingAquaticList->SetMaxScrollDistance(MAX_SCR_DIS);
-        TraingAquaticList->SetYScrollBarVisible(true); // 设置滑动滚动条
-
-        // 增加表冠控制
-        TraingAquaticList->SetRotateFactor(2);
-        TraingAquaticList->RequestFocus();
-
-        SetKeyActListener();
     }
     UIList *TraingAquaticView::GetList()
     {
@@ -132,19 +138,26 @@ namespace OHOS
     {
         View<TraingAquaticPresenter>::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_);
     }
 
     /// @brief 创建页面的视图。
     void TraingAquaticView::OnSetUpView()
     {
         View<TraingAquaticPresenter>::OnSetUpView();
-        scrollView->Add(title);
-        scrollView->Add(TraingAquaticList);
-        scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
-        RootView::GetInstance()->Add(scrollView);
-        TraingAquaticList->SetAdapter(p_TraingAquaticListAdapter);
-        // TraingAquaticList->RefreshList(); // 刷新列表
+        if (TraingAquaticList != nullptr && p_TraingAquaticListAdapter != nullptr)
+        {
+            scrollView->Add(TraingAquaticList);
+            scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+            RootView::GetInstance()->Add(scrollView);
+            TraingAquaticList->SetAdapter(p_TraingAquaticListAdapter);
+        }
         Draw();
     }
 
@@ -159,12 +172,14 @@ namespace OHOS
     void TraingAquaticView::OnStop()
     {
         View<TraingAquaticPresenter>::OnStop();
-
-
+        if (container_ != nullptr)
+        {
+            container_->RemoveAll();
+            delete container_;
+            container_ = nullptr;
+        }
         RootView::GetInstance()->ClearOnKeyActListener();
-        //FocusManager::GetInstance()->ClearFocus();
         RootView::GetInstance()->RemoveAll();
-        // RootView::GetInstance()->ClearFocus();
         return;
     }
 }
\ No newline at end of file
index 9d0ac08..af44231 100644 (file)
@@ -56,55 +56,53 @@ namespace OHOS
         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);
+            
         }
-        scrollView->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
-        // scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
-        // scrollView->SetScrollBlankSize(52);
-        scrollView->SetReboundSize(50);
-        scrollView->SetTouchable(true);
-        scrollView->SetDraggable(true);
-        scrollView->SetDirection(1);
-        draglistener = static_cast<UIView::OnDragListener *>(TraingBallPresenter::GetInstance());
-        scrollView->SetOnDragListener(draglistener);
-
         /* -------------------------------------------------------------------------- */
-        // 初始化Lable
-        InitLabelExt(title, 135, 52, 200, 60, "label1", STR_BALL_LIST, DEFAULT_VECTOR_FONT_FILENAME, 30);
-        title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full);
-        scrollView->Add(title);
+        // 初始化Lable 暂时不添加
+        if (title == nullptr)
+        {
+            InitLabelExt(title, 135, 52, 200, 60, "label1", STR_BALL_LIST_TITLE, DEFAULT_VECTOR_FONT_FILENAME, 30);
+            title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full);
+            scrollView->Add(title);
+        }
         // UIList 的适配器
-        p_TraingBallListAdapter = new TraingBallAdapter();
-        p_TraingBallListAdapter->SetItemClickListener(presenter_);
+        if (p_TraingBallListAdapter == nullptr)
+        {
+            p_TraingBallListAdapter = new TraingBallAdapter();
+            p_TraingBallListAdapter->SetItemClickListener(presenter_);
+        }
+        // 初始化列表
         if (TraingBallList == nullptr)
         {
             TraingBallList = new UIList();
+            TraingBallList->SetPosition(43, 120, 466, 466);
+            TraingBallList->SetThrowDrag(true);
+            TraingBallList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+            TraingBallList->SetMaxScrollDistance(1000);
+            TraingBallList->SetSwipeACCLevel(800);
+            TraingBallList->SetDragACCLevel(5);
+            // 增加表冠控制
+            TraingBallList->SetRotateFactor(2);
+            TraingBallList->RequestFocus();
         }
-#if 0
-        TraingBallList->SetPosition(Ball_LIST_POSITION_X, Ball_LIST_POSITION_Y);
-        TraingBallList->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
-        TraingBallList->SetScrollBlankSize(Ball_SCROLLBLANKSIZE);
-        TraingBallList->SetSelectPosition(HORIZONTAL_RESOLUTION / SNUM_2); // middle position
-        TraingBallList->SetReboundSize(50);
-        TraingBallList->SetDraggable(true);
-        TraingBallList->SetThrowDrag(true);
-        TraingBallList->EnableAutoAlign(true);
-        TraingBallList->SetElastic(true); // 设置回弹效果
-        TraingBallList->SetMaxScrollDistance(MAX_SCR_DIS);
-        TraingBallList->SetYScrollBarVisible(true); // 设置滑动滚动条
-#endif
-
-        TraingBallList->SetPosition(Ball_LIST_POSITION_X, Ball_LIST_POSITION_Y, 466, 466);
-        TraingBallList->SetThrowDrag(true);
-        TraingBallList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
-        TraingBallList->SetMaxScrollDistance(1000);
-        TraingBallList->SetSwipeACCLevel(800);
-        TraingBallList->SetDragACCLevel(5);
-
-        // 增加表冠控制
-        TraingBallList->SetRotateFactor(2);
-        TraingBallList->RequestFocus();
-
-        SetKeyActListener();
     }
     UIList *TraingBallView::GetList()
     {
@@ -141,19 +139,26 @@ namespace OHOS
     {
         View<TraingBallPresenter>::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_);
     }
 
     /// @brief 创建页面的视图。
     void TraingBallView::OnSetUpView()
     {
         View<TraingBallPresenter>::OnSetUpView();
-        scrollView->Add(title);
-        scrollView->Add(TraingBallList);
-        scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
-        RootView::GetInstance()->Add(scrollView);
-        TraingBallList->SetAdapter(p_TraingBallListAdapter);
-        // TraingBallList->RefreshList(); // 刷新列表
+        if (TraingBallList != nullptr && p_TraingBallListAdapter != nullptr)
+        {
+            scrollView->Add(TraingBallList);
+            scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+            RootView::GetInstance()->Add(scrollView);
+            TraingBallList->SetAdapter(p_TraingBallListAdapter);
+        }
         Draw();
     }
 
@@ -169,10 +174,14 @@ namespace OHOS
     {
         View<TraingBallPresenter>::OnStop();
 
+        if (container_ != nullptr)
+        {
+            container_->RemoveAll();
+            delete container_;
+            container_ = nullptr;
+        }
         RootView::GetInstance()->ClearOnKeyActListener();
-        // FocusManager::GetInstance()->ClearFocus();
         RootView::GetInstance()->RemoveAll();
-        // RootView::GetInstance()->ClearFocus();
         return;
     }
 }
\ No newline at end of file
index 3e44f69..f43871a 100644 (file)
@@ -56,55 +56,55 @@ namespace OHOS
         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);
         }
-        scrollView->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
-        // scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
-        // scrollView->SetScrollBlankSize(52);
-        scrollView->SetReboundSize(50);
-        scrollView->SetTouchable(true);
-        scrollView->SetDraggable(true);
-        scrollView->SetDirection(1);
-        draglistener = static_cast<UIView::OnDragListener *>(TraingDancePresenter::GetInstance());
-        scrollView->SetOnDragListener(draglistener);
-
         /* -------------------------------------------------------------------------- */
-        // 初始化Lable
-        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);
+        // 初始化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 的适配器
-        p_TraingDanceListAdapter = new TraingDanceAdapter();
-        p_TraingDanceListAdapter->SetItemClickListener(presenter_);
+        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();
         }
-#if 0
-        TraingDanceList->SetPosition(Dance_LIST_POSITION_X, Dance_LIST_POSITION_Y);
-        TraingDanceList->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
-        TraingDanceList->SetScrollBlankSize(Dance_SCROLLBLANKSIZE);
-        TraingDanceList->SetSelectPosition(HORIZONTAL_RESOLUTION / SNUM_2); // middle position
-        TraingDanceList->SetReboundSize(50);
-        TraingDanceList->SetDraggable(true);
-        TraingDanceList->SetThrowDrag(true);
-        TraingDanceList->EnableAutoAlign(true);
-        TraingDanceList->SetElastic(true); // 设置回弹效果
-        TraingDanceList->SetMaxScrollDistance(MAX_SCR_DIS);
-        TraingDanceList->SetYScrollBarVisible(true); // 设置滑动滚动条
-#endif
-
-        TraingDanceList->SetPosition(Dance_LIST_POSITION_X, Dance_LIST_POSITION_Y, 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();
-
-        SetKeyActListener();
     }
     UIList *TraingDanceView::GetList()
     {
@@ -141,19 +141,26 @@ namespace OHOS
     {
         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_);
     }
 
     /// @brief 创建页面的视图。
     void TraingDanceView::OnSetUpView()
     {
         View<TraingDancePresenter>::OnSetUpView();
-        // scrollView->Add(title);
-        scrollView->Add(TraingDanceList);
-        scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
-        RootView::GetInstance()->Add(scrollView);
-        TraingDanceList->SetAdapter(p_TraingDanceListAdapter);
-        // TraingDanceList->RefreshList(); // 刷新列表
+        if (TraingDanceList != nullptr && p_TraingDanceListAdapter != nullptr)
+        {
+            scrollView->Add(TraingDanceList);
+            scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+            RootView::GetInstance()->Add(scrollView);
+            TraingDanceList->SetAdapter(p_TraingDanceListAdapter);
+        }
         Draw();
     }
 
@@ -169,10 +176,14 @@ namespace OHOS
     {
         View<TraingDancePresenter>::OnStop();
 
+        if (container_ != nullptr)
+        {
+            container_->RemoveAll();
+            delete container_;
+            container_ = nullptr;
+        }
         RootView::GetInstance()->ClearOnKeyActListener();
-        // FocusManager::GetInstance()->ClearFocus();
         RootView::GetInstance()->RemoveAll();
-        // RootView::GetInstance()->ClearFocus();
         return;
     }
 }
\ No newline at end of file
index 0f9e831..c05f827 100644 (file)
@@ -54,56 +54,53 @@ namespace OHOS
     {
         if (scrollView == nullptr)
         {
-            scrollView = new UIScrollView();
+                 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);
         }
-        scrollView->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
-        // scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
-        // scrollView->SetScrollBlankSize(52);
-        scrollView->SetReboundSize(50);
-        scrollView->SetTouchable(true);
-        scrollView->SetDraggable(true);
-        scrollView->SetDirection(1);
-        draglistener = static_cast<UIView::OnDragListener *>(TraingFitnessPresenter::GetInstance());
-        scrollView->SetOnDragListener(draglistener);
-
         /* -------------------------------------------------------------------------- */
-        // 初始化Lable
-        InitLabelExt(title, 135, 52, 200, 60, "label1", STR_EXERCISE_TITLE, DEFAULT_VECTOR_FONT_FILENAME, 30);
-        title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full);
-        scrollView->Add(title);
+        // 初始化Lable 暂时不添加
+        if (title == nullptr)
+        {
+            InitLabelExt(title, 135, 52, 200, 60, "label1", STR_EXERCISE_TITLE, DEFAULT_VECTOR_FONT_FILENAME, 30);
+            title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full);
+            scrollView->Add(title);
+        }
         // UIList 的适配器
-        p_TraingFitnessListAdapter = new TraingFitnessAdapter();
-        p_TraingFitnessListAdapter->SetItemClickListener(presenter_);
+        if (p_TraingFitnessListAdapter == nullptr)
+        {
+            p_TraingFitnessListAdapter = new TraingFitnessAdapter();
+            p_TraingFitnessListAdapter->SetItemClickListener(presenter_);
+        }
+        // 初始化列表
         if (TraingFitnessList == nullptr)
         {
             TraingFitnessList = new UIList();
+            TraingFitnessList->SetPosition(43, 120, 466, 466);
+            TraingFitnessList->SetThrowDrag(true);
+            TraingFitnessList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+            TraingFitnessList->SetMaxScrollDistance(1000);
+            TraingFitnessList->SetSwipeACCLevel(800);
+            TraingFitnessList->SetDragACCLevel(5);
+            // 增加表冠控制
+            TraingFitnessList->SetRotateFactor(2);
+            TraingFitnessList->RequestFocus();
         }
-#if 0
-        TraingFitnessList->SetPosition(Fitness_LIST_POSITION_X, Fitness_LIST_POSITION_Y);
-        TraingFitnessList->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
-        TraingFitnessList->SetScrollBlankSize(Fitness_SCROLLBLANKSIZE);
-        TraingFitnessList->SetSelectPosition(HORIZONTAL_RESOLUTION / SNUM_2); // middle position
-        TraingFitnessList->SetReboundSize(50);
-        TraingFitnessList->SetDraggable(true);
-        TraingFitnessList->SetThrowDrag(true);
-        TraingFitnessList->EnableAutoAlign(true);
-        TraingFitnessList->SetElastic(true); // 设置回弹效果
-        TraingFitnessList->SetMaxScrollDistance(MAX_SCR_DIS);
-        TraingFitnessList->SetYScrollBarVisible(true); // 设置滑动滚动条
-#endif
-
-        TraingFitnessList->SetPosition(Fitness_LIST_POSITION_X, Fitness_LIST_POSITION_Y, 466, 466);
-        TraingFitnessList->SetThrowDrag(true);
-        TraingFitnessList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
-        TraingFitnessList->SetMaxScrollDistance(1000);
-        TraingFitnessList->SetSwipeACCLevel(800);
-        TraingFitnessList->SetDragACCLevel(5);
-
-        // 增加表冠控制
-        TraingFitnessList->SetRotateFactor(2);
-        TraingFitnessList->RequestFocus();
-
-        SetKeyActListener();
     }
     UIList *TraingFitnessView::GetList()
     {
@@ -145,19 +142,26 @@ namespace OHOS
     {
         View<TraingFitnessPresenter>::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_);
     }
 
     /// @brief 创建页面的视图。
     void TraingFitnessView::OnSetUpView()
     {
         View<TraingFitnessPresenter>::OnSetUpView();
-        // scrollView->Add(title);
-        scrollView->Add(TraingFitnessList);
-        scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
-        RootView::GetInstance()->Add(scrollView);
-        TraingFitnessList->SetAdapter(p_TraingFitnessListAdapter);
-        // TraingFitnessList->RefreshList(); // 刷新列表
+        if (TraingFitnessList != nullptr && p_TraingFitnessListAdapter != nullptr)
+        {
+            scrollView->Add(TraingFitnessList);
+            scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+            RootView::GetInstance()->Add(scrollView);
+            TraingFitnessList->SetAdapter(p_TraingFitnessListAdapter);
+        }
         Draw();
     }
 
@@ -172,11 +176,14 @@ namespace OHOS
     void TraingFitnessView::OnStop()
     {
         View<TraingFitnessPresenter>::OnStop();
-
+        if (container_ != nullptr)
+        {
+            container_->RemoveAll();
+            delete container_;
+            container_ = nullptr;
+        }
         RootView::GetInstance()->ClearOnKeyActListener();
-        // FocusManager::GetInstance()->ClearFocus();
         RootView::GetInstance()->RemoveAll();
-        // RootView::GetInstance()->ClearFocus();
         return;
     }
 }
\ No newline at end of file
index a2fb057..15cdc48 100644 (file)
@@ -63,56 +63,53 @@ namespace OHOS
     {
         if (scrollView == nullptr)
         {
-            scrollView = new UIScrollView();
+                 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);
         }
-        scrollView->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
-        // scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
-        // scrollView->SetScrollBlankSize(52);
-        scrollView->SetReboundSize(50);
-        scrollView->SetTouchable(true);
-        scrollView->SetDraggable(true);
-        scrollView->SetDirection(1);
-        draglistener = static_cast<UIView::OnDragListener *>(TraingIcePresenter::GetInstance());
-        scrollView->SetOnDragListener(draglistener);
-
         /* -------------------------------------------------------------------------- */
-        // 初始化Lable
-        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);
+        // 初始化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 的适配器
-        p_TraingIceListAdapter = new TraingIceAdapter();
-        p_TraingIceListAdapter->SetItemClickListener(presenter_);
+        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();
         }
-#if 0
-        TraingIceList->SetPosition(Ice_LIST_POSITION_X, Ice_LIST_POSITION_Y);
-        TraingIceList->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
-        TraingIceList->SetScrollBlankSize(Ice_SCROLLBLANKSIZE);
-        TraingIceList->SetSelectPosition(HORIZONTAL_RESOLUTION / SNUM_2); // middle position
-        TraingIceList->SetDraggable(true);
-        TraingIceList->SetThrowDrag(true);
-        TraingIceList->EnableAutoAlign(true);
-        TraingIceList->SetReboundSize(50);
-        TraingIceList->SetElastic(true); // 设置回弹效果
-        TraingIceList->SetMaxScrollDistance(MAX_SCR_DIS);
-        TraingIceList->SetYScrollBarVisible(true); // 设置滑动滚动条
-#endif
-
-        TraingIceList->SetPosition(Ice_LIST_POSITION_X, Ice_LIST_POSITION_Y, 466, 466);
-        TraingIceList->SetThrowDrag(true);
-        TraingIceList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
-        TraingIceList->SetMaxScrollDistance(1000);
-        TraingIceList->SetSwipeACCLevel(800);
-        TraingIceList->SetDragACCLevel(5);
-
-        // 增加表冠控制
-        scrollView->SetRotateFactor(2);
-        scrollView->RequestFocus();
-
-        SetKeyActListener();
     }
     UIList *TraingIceView::GetList()
     {
@@ -149,19 +146,26 @@ namespace OHOS
     {
         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_);
     }
 
     /// @brief 创建页面的视图。
     void TraingIceView::OnSetUpView()
     {
         View<TraingIcePresenter>::OnSetUpView();
-        // scrollView->Add(title);
-        scrollView->Add(TraingIceList);
-        scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
-        RootView::GetInstance()->Add(scrollView);
-        TraingIceList->SetAdapter(p_TraingIceListAdapter);
-        // TraingIceList->RefreshList(); // 刷新列表
+        if (TraingIceList != nullptr && p_TraingIceListAdapter != nullptr)
+        {
+            scrollView->Add(TraingIceList);
+            scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+            RootView::GetInstance()->Add(scrollView);
+            TraingIceList->SetAdapter(p_TraingIceListAdapter);
+        }
         Draw();
     }
 
@@ -176,11 +180,14 @@ namespace OHOS
     void TraingIceView::OnStop()
     {
         View<TraingIcePresenter>::OnStop();
-
+        if (container_ != nullptr)
+        {
+            container_->RemoveAll();
+            delete container_;
+            container_ = nullptr;
+        }
         RootView::GetInstance()->ClearOnKeyActListener();
-        // FocusManager::GetInstance()->ClearFocus();
         RootView::GetInstance()->RemoveAll();
-        // RootView::GetInstance()->ClearFocus();
         return;
     }
 }
\ No newline at end of file
index 415ee64..93855a8 100644 (file)
@@ -56,56 +56,53 @@ namespace OHOS
     {\r
         if (scrollView == nullptr)\r
         {\r
-            scrollView = new UIScrollView();\r
+                 scrollView = new UIScrollView();\r
+            if (scrollView == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "scrollView new fail!");\r
+                return;\r
+            }\r
+            scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
+            scrollView->SetScrollBlankSize(50);\r
+            // scrollView->SetReboundSize(35);\r
+            scrollView->SetHorizontalScrollState(false);\r
+            scrollView->RequestFocus();\r
+            scrollView->SetRotateFactor(1.0);\r
+            scrollView->SetMaxScrollDistance(1000);\r
+            scrollView->SetDragACCLevel(5);\r
+            scrollView->SetSwipeACCLevel(800); /*设置手指抬起屏幕后的补偿距离。*/\r
+            scrollView->SetTouchable(true);\r
+            scrollView->SetDraggable(true);\r
+            container_->Add(scrollView);\r
         }\r
-        scrollView->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);\r
-        // scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
-        // scrollView->SetScrollBlankSize(52);\r
-        scrollView->SetReboundSize(50);\r
-        scrollView->SetTouchable(true);\r
-        scrollView->SetDraggable(true);\r
-        scrollView->SetDirection(1);\r
-        draglistener = static_cast<UIView::OnDragListener *>(TraingLimitPresenter::GetInstance());\r
-        scrollView->SetOnDragListener(draglistener);\r
-\r
         /* -------------------------------------------------------------------------- */\r
-        // 初始化Lable\r
-        InitLabelExt(title, 135, 52, 200, 60, "label1", STR_EXTREME_LIST, DEFAULT_VECTOR_FONT_FILENAME, 30);\r
-        title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full);\r
-        scrollView->Add(title);\r
+        // 初始化Lable 暂时不添加\r
+        if (title == nullptr)\r
+        {\r
+            InitLabelExt(title, 135, 52, 200, 60, "label1", STR_EXTREME_LIST, DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+            title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full);\r
+            scrollView->Add(title);\r
+        }\r
         // UIList 的适配器\r
-        p_TraingLimitListAdapter = new TraingLimitAdapter();\r
-        p_TraingLimitListAdapter->SetItemClickListener(presenter_);\r
+        if (p_TraingLimitListAdapter == nullptr)\r
+        {\r
+            p_TraingLimitListAdapter = new TraingLimitAdapter();\r
+            p_TraingLimitListAdapter->SetItemClickListener(presenter_);\r
+        }\r
+        // 初始化列表\r
         if (TraingLimitList == nullptr)\r
         {\r
             TraingLimitList = new UIList();\r
+            TraingLimitList->SetPosition(43, 120, 466, 466);\r
+            TraingLimitList->SetThrowDrag(true);\r
+            TraingLimitList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);\r
+            TraingLimitList->SetMaxScrollDistance(1000);\r
+            TraingLimitList->SetSwipeACCLevel(800);\r
+            TraingLimitList->SetDragACCLevel(5);\r
+            // 增加表冠控制\r
+            TraingLimitList->SetRotateFactor(2);\r
+            TraingLimitList->RequestFocus();\r
         }\r
-#if 0\r
-        TraingLimitList->SetPosition(Limit_LIST_POSITION_X, Limit_LIST_POSITION_Y);\r
-        TraingLimitList->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);\r
-        TraingLimitList->SetScrollBlankSize(Limit_SCROLLBLANKSIZE);\r
-        TraingLimitList->SetSelectPosition(HORIZONTAL_RESOLUTION / SNUM_2); // middle position\r
-        TraingLimitList->SetReboundSize(50);\r
-        TraingLimitList->SetDraggable(true);\r
-        TraingLimitList->SetThrowDrag(true);\r
-        TraingLimitList->EnableAutoAlign(true);\r
-        TraingLimitList->SetElastic(true); // 设置回弹效果\r
-        TraingLimitList->SetMaxScrollDistance(MAX_SCR_DIS);\r
-        TraingLimitList->SetYScrollBarVisible(true); // 设置滑动滚动条\r
-#endif\r
-\r
-        TraingLimitList->SetPosition(Limit_LIST_POSITION_X, Limit_LIST_POSITION_Y, 466, 466);\r
-        TraingLimitList->SetThrowDrag(true);\r
-        TraingLimitList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);\r
-        TraingLimitList->SetMaxScrollDistance(1000);\r
-        TraingLimitList->SetSwipeACCLevel(800);\r
-        TraingLimitList->SetDragACCLevel(5);\r
-\r
-        // 增加表冠控制\r
-        TraingLimitList->SetRotateFactor(2);\r
-        TraingLimitList->RequestFocus();\r
-\r
-        SetKeyActListener();\r
     }\r
     UIList *TraingLimitView::GetList()\r
     {\r
@@ -142,19 +139,26 @@ namespace OHOS
     {\r
         View<TraingLimitPresenter>::OnStart();\r
         BaseView::RootView(Color::Black().full);\r
+        SetContainerView(new UIViewGroup());\r
+        container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
+        container_->SetOnDragListener(presenter_);\r
+        container_->SetTouchable(true);\r
+        container_->SetDraggable(true);\r
         PreLoad();\r
+        RootView::GetInstance()->SetOnKeyActListener(presenter_);\r
     }\r
 \r
     /// @brief 创建页面的视图。\r
     void TraingLimitView::OnSetUpView()\r
     {\r
         View<TraingLimitPresenter>::OnSetUpView();\r
-        // scrollView->Add(title);\r
-        scrollView->Add(TraingLimitList);\r
-        scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);\r
-        RootView::GetInstance()->Add(scrollView);\r
-        TraingLimitList->SetAdapter(p_TraingLimitListAdapter);\r
-        // TraingLimitList->RefreshList(); // 刷新列表\r
+        if (TraingLimitList != nullptr && p_TraingLimitListAdapter != nullptr)\r
+        {\r
+            scrollView->Add(TraingLimitList);\r
+            scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);\r
+            RootView::GetInstance()->Add(scrollView);\r
+            TraingLimitList->SetAdapter(p_TraingLimitListAdapter);\r
+        }\r
         Draw();\r
     }\r
 \r
@@ -169,11 +173,14 @@ namespace OHOS
     void TraingLimitView::OnStop()\r
     {\r
         View<TraingLimitPresenter>::OnStop();\r
-\r
+        if (container_ != nullptr)\r
+        {\r
+            container_->RemoveAll();\r
+            delete container_;\r
+            container_ = nullptr;\r
+        }\r
         RootView::GetInstance()->ClearOnKeyActListener();\r
-        // FocusManager::GetInstance()->ClearFocus();\r
         RootView::GetInstance()->RemoveAll();\r
-        // RootView::GetInstance()->ClearFocus();\r
         return;\r
     }\r
 }
\ No newline at end of file
index 273aca6..6625ec9 100644 (file)
@@ -58,41 +58,38 @@ namespace OHOS
     }\r
     void TraingMoreView::InitView()\r
     {\r
+        // 初始化 UIScrollView\r
         if (scrollView == nullptr)\r
         {\r
             scrollView = new UIScrollView();\r
         }\r
-        scrollView->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);\r
-        // scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
-        // scrollView->SetScrollBlankSize(52);\r
-        scrollView->SetReboundSize(50);\r
+\r
+        // 设置 UIScrollView 属性\r
+        scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
         scrollView->SetTouchable(true);\r
         scrollView->SetDraggable(true);\r
         scrollView->SetDirection(1);\r
-        draglistener = static_cast<UIView::OnDragListener *>(TraingMorePresenter::GetInstance());\r
-        scrollView->SetOnDragListener(draglistener);\r
+        // scrollView->SetReboundSize(50); // 设置空白大小\r
+        scrollView->SetScrollBlankSize(75);\r
+        scrollView->SetHorizontalScrollState(false); // 设置横向不可滑动\r
+\r
+        // 设置拖动监听器\r
+        scrollView->SetOnDragListener(presenter_);\r
 \r
-        /* -------------------------------------------------------------------------- */\r
-        // 初始化Lable\r
+        // 初始化 label\r
         InitLabelExt(title, 125, 52, 200, 60, "label1", STR_TRAINING, DEFAULT_VECTOR_FONT_FILENAME, 30);\r
         scrollView->Add(title);\r
-        // UIList 的适配器\r
+\r
+        // 初始化适配器\r
         p_TraingMoreListAdapter = new TraingMoreAdapter();\r
         p_TraingMoreListAdapter->SetItemClickListener(presenter_);\r
+\r
+        // 初始化 UIList\r
         if (TraingMoreList == nullptr)\r
         {\r
             TraingMoreList = new UIList();\r
         }\r
 \r
-        // TraingMoreList->SetScrollBlankSize(More_SCROLLBLANKSIZE);\r
-        // TraingMoreList->SetReboundSize(50);\r
-        // TraingMoreList->SetSelectPosition(HORIZONTAL_RESOLUTION / SNUM_2); // middle position\r
-        // TraingMoreList->SetDraggable(true);\r
-        // TraingMoreList->SetThrowDrag(true);\r
-        // TraingMoreList->EnableAutoAlign(true);\r
-        // TraingMoreList->SetElastic(true); // 设置回弹效果\r
-        // TraingMoreList->SetMaxScrollDistance(MAX_SCR_DIS);\r
-\r
         TraingMoreList->SetPosition(More_LIST_POSITION_X, More_LIST_POSITION_Y, 466, 466);\r
         TraingMoreList->SetThrowDrag(true);\r
         TraingMoreList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);\r
@@ -100,12 +97,14 @@ namespace OHOS
         TraingMoreList->SetSwipeACCLevel(800);\r
         TraingMoreList->SetDragACCLevel(5);\r
 \r
-        scrollView->SetYScrollBarVisible(true); // 设置滑动滚动条\r
+        // 设置滚动条可见性\r
+        scrollView->SetYScrollBarVisible(true);\r
 \r
         // 增加表冠控制\r
         TraingMoreList->SetRotateFactor(2);\r
         TraingMoreList->RequestFocus();\r
 \r
+        // 设置键盘事件监听\r
         SetKeyActListener();\r
     }\r
     UIList *TraingMoreView::GetList()\r
@@ -155,7 +154,7 @@ namespace OHOS
         scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);\r
         RootView::GetInstance()->Add(scrollView);\r
         TraingMoreList->SetAdapter(p_TraingMoreListAdapter);\r
-        TraingMoreList->SetIntercept(true);\r
+        // TraingMoreList->SetIntercept(true);\r
         // TraingMoreList->RefreshList(); // 刷新列表\r
         Draw();\r
     }\r
index 7e2b211..f216977 100644 (file)
@@ -57,55 +57,53 @@ namespace OHOS
         if (scrollView == nullptr)
         {
             scrollView = new UIScrollView();
+            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);
         }
-        scrollView->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
-        // scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
-        // scrollView->SetScrollBlankSize(52);
-        scrollView->SetReboundSize(50);
-        scrollView->SetTouchable(true);
-        scrollView->SetDraggable(true);
-        scrollView->SetDirection(1);
-        draglistener = static_cast<UIView::OnDragListener *>(TraingOtherPresenter::GetInstance());
-        scrollView->SetOnDragListener(draglistener);
-
         /* -------------------------------------------------------------------------- */
-        // 初始化Lable
-        InitLabelExt(title, 125, 52, 200, 60, "label1", STR_OTHER_TITLE, DEFAULT_VECTOR_FONT_FILENAME, 30);
-        title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full);
-        scrollView->Add(title);
+        // 初始化Lable 暂时不添加
+        if (title == nullptr)
+        {
+            InitLabelExt(title, 135, 52, 200, 60, "label1", STR_OTHER_LIST, DEFAULT_VECTOR_FONT_FILENAME, 30);
+            title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full);
+            scrollView->Add(title);
+        }
         // UIList 的适配器
-        p_TraingOtherListAdapter = new TraingOtherAdapter();
-        p_TraingOtherListAdapter->SetItemClickListener(presenter_);
+        if (p_TraingOtherListAdapter == nullptr)
+        {
+            p_TraingOtherListAdapter = new TraingOtherAdapter();
+            p_TraingOtherListAdapter->SetItemClickListener(presenter_);
+        }
+        // 初始化列表
         if (TraingOtherList == nullptr)
         {
             TraingOtherList = new UIList();
+            TraingOtherList->SetPosition(43, 120, 466, 466);
+            TraingOtherList->SetThrowDrag(true);
+            TraingOtherList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+            TraingOtherList->SetMaxScrollDistance(1000);
+            TraingOtherList->SetSwipeACCLevel(800);
+            TraingOtherList->SetDragACCLevel(5);
+            // 增加表冠控制
+            TraingOtherList->SetRotateFactor(2);
+            TraingOtherList->RequestFocus();
         }
-#if 0
-        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->SetReboundSize(50);
-        TraingOtherList->SetDraggable(true);
-        TraingOtherList->SetThrowDrag(true);
-        TraingOtherList->EnableAutoAlign(true);
-        TraingOtherList->SetElastic(true); // 设置回弹效果
-        TraingOtherList->SetMaxScrollDistance(MAX_SCR_DIS);
-        TraingOtherList->SetYScrollBarVisible(true); // 设置滑动滚动条
-#endif
-
-        TraingOtherList->SetPosition(Other_LIST_POSITION_X, Other_LIST_POSITION_Y, 466, 466);
-        TraingOtherList->SetThrowDrag(true);
-        TraingOtherList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
-        TraingOtherList->SetMaxScrollDistance(1000);
-        TraingOtherList->SetSwipeACCLevel(800);
-        TraingOtherList->SetDragACCLevel(5);
-
-        // 增加表冠控制
-        TraingOtherList->SetRotateFactor(2);
-        TraingOtherList->RequestFocus();
-
-        SetKeyActListener();
     }
     UIList *TraingOtherView::GetList()
     {
@@ -142,19 +140,26 @@ namespace OHOS
     {
         View<TraingOtherPresenter>::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_);
     }
 
     /// @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(); // 刷新列表
+        if (TraingOtherList != nullptr && p_TraingOtherListAdapter != nullptr)
+        {
+            scrollView->Add(TraingOtherList);
+            scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+            RootView::GetInstance()->Add(scrollView);
+            TraingOtherList->SetAdapter(p_TraingOtherListAdapter);
+        }
         Draw();
     }
 
@@ -169,11 +174,14 @@ namespace OHOS
     void TraingOtherView::OnStop()
     {
         View<TraingOtherPresenter>::OnStop();
-
+        if (container_ != nullptr)
+        {
+            container_->RemoveAll();
+            delete container_;
+            container_ = nullptr;
+        }
         RootView::GetInstance()->ClearOnKeyActListener();
-        // FocusManager::GetInstance()->ClearFocus();
         RootView::GetInstance()->RemoveAll();
-        // RootView::GetInstance()->ClearFocus();
         return;
     }
 }
\ No newline at end of file
index 149c7ec..de18dee 100644 (file)
@@ -54,58 +54,55 @@ namespace OHOS
     }
     void TraingRestView::InitView()
     {
-        if (scrollView == nullptr)
+   if (scrollView == nullptr)
         {
-            scrollView = new UIScrollView();
+                 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);
         }
-        scrollView->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
-        // scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
-        // scrollView->SetScrollBlankSize(52);
-        scrollView->SetReboundSize(50);
-        scrollView->SetTouchable(true);
-        scrollView->SetDraggable(true);
-        scrollView->SetDirection(1);
-        draglistener = static_cast<UIView::OnDragListener *>(TraingRestPresenter::GetInstance());
-        scrollView->SetOnDragListener(draglistener);
-
         /* -------------------------------------------------------------------------- */
-        // 初始化Lable
-        InitLabelExt(title, 125, 52, 200, 60, "label1", STR_RECREATIONAL_LIST, DEFAULT_VECTOR_FONT_FILENAME, 30);
-        title->SetStyle(STYLE_TEXT_COLOR, Color::Green().full);
-        scrollView->Add(title);
+        // 初始化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 的适配器
-        p_TraingRestListAdapter = new TraingRestAdapter();
-        p_TraingRestListAdapter->SetItemClickListener(presenter_);
+        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();
         }
-#if 0
-        TraingRestList->SetPosition(Rest_LIST_POSITION_X, Rest_LIST_POSITION_Y);
-        TraingRestList->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
-        TraingRestList->SetScrollBlankSize(Rest_SCROLLBLANKSIZE);
-        TraingRestList->SetSelectPosition(HORIZONTAL_RESOLUTION / SNUM_2); // middle position
-        TraingRestList->SetReboundSize(50);
-        TraingRestList->SetDraggable(true);
-        TraingRestList->SetThrowDrag(true);
-        TraingRestList->EnableAutoAlign(true);
-        TraingRestList->SetElastic(true); // 设置回弹效果
-        TraingRestList->SetMaxScrollDistance(MAX_SCR_DIS);
-        TraingRestList->SetYScrollBarVisible(true); // 设置滑动滚动条
-#endif
-
-        TraingRestList->SetPosition(Rest_LIST_POSITION_X, Rest_LIST_POSITION_Y, 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();
-
-        SetKeyActListener();
     }
     UIList *TraingRestView::GetList()
     {
@@ -142,19 +139,26 @@ namespace OHOS
     {
         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_);
     }
 
     /// @brief 创建页面的视图。
     void TraingRestView::OnSetUpView()
     {
         View<TraingRestPresenter>::OnSetUpView();
-        // scrollView->Add(title);
-        scrollView->Add(TraingRestList);
-        scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
-        RootView::GetInstance()->Add(scrollView);
-        TraingRestList->SetAdapter(p_TraingRestListAdapter);
-        // TraingRestList->RefreshList(); // 刷新列表
+        if (TraingRestList != nullptr && p_TraingRestListAdapter != nullptr)
+        {
+            scrollView->Add(TraingRestList);
+            scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+            RootView::GetInstance()->Add(scrollView);
+            TraingRestList->SetAdapter(p_TraingRestListAdapter);
+        }
         Draw();
     }
 
@@ -169,11 +173,14 @@ namespace OHOS
     void TraingRestView::OnStop()
     {
         View<TraingRestPresenter>::OnStop();
-
+        if (container_ != nullptr)
+        {
+            container_->RemoveAll();
+            delete container_;
+            container_ = nullptr;
+        }
         RootView::GetInstance()->ClearOnKeyActListener();
-        // FocusManager::GetInstance()->ClearFocus();
         RootView::GetInstance()->RemoveAll();
-        // RootView::GetInstance()->ClearFocus();
         return;
     }
 }
\ No newline at end of file