优化训练死机bug
authorCaisking <3449750381@qq.com>
Thu, 13 Jun 2024 08:10:19 +0000 (16:10 +0800)
committerCaisking <3449750381@qq.com>
Thu, 13 Jun 2024 08:10:19 +0000 (16:10 +0800)
14 files changed:
code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp
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
code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordView.cpp

index aae8b1b..6d2b730 100644 (file)
@@ -1,4 +1,10 @@
-/*** 
+/***
+ * @Date: 2024-06-12 11:24:16
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-06-13 15:08:56
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataPresenter.cpp
+ */
+/***
  * @Date: 2024-04-15 14:19:47
  * @LastEditors: Caisking 3449750381@qq.com
  * @LastEditTime: 2024-06-11 15:34:57
@@ -73,7 +79,7 @@ namespace OHOS
     {
         if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
         {
-            NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);
+            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAINING_RECORD);
         }
         UNUSED(view);
         return true;
@@ -84,7 +90,7 @@ namespace OHOS
         // 根据控件id查找是哪个控件触发了点击回调
         if (strcmp(view.GetViewId(), BUTTONBACK) == 0)
         {
-            NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);
+            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGMORE);
         }
         return true;
     }
index 7ee0737..932b883 100644 (file)
@@ -145,8 +145,8 @@ namespace OHOS
     /* DeInit:删除组件 */
     void TraingEnddataView::DeInit()
     {
-        container_->RemoveAll();
         scrollView_->RemoveAll();
+        container_->RemoveAll();
         /*单位label*/
         if (labeltype != nullptr)
         {
@@ -271,6 +271,13 @@ namespace OHOS
             delete imageLine7;
             imageLine7 = nullptr;
         }
+
+        if (scrollView_ != nullptr)
+        {
+            delete scrollView_;
+            scrollView_ = nullptr;
+        }
+        
         delete container_;
         container_ = nullptr;
     }
@@ -287,13 +294,13 @@ namespace OHOS
     void TraingEnddataView::InitData()
     {
         SportData *enddata = TraingModel::GetInstance()->GetSportdata();
-        
+
         if (enddata == nullptr)
         {
             printf("Enddata is nullptr. Exiting InitData()...\r\n");
             return;
         }
-        printf("Initializing TraingEnddataView data...\r\n");
+        // printf("Initializing TraingEnddataView data...\r\n");
         // 训练图标Icon
         std::string imageStr = TraingModel::GetInstance()->GetSportType(enddata->sportType);
         if (!imageStr.empty())
@@ -316,7 +323,7 @@ namespace OHOS
         labelduration->SetText(durationStr.c_str());
 
         // 运动目标
-        if (enddata->tag)
+        if (enddata->goaldegree)
         {
             std::string tagStr = std::to_string(enddata->goaldegree) + "%";
             labeltag->SetText(tagStr.c_str());
index e9b8b7f..cc88c58 100644 (file)
@@ -1154,7 +1154,7 @@ namespace OHOS
         // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CheckDataJson is ok");
         return true;
     }
-#if 0
+#if 1
     bool TraingModel::SaveDataToJson(SportData *data)
     {
         if (data == nullptr)
@@ -1252,6 +1252,7 @@ namespace OHOS
         return true;
     }
 #endif
+#if 0
     bool TraingModel::SaveDataToJson(SportData *data)
     {
         if (data == nullptr)
@@ -1317,7 +1318,7 @@ namespace OHOS
         WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "SaveDataToJson succeeded");
         return true;
     }
-
+#endif
     /* 加载训练数据函数 */
     std::vector<SportData> TraingModel::LoadDataFormJson()
     {
index 3ec7102..cb15c6f 100644 (file)
@@ -85,8 +85,8 @@ namespace OHOS
         TraingAquaticList->SetYScrollBarVisible(true); // 设置滑动滚动条
 
         // 增加表冠控制
-        TraingAquaticList->SetRotateFactor(2);
-        TraingAquaticList->RequestFocus();
+        //TraingAquaticList->SetRotateFactor(2);
+        //TraingAquaticList->RequestFocus();
     }
     UIList *TraingAquaticView::GetList()
     {
@@ -151,7 +151,7 @@ namespace OHOS
     {
         View<TraingAquaticPresenter>::OnStop();
         RootView::GetInstance()->RemoveAll();
-        RootView::GetInstance()->ClearFocus();
+       // RootView::GetInstance()->ClearFocus();
         return;
     }
 }
