修复血氧界面滑动卡死的bug 2060/1 2060/head
authorCaisking <Casiking@zhihuishixun.com>
Fri, 8 Aug 2025 08:02:53 +0000 (16:02 +0800)
committerCaisking <Casiking@zhihuishixun.com>
Fri, 8 Aug 2025 08:02:53 +0000 (16:02 +0800)
code/sdk/application/wearable/fd230/nativeapp/nativeui/bloodoxygen/include/BloodDetectionView.h
code/sdk/application/wearable/fd230/nativeapp/nativeui/bloodoxygen/include/BloodResultView.h
code/sdk/application/wearable/fd230/nativeapp/nativeui/bloodoxygen/src/BloodDetectionView.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/bloodoxygen/src/BloodResultView.cpp

index 10ab43f..76920e5 100644 (file)
@@ -54,6 +54,7 @@ namespace OHOS
         UILabelExt *titleLabel{nullptr};
         UILabel *Spo2Text{nullptr};
         UILabelButtonExt *testButton{nullptr};
+        UIScrollView *scrollView_ = nullptr;
 
         uint32_t spo2_;
     };
index f02f591..06c6816 100644 (file)
@@ -1,21 +1,3 @@
-/***
- * @Date: 2024-04-15 10:55:58
- * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-07-30 11:46:23
- * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodResultView.h
- */
-/***
- * @Date: 2024-04-15 10:55:58
- * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-05-07 18:51:13
- * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodResultView.h
- */
-/*
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
- * Description: bloodResult view
- * Author:
- * Create: 2021-08-01
- */
 
 #ifndef BLOOD_Result_VIEW_H
 #define BLOOD_Result_VIEW_H
@@ -60,6 +42,7 @@ namespace OHOS
         UILabelExt *timeLabel = nullptr;
         UILabel *bloodLabel = nullptr;
         UILabelButtonExt *checkButton{nullptr};
+        UIScrollView *scrollView_ = nullptr;
     };
 }
 
index 075f8be..f6894ec 100644 (file)
@@ -20,6 +20,7 @@ namespace OHOS
     static constexpr uint16_t IMAGE_POSITION_X = 143;
     static constexpr uint16_t DETECTION_IMAGE_ANIMATORVIEW_SIZE = 30;
     static constexpr uint16_t DETECTION_IMAGE_ANIMATORVIEW_SPEED = 40;
+    static const uint32_t BACK_GROUND_COLOR = 0xfff6f6f6;
 
     static ImageAnimatorInfo g_imageAnimatorInfo_blood[30] = {
     {PNG_CHECK_TIME_IMAGE_0, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
@@ -108,7 +109,7 @@ namespace OHOS
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodDetectionViewInit is begin");
         /*初始化title*/
         InitLabelExt(titleLabel, 83, 50, 300, 35, "title", STR_CHECKON, DEFAULT_VECTOR_FONT_FILENAME, 30);
-        AddViewToRootContainer(titleLabel);
+        scrollView_->Add(titleLabel);
 
         /* -------------------------------------------------------------------------- */
         imageAnimator = new UIImageAnimatorView();
@@ -119,16 +120,16 @@ namespace OHOS
         }
         imageAnimator->SetImageAnimatorSrc(g_imageAnimatorInfo_blood, DETECTION_IMAGE_ANIMATORVIEW_SIZE, DETECTION_IMAGE_ANIMATORVIEW_SPEED);
         imageAnimator->SetRepeat(true);
-        AddViewToRootContainer(imageAnimator);
+        scrollView_->Add(imageAnimator);
 
         /* -------------------------------------------------------------------------- */
         /*初始化血氧值label*/
         // InitUILabel(Spo2Text, 83, 83, 300, 300, "bloodtext", "--", GILROY_BOLD_FONT, 140);
-        // AddViewToRootContainer(Spo2Text);
+        // scrollView_->Add(Spo2Text);
 
         /* -------------------------------------------------------------------------- */
         InitButtonExt(testButton, 93, 330, 280, 90, STOPCHECK, STR_CHECKSTOP, 30);
-        AddViewToRootContainer(testButton);
+        scrollView_->Add(testButton);
 
         /* -------------------------------------------------------------------------- */
         UIView::OnClickListener *clickLeftListener = (UIView::OnClickListener *)OHOS::BloodDetectionPresenter::GetInstance();
@@ -145,6 +146,21 @@ namespace OHOS
     void BloodDetectionView::OnStart()
     {
 
+        scrollView_ = new UIScrollView();
+        if (scrollView_ == nullptr) {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "scrollView_ new fail");
+            return;
+        }
+        scrollView_->SetScrollBlankSize(35);
+        scrollView_->SetReboundSize(50);
+        scrollView_->SetPosition(0, 0, Screen::GetInstance().GetWidth(),
+                                Screen::GetInstance().GetHeight());
+
+        scrollView_->SetTouchable(false);
+        scrollView_->SetDraggable(false);
+        scrollView_->SetStyle(STYLE_BACKGROUND_COLOR, BACK_GROUND_COLOR);
+        scrollView_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+
         if (!BloodDetectionViewInit())
         {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodDetectionView::InitBloodView fail");
@@ -156,12 +172,7 @@ namespace OHOS
             imageAnimator->Start();
         }
 
-       RootView::GetInstance()->SetDraggable(true);
-       RootView::GetInstance()->SetTouchable(true);
-       RootView::GetInstance()->SetOnDragListener(presenter_);
-
-        // 增加按键监听
-        // presenter_->SetOnKeyActListener(keyactListener);
+        AddViewToRootContainer(scrollView_);
         RootView::GetInstance()->SetOnKeyActListener(presenter_);
 
     }