\ No newline at end of file
index d4726a3..9ec6b68 100644 (file)
@@ -85,8 +85,8 @@ namespace OHOS
         TraingBallList->SetYScrollBarVisible(true); // 设置滑动滚动条
 
         // 增加表冠控制
-        TraingBallList->SetRotateFactor(2);
-        TraingBallList->RequestFocus();
+        //TraingBallList->SetRotateFactor(2);
+        //TraingBallList->RequestFocus();
     }
     UIList *TraingBallView::GetList()
     {
@@ -151,7 +151,7 @@ namespace OHOS
     {
         View<TraingBallPresenter>::OnStop();
         RootView::GetInstance()->RemoveAll();
-        RootView::GetInstance()->ClearFocus();
+       // RootView::GetInstance()->ClearFocus();
         return;
     }
 }
\ No newline at end of file
index b40d502..03d164a 100644 (file)
@@ -85,8 +85,8 @@ namespace OHOS
         TraingDanceList->SetYScrollBarVisible(true); // 设置滑动滚动条
 
         // 增加表冠控制
-        TraingDanceList->SetRotateFactor(2);
-        TraingDanceList->RequestFocus();
+        //TraingDanceList->SetRotateFactor(2);
+        //TraingDanceList->RequestFocus();
     }
     UIList *TraingDanceView::GetList()
     {
@@ -151,7 +151,7 @@ namespace OHOS
     {
         View<TraingDancePresenter>::OnStop();
         RootView::GetInstance()->RemoveAll();
-        RootView::GetInstance()->ClearFocus();
+       // RootView::GetInstance()->ClearFocus();
         return;
     }
 }
\ No newline at end of file
index edd4239..169713b 100644 (file)
@@ -83,8 +83,8 @@ namespace OHOS
         TraingFitnessList->SetYScrollBarVisible(true); // 设置滑动滚动条
 
         // 增加表冠控制
-        TraingFitnessList->SetRotateFactor(2);
-        TraingFitnessList->RequestFocus();
+        //TraingFitnessList->SetRotateFactor(2);
+        //TraingFitnessList->RequestFocus();
     }
     UIList *TraingFitnessView::GetList()
     {
@@ -153,7 +153,7 @@ namespace OHOS
     {
         View<TraingFitnessPresenter>::OnStop();
         RootView::GetInstance()->RemoveAll();
-        RootView::GetInstance()->ClearFocus();
+       // RootView::GetInstance()->ClearFocus();
         return;
     }
 }
\ No newline at end of file
index 4182d1b..5065f0f 100644 (file)
@@ -93,8 +93,8 @@ namespace OHOS
         TraingIceList->SetYScrollBarVisible(true); // 设置滑动滚动条
 
         // 增加表冠控制
-        scrollView->SetRotateFactor(2);
-        scrollView->RequestFocus();
+        //scrollView->SetRotateFactor(2);
+        //scrollView->RequestFocus();
     }
     UIList *TraingIceView::GetList()
     {
@@ -159,7 +159,7 @@ namespace OHOS
     {
         View<TraingIcePresenter>::OnStop();
         RootView::GetInstance()->RemoveAll();
-        RootView::GetInstance()->ClearFocus();
+       // RootView::GetInstance()->ClearFocus();
         return;
     }
 }
\ No newline at end of file
index e8de6c7..b2a069c 100644 (file)
@@ -85,8 +85,8 @@ namespace OHOS
         TraingLimitList->SetYScrollBarVisible(true); // 设置滑动滚动条\r
 \r
         // 增加表冠控制\r
-        TraingLimitList->SetRotateFactor(2);\r
-        TraingLimitList->RequestFocus();\r
+        //TraingLimitList->SetRotateFactor(2);\r
+        //TraingLimitList->RequestFocus();\r
     }\r
     UIList *TraingLimitView::GetList()\r
     {\r
@@ -151,7 +151,7 @@ namespace OHOS
     {\r
         View<TraingLimitPresenter>::OnStop();\r
         RootView::GetInstance()->RemoveAll();\r
-        RootView::GetInstance()->ClearFocus();\r
+       // RootView::GetInstance()->ClearFocus();\r
         return;\r
     }\r
 }