index 53cbdd3..860a1dd 100644 (file)
@@ -25,7 +25,7 @@ namespace OHOS
 {
     static BloodResultView *g_pBloodResultView{nullptr};
     static const char *BLOODBACKPATH = "/user/res/Blood/beijing.bin";
-
+    static const uint32_t BACK_GROUND_COLOR = 0xfff6f6f6;
     BloodResultView::BloodResultView()
     {
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodResultView::BloodResultView");
@@ -96,7 +96,7 @@ namespace OHOS
         UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::BloodResultPresenter::GetInstance();
         checkButton->SetOnClickListener(clickListener);
 
-        AddViewToRootContainer(checkButton);
+        scrollView_->Add(checkButton);
         return true;
     }
     /***
@@ -117,9 +117,9 @@ namespace OHOS
 
         UpSPO2Text();
 
-        AddViewToRootContainer(titleLabel);
-        AddViewToRootContainer(bloodLabel);
-        AddViewToRootContainer(timeLabel);
+        scrollView_->Add(titleLabel);
+        scrollView_->Add(bloodLabel);
+        scrollView_->Add(timeLabel);
 
         return true;
     }
@@ -134,7 +134,7 @@ namespace OHOS
         background->SetPosition(0, 0, 466, 466);
         background->SetSrc(BLOODBACKPATH);
 
-        AddViewToRootContainer(background);
+        scrollView_->Add(background);
         return true;
     }
     /***
@@ -195,20 +195,27 @@ namespace OHOS
     void BloodResultView::OnStart()
     {
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodResultView::OnStart");
-        View<BloodResultPresenter>::OnStart();
+        scrollView_ = new UIScrollView();
+        if (scrollView_ == nullptr) {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "scrollView_ new fail");
+            return;
+        }
+        scrollView_->SetScrollBlankSize(35);
+        scrollView_->SetReboundSize(50);
+        scrollView_->SetPosition(0, 0, Screen::GetInstance().GetWidth(),
+                                Screen::GetInstance().GetHeight());
+
+        scrollView_->SetTouchable(false);
+        scrollView_->SetDraggable(false);
+        scrollView_->SetStyle(STYLE_BACKGROUND_COLOR, BACK_GROUND_COLOR);
+        scrollView_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
 
         if (!BloodResultViewInit())
         {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodResultView::InitBloodView fail");
         }
 
-       RootView::GetInstance()->SetDraggable(true);
-       RootView::GetInstance()->SetTouchable(true);
-       RootView::GetInstance()->SetOnDragListener(presenter_);
-
-        // 增加按键监听
-        // RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::BloodResultPresenter::GetInstance();
-        //RootView::GetInstance()->SetOnKeyActListener(keyactListener);
+        AddViewToRootContainer(scrollView_);
         RootView::GetInstance()->SetOnKeyActListener(presenter_);
     }