\ No newline at end of file
index dec193d..8e0823f 100644 (file)
@@ -90,8 +90,8 @@ namespace OHOS
         scrollView->SetYScrollBarVisible(true); // 设置滑动滚动条\r
 \r
         // 增加表冠控制\r
-        TraingMoreList->SetRotateFactor(2);\r
-        TraingMoreList->RequestFocus();\r
+        //TraingMoreList->SetRotateFactor(2);\r
+        //TraingMoreList->RequestFocus();\r
     }\r
     UIList *TraingMoreView::GetList()\r
     {\r
@@ -156,7 +156,7 @@ namespace OHOS
     {\r
         View<TraingMorePresenter>::OnStop();\r
         RootView::GetInstance()->RemoveAll();\r
-        RootView::GetInstance()->ClearFocus();\r
+        //RootView::GetInstance()->ClearFocus();\r
         return;\r
     }\r
 }
\ No newline at end of file
index 34c0b85..4c78490 100644 (file)
@@ -85,8 +85,8 @@ namespace OHOS
         TraingOtherList->SetYScrollBarVisible(true); // 设置滑动滚动条
 
         // 增加表冠控制
-        TraingOtherList->SetRotateFactor(2);
-        TraingOtherList->RequestFocus();
+        //TraingOtherList->SetRotateFactor(2);
+        //TraingOtherList->RequestFocus();
     }
     UIList *TraingOtherView::GetList()
     {
@@ -151,7 +151,7 @@ namespace OHOS
     {
         View<TraingOtherPresenter>::OnStop();
         RootView::GetInstance()->RemoveAll();
-        RootView::GetInstance()->ClearFocus();
+        //RootView::GetInstance()->ClearFocus();
         return;
     }
 }
\ No newline at end of file
index 5e0d517..78b292d 100644 (file)
@@ -85,8 +85,8 @@ namespace OHOS
         TraingRestList->SetYScrollBarVisible(true); // 设置滑动滚动条
 
         // 增加表冠控制
-        TraingRestList->SetRotateFactor(2);
-        TraingRestList->RequestFocus();
+        //TraingRestList->SetRotateFactor(2);
+        //TraingRestList->RequestFocus();
     }
     UIList *TraingRestView::GetList()
     {
@@ -151,7 +151,7 @@ namespace OHOS
     {
         View<TraingRestPresenter>::OnStop();
         RootView::GetInstance()->RemoveAll();
-        RootView::GetInstance()->ClearFocus();
+        //RootView::GetInstance()->ClearFocus();
         return;
     }
 }
\ No newline at end of file
index 788e0f4..afe88b8 100644 (file)
@@ -108,7 +108,8 @@ namespace OHOS
             if (!sportDataVector.empty())
             {
                 // 选择点击按键的历史数据
-                SportData sportData = sportDataVector[index];
+                int arraynum = sportDataVector.size() - 1;
+                SportData sportData = sportDataVector[arraynum - index]; // 显示是倒序 id同理
                 NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGENDDATA);
                 TraingModel::GetInstance()->SetSportdata(&sportData);
                 return true;
index 33e382d..33cfd90 100644 (file)
@@ -213,10 +213,6 @@ namespace OHOS
         TraingRecordList->SetMaxScrollDistance(MAX_SCR_DIS);
 
         recordView->SetYScrollBarVisible(true); // 设置滑动滚动条
-
-        // 增加表冠控制
-        TraingRecordList->SetRotateFactor(2);
-        TraingRecordList->RequestFocus();
         TraingRecordList->SetOnClickListener(static_cast<UIView::OnClickListener *>(TraingRecordPresenter::GetInstance()));
 
         UIView::OnDragListener *recorddraglistener = static_cast<UIView::OnDragListener *>(TraingRecordPresenter::GetInstance());
@@ -309,8 +305,6 @@ namespace OHOS
     {
         View<TraingRecordPresenter>::OnStop();
         RootView::GetInstance()->RemoveAll();
-        if (TraingRecordModel::GetInstance().GetJsonStatus())
-            RootView::GetInstance()->ClearFocus();
         return;
     }
 }