动画图片优化
authorluozheng <1732036298@qq.com>
Sat, 28 Mar 2026 03:53:25 +0000 (11:53 +0800)
committerluozheng <1732036298@qq.com>
Sat, 28 Mar 2026 03:53:25 +0000 (11:53 +0800)
code/sdk/application/wearable/fd272/nativeapp/nativeui/goal/include/goalother.h
code/sdk/application/wearable/fd272/nativeapp/nativeui/goal/include/goalview.h
code/sdk/application/wearable/fd272/nativeapp/nativeui/goal/src/Maingoalview.cpp
code/sdk/application/wearable/fd272/nativeapp/nativeui/goal/src/goalControlView.cpp
code/sdk/application/wearable/fd272/nativeapp/nativeui/goal/src/goalview.cpp
code/sdk/application/wearable/fd272/nativeapp/nativeui/health/BloodCardView.cpp
code/sdk/application/wearable/fd272/nativeapp/nativeui/sleep/src/SleepCardView.cpp
code/sdk/application/wearable/fd272/nativeapp/nativeui/weather/include/WeatherReportView.h
code/sdk/application/wearable/fd272/nativeapp/nativeui/weather/src/WeatherReportView.cpp

index 2ad212f..313b43a 100644 (file)
@@ -44,14 +44,6 @@ namespace OHOS
         UILabelExt *InitLabelExt(int x, int y, int w, int h, const char *text, int textfont, int lineheight);
 
     private:
-        void DumpWeatherInfo();
-        std::string WeatherImag;          // 天气图片
-        std::string Temperature;          // 温度
-        std::string WeatherDescription;   // 天气描述
-        std::string WeatherArea;          // 天气地区
-        std::string MaxandMinTemperature; // 最高与最低气温
-    private:
-
 
         UILabelExt *caloriegoalTitle{nullptr};          // 卡路里标题
         UILabelExt *mileagegoalTitle{nullptr};          // 里程标题
index 75fb64b..271fee0 100644 (file)
@@ -51,7 +51,6 @@ namespace OHOS
         UIImageView *PullUpImage{nullptr};
         UIImageAnimatorView *stepAnimatorView{nullptr}; // 走路动画
         ImageAnimatorInfo goalAnimatorInfo[20]{0};
-        const ImageInfo **goalAnimator_imageInfo{nullptr};
         bool viewInitStatus{false};
     };
 } // namespace OHOS
index 5cd57b3..3cd979c 100644 (file)
@@ -35,27 +35,32 @@ namespace OHOS
         if(goalSwipeViewList)
         {
             goalSwipeViewList->RemoveAll();
+            delete goalSwipeViewList;
+            goalSwipeViewList = nullptr;
 
-            delete goalView;
-            goalView = nullptr;
-
-            delete goalotherView;
-            goalotherView = nullptr;
+            if(goalView)
+            {
+                delete goalView;
+                goalView = nullptr;
+            }
 
-            delete goalhintView;
-            goalhintView = nullptr;
+            if(goalotherView)
+            {
+                delete goalotherView;
+                goalotherView = nullptr;
+            }
 
-            
-            delete goalSwipeViewList;
-            goalSwipeViewList = nullptr;
+            if(goalhintView)
+            {
+                delete goalhintView;
+                goalhintView = nullptr;
+            }
 
             for (int32_t i = 0; i < 3; i++)
             {
                 recordCard[i] = nullptr;
             }
         }
-        
-
     }
 
     /*
index 51a5465..5f1e157 100644 (file)
@@ -29,19 +29,15 @@ namespace OHOS
         if (viewiInitStatus == true)
         {
             RemoveAll();
+            if (goalOnSwipeListener != nullptr)
+            {
+                delete goalOnSwipeListener;
+                goalOnSwipeListener = nullptr;
+            }
             if (maingoalView != nullptr)
             {
-                if (goalOnSwipeListener != nullptr)
-                {
-                    delete goalOnSwipeListener;
-                    goalOnSwipeListener = nullptr;
-                }
-                
-                if (maingoalView != nullptr)
-                {
-                    delete maingoalView;
-                    maingoalView = nullptr;
-                }
+                delete maingoalView;
+                maingoalView = nullptr;
             }
         }
     }
index a4d8c4d..ba1269b 100644 (file)
@@ -17,10 +17,32 @@ namespace OHOS
     static constexpr int16_t PULLUP_ANIMATOR_VIEW_NUM_FRAMES = 70;
     static constexpr int16_t PULLUP_ANIMATOR_VIEW_TIME = 100;
 
-    static constexpr const char *PullUpPaths = "/user/res/weather/PullUp/PullUp_";
 
     static constexpr const char *stepPaths = "/user/res/step/";
 
+    const char *stepPathsArray[] = {
+     "/user/res/step/1.bin",
+     "/user/res/step/2.bin",
+     "/user/res/step/3.bin",
+     "/user/res/step/4.bin",
+     "/user/res/step/5.bin",
+     "/user/res/step/6.bin",
+     "/user/res/step/7.bin",
+     "/user/res/step/8.bin",
+     "/user/res/step/9.bin",
+     "/user/res/step/10.bin",
+     "/user/res/step/11.bin",
+     "/user/res/step/12.bin",
+     "/user/res/step/13.bin",
+     "/user/res/step/14.bin",
+     "/user/res/step/15.bin",
+     "/user/res/step/16.bin",
+     "/user/res/step/17.bin",
+     "/user/res/step/18.bin",
+     "/user/res/step/19.bin",
+     "/user/res/step/20.bin",
+    };
+
     static GoalView *g_pgoalView{nullptr};
     GoalView::GoalView()
     {
@@ -86,8 +108,6 @@ namespace OHOS
             delete PullUpImage;
             PullUpImage = nullptr;  
         }
-        ImageCacheManager::GetInstance().UnloadSingleRes("/user/res/step/step_b.bin");
-        FreeImageInfoArray(goalAnimator_imageInfo, stepPaths, 20);
         }
 
     GoalView *GoalView::GetInstance()
@@ -195,7 +215,6 @@ namespace OHOS
         circleProgress1_->SetBackgroundImagePosition(36, 26);
         circleProgress1_->SetCapType(CAP_ROUND);
         /*----------------------------------------------------------------------------- */
-        goalAnimator_imageInfo = CreateImageInfoArray(stepPaths, 20);
         if (stepAnimatorView == nullptr)
         {
             stepAnimatorView = new UIImageAnimatorView();
@@ -206,8 +225,8 @@ namespace OHOS
             }
             for (uint8_t i = 0; i < 20; i++)
             {
-                goalAnimatorInfo[i].imageInfo = goalAnimator_imageInfo[i];
-                goalAnimatorInfo[i].imageType = IMG_SRC_IMAGE_INFO;
+                goalAnimatorInfo[i].imagePath = stepPathsArray[i];
+                goalAnimatorInfo[i].imageType = IMG_SRC_FILE_PATH;
                 goalAnimatorInfo[i].pos.x = 193;
                 goalAnimatorInfo[i].pos.y = 90;
                 goalAnimatorInfo[i].width = 100;
index 1cd5833..c7d980d 100644 (file)
@@ -128,9 +128,10 @@ namespace OHOS
 \r
         background = new UIImageView();\r
 \r
-        background->SetPosition(0, 0);   // widget's left position and top position\r
-        background->Resize(466, 466);    // widget's width and height\r
-        background->SetViewId("image1"); // Set style\r
+        background->SetPosition(0, 0);   \r
+        background->Resize(466, 466);    \r
+        background->SetViewId("image1");\r
+        background->SetSrc("/user/res/Blood/beijing.bin");\r
 \r
         Add(background);\r
         return true;\r
@@ -163,7 +164,7 @@ namespace OHOS
      */\r
     void BloodCardView::DeInit()\r
     {\r
-        UnLoadBloodImageRes();\r
+        // UnLoadBloodImageRes();\r
         RemoveAll();\r
         if (background != nullptr)\r
         {\r
@@ -219,19 +220,19 @@ namespace OHOS
 \r
     void BloodCardView::PreLoad(void)\r
     {\r
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodCardView::PreLoad");\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodCardView::PreLoad");\r
         if (!viewiInitStatus)\r
         {\r
             InitView();\r
             viewiInitStatus = true;\r
         }\r
-        PreLoadBloodImageRes();\r
+        // PreLoadBloodImageRes();\r
     }\r
 \r
     void BloodCardView::UnLoad(void)\r
     {\r
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodCardView::UnLoad");\r
-        UnLoadBloodImageRes();\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodCardView::UnLoad");\r
+        // UnLoadBloodImageRes();\r
     }\r
     /* -------------------------------------------------------------------------- */\r
 }\r
index 97ce35c..780d285 100644 (file)
@@ -87,7 +87,7 @@ namespace OHOS
     }\r
     void SleepCardView::PreLoad(void)\r
     {\r
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SleepCardView::PreLoad viewiInitStatus %d",viewiInitStatus);\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SleepCardView::PreLoad viewiInitStatus %d",viewiInitStatus);\r
         if (!viewiInitStatus)\r
         {\r
             InitView();\r
@@ -97,7 +97,7 @@ namespace OHOS
 \r
     void SleepCardView::UnLoad(void)\r
     {\r
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SleepCardView::UnLoad");\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SleepCardView::UnLoad");\r
     }\r
 \r
 }
\ No newline at end of file
index 4e6940f..b2fef58 100644 (file)
@@ -75,9 +75,6 @@ namespace OHOS
         UIImageAnimatorView *WindSpeedImageAnimatorView{nullptr}; // 风速动画\r
         UIImageAnimatorView *HumidityImageAnimatorView{nullptr};  // 湿度动画\r
 \r
-        const ImageInfo **UVPathsArray{nullptr};\r
-        const ImageInfo **WindSpeedPathsArray{nullptr};\r
-        const ImageInfo **HumidityPathsArray{nullptr};\r
         bool viewInitStatus{false};\r
     };\r
 } // namespace OHOS\r
index 54e0ba0..db849be 100644 (file)
@@ -27,12 +27,85 @@ namespace OHOS
     static constexpr int16_t HUMIDITY_IMAGE_ANIMATOR_VIEW_NUM_FRAMES = 20; // 图片帧数\r
     static ImageAnimatorInfo HumidityimageAnimatorInfo[HUMIDITY_IMAGE_ANIMATOR_VIEW_NUM_FRAMES];\r
 \r
-    static constexpr const char *UVPaths = "/user/res/weather/weather60x60gif/UV/";\r
-    static constexpr const char *WindSpeedPaths = "/user/res/weather/weather60x60gif/WindSpeed/";\r
-    static constexpr const char *HumidityPaths = "/user/res/weather/weather60x60gif/Humidity/";\r
+    const char *UVPathsArray[] = {\r
+        "/user/res/weather/weather60x60gif/UV/1.bin",\r
+        "/user/res/weather/weather60x60gif/UV/2.bin",\r
+        "/user/res/weather/weather60x60gif/UV/3.bin",\r
+        "/user/res/weather/weather60x60gif/UV/4.bin",\r
+        "/user/res/weather/weather60x60gif/UV/5.bin",\r
+        "/user/res/weather/weather60x60gif/UV/6.bin",\r
+        "/user/res/weather/weather60x60gif/UV/7.bin",\r
+        "/user/res/weather/weather60x60gif/UV/8.bin",\r
+        "/user/res/weather/weather60x60gif/UV/9.bin",\r
+        "/user/res/weather/weather60x60gif/UV/10.bin",\r
+        "/user/res/weather/weather60x60gif/UV/11.bin",\r
+        "/user/res/weather/weather60x60gif/UV/12.bin",\r
+        "/user/res/weather/weather60x60gif/UV/13.bin",\r
+        "/user/res/weather/weather60x60gif/UV/14.bin",\r
+        "/user/res/weather/weather60x60gif/UV/15.bin",\r
+        "/user/res/weather/weather60x60gif/UV/16.bin",\r
+        "/user/res/weather/weather60x60gif/UV/17.bin",\r
+        "/user/res/weather/weather60x60gif/UV/18.bin",\r
+        "/user/res/weather/weather60x60gif/UV/19.bin",\r
+        "/user/res/weather/weather60x60gif/UV/20.bin",\r
+        "/user/res/weather/weather60x60gif/UV/21.bin",\r
+        "/user/res/weather/weather60x60gif/UV/22.bin",\r
+        "/user/res/weather/weather60x60gif/UV/23.bin",\r
+        "/user/res/weather/weather60x60gif/UV/24.bin",\r
+    };\r
+\r
+    const char *WindSpeedPathsArray[] ={\r
+        "/user/res/weather/weather60x60gif/WindSpeed/1.bin",\r
+        "/user/res/weather/weather60x60gif/WindSpeed/2.bin",\r
+        "/user/res/weather/weather60x60gif/WindSpeed/3.bin",\r
+        "/user/res/weather/weather60x60gif/WindSpeed/4.bin",\r
+        "/user/res/weather/weather60x60gif/WindSpeed/5.bin",\r
+        "/user/res/weather/weather60x60gif/WindSpeed/6.bin",\r
+        "/user/res/weather/weather60x60gif/WindSpeed/7.bin",\r
+        "/user/res/weather/weather60x60gif/WindSpeed/8.bin",\r
+        "/user/res/weather/weather60x60gif/WindSpeed/9.bin",\r
+        "/user/res/weather/weather60x60gif/WindSpeed/10.bin",\r
+        "/user/res/weather/weather60x60gif/WindSpeed/11.bin",\r
+        "/user/res/weather/weather60x60gif/WindSpeed/12.bin",\r
+        "/user/res/weather/weather60x60gif/WindSpeed/13.bin",\r
+        "/user/res/weather/weather60x60gif/WindSpeed/14.bin",\r
+        "/user/res/weather/weather60x60gif/WindSpeed/15.bin",\r
+        "/user/res/weather/weather60x60gif/WindSpeed/16.bin",\r
+        "/user/res/weather/weather60x60gif/WindSpeed/17.bin",\r
+        "/user/res/weather/weather60x60gif/WindSpeed/18.bin",\r
+        "/user/res/weather/weather60x60gif/WindSpeed/19.bin",\r
+        "/user/res/weather/weather60x60gif/WindSpeed/20.bin",\r
+        "/user/res/weather/weather60x60gif/WindSpeed/21.bin",\r
+        "/user/res/weather/weather60x60gif/WindSpeed/22.bin",\r
+        "/user/res/weather/weather60x60gif/WindSpeed/23.bin",\r
+        "/user/res/weather/weather60x60gif/WindSpeed/24.bin",\r
+    }; \r
+\r
+    const char *HumidityPathsArray[] = {\r
+        "/user/res/weather/weather60x60gif/Humidity/1.bin",\r
+        "/user/res/weather/weather60x60gif/Humidity/2.bin",\r
+        "/user/res/weather/weather60x60gif/Humidity/3.bin",\r
+        "/user/res/weather/weather60x60gif/Humidity/4.bin",\r
+        "/user/res/weather/weather60x60gif/Humidity/5.bin",\r
+        "/user/res/weather/weather60x60gif/Humidity/6.bin",\r
+        "/user/res/weather/weather60x60gif/Humidity/7.bin",\r
+        "/user/res/weather/weather60x60gif/Humidity/8.bin",\r
+        "/user/res/weather/weather60x60gif/Humidity/9.bin",\r
+        "/user/res/weather/weather60x60gif/Humidity/10.bin",\r
+        "/user/res/weather/weather60x60gif/Humidity/11.bin",\r
+        "/user/res/weather/weather60x60gif/Humidity/12.bin",\r
+        "/user/res/weather/weather60x60gif/Humidity/13.bin",\r
+        "/user/res/weather/weather60x60gif/Humidity/14.bin",\r
+        "/user/res/weather/weather60x60gif/Humidity/15.bin",\r
+        "/user/res/weather/weather60x60gif/Humidity/16.bin",\r
+        "/user/res/weather/weather60x60gif/Humidity/17.bin",\r
+        "/user/res/weather/weather60x60gif/Humidity/18.bin",\r
+        "/user/res/weather/weather60x60gif/Humidity/19.bin",\r
+        "/user/res/weather/weather60x60gif/Humidity/20.bin",\r
+    };\r
 \r
-    static WeatherReportView *g_pWeatherReportView{nullptr};\r
 \r
+    static WeatherReportView *g_pWeatherReportView{nullptr};\r
     WeatherReportView::WeatherReportView()\r
     {\r
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " WeatherReportView::WeatherReportView");\r
@@ -99,15 +172,6 @@ namespace OHOS
             delete HumidityImageAnimatorView;\r
             HumidityImageAnimatorView = nullptr;\r
 \r
-            // FreeImagePathsArray(UVPathsArray, UV_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);\r
-\r
-            // FreeImagePathsArray(WindSpeedPathsArray, WINDSPEED_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);\r
-\r
-            // FreeImagePathsArray(HumidityPathsArray, HUMIDITY_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);\r
-\r
-            FreeImageInfoArray(UVPathsArray, UVPaths, UV_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);\r
-            FreeImageInfoArray(WindSpeedPathsArray, WindSpeedPaths, WINDSPEED_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);\r
-            FreeImageInfoArray(HumidityPathsArray, HumidityPaths, HUMIDITY_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);\r
         }\r
     }\r
 \r
@@ -260,7 +324,6 @@ namespace OHOS
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherReportView::WeatherReportViewImageAnimatorViewInit");\r
 \r
         /* ----------------------------- UVImageAnimatorView---------------------------- */\r
-        UVPathsArray = CreateImageInfoArray(UVPaths, UV_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);\r
         if (UVImageAnimatorView == nullptr)\r
         {\r
             UVImageAnimatorView = new UIImageAnimatorView();\r
@@ -271,10 +334,8 @@ namespace OHOS
             }\r
             for (uint8_t i = 0; i < UV_IMAGE_ANIMATOR_VIEW_NUM_FRAMES; i++)\r
             {\r
-                // UVimageAnimatorInfo[i].imagePath = UVPathsArray[i];\r
-                // UVimageAnimatorInfo[i].imageType = IMG_SRC_FILE_PATH;\r
-                UVimageAnimatorInfo[i].imageInfo = UVPathsArray[i];\r
-                UVimageAnimatorInfo[i].imageType = IMG_SRC_IMAGE_INFO;\r
+                UVimageAnimatorInfo[i].imagePath = UVPathsArray[i];\r
+                UVimageAnimatorInfo[i].imageType = IMG_SRC_FILE_PATH;\r
                 UVimageAnimatorInfo[i].pos.x = UV_IMAGE_ANIMATOR_VIEW_X;\r
                 UVimageAnimatorInfo[i].pos.y = UV_IMAGE_ANIMATOR_VIEW_Y;\r
                 UVimageAnimatorInfo[i].width = UV_IMAGE_ANIMATOR_VIEW_W;\r
@@ -288,7 +349,6 @@ namespace OHOS
             UVImageAnimatorView->Start();\r
         }\r
         /* ----------------------- WindSpeedImageAnimatorView ----------------------- */\r
-        WindSpeedPathsArray = CreateImageInfoArray(WindSpeedPaths, WINDSPEED_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);\r
         if (WindSpeedImageAnimatorView == nullptr)\r
         {\r
             WindSpeedImageAnimatorView = new UIImageAnimatorView();\r
@@ -299,10 +359,8 @@ namespace OHOS
             }\r
             for (uint8_t i = 0; i < WINDSPEED_IMAGE_ANIMATOR_VIEW_NUM_FRAMES; i++)\r
             {\r
-                // WindSpeedimageAnimatorInfo[i].imagePath = WindSpeedPathsArray[i];\r
-                // WindSpeedimageAnimatorInfo[i].imageType = IMG_SRC_FILE_PATH;\r
-                WindSpeedimageAnimatorInfo[i].imageInfo = WindSpeedPathsArray[i];\r
-                WindSpeedimageAnimatorInfo[i].imageType = IMG_SRC_IMAGE_INFO;\r
+                WindSpeedimageAnimatorInfo[i].imagePath = WindSpeedPathsArray[i];\r
+                WindSpeedimageAnimatorInfo[i].imageType = IMG_SRC_FILE_PATH;\r
                 WindSpeedimageAnimatorInfo[i].pos.x = WINDSPEED_IMAGE_ANIMATOR_VIEW_X;\r
                 WindSpeedimageAnimatorInfo[i].pos.y = UV_IMAGE_ANIMATOR_VIEW_Y;\r
                 WindSpeedimageAnimatorInfo[i].width = UV_IMAGE_ANIMATOR_VIEW_W;\r
@@ -316,7 +374,6 @@ namespace OHOS
             WindSpeedImageAnimatorView->Start();\r
         }\r
         /* ------------------------ HumidityImageAnimatorView ----------------------- */\r
-        HumidityPathsArray = CreateImageInfoArray(HumidityPaths, HUMIDITY_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);\r
         if (HumidityImageAnimatorView == nullptr)\r
         {\r
             HumidityImageAnimatorView = new UIImageAnimatorView();\r
@@ -327,10 +384,8 @@ namespace OHOS
             }\r
             for (uint8_t i = 0; i < HUMIDITY_IMAGE_ANIMATOR_VIEW_NUM_FRAMES; i++)\r
             {\r
-                // HumidityimageAnimatorInfo[i].imagePath = HumidityPathsArray[i];\r
-                // HumidityimageAnimatorInfo[i].imageType = IMG_SRC_FILE_PATH;\r
-                HumidityimageAnimatorInfo[i].imageInfo = HumidityPathsArray[i];\r
-                HumidityimageAnimatorInfo[i].imageType = IMG_SRC_IMAGE_INFO;\r
+                HumidityimageAnimatorInfo[i].imagePath = HumidityPathsArray[i];\r
+                HumidityimageAnimatorInfo[i].imageType = IMG_SRC_FILE_PATH;\r
                 HumidityimageAnimatorInfo[i].pos.x = HUMIDITY_IMAGE_ANIMATOR_VIEW_X;\r
                 HumidityimageAnimatorInfo[i].pos.y = UV_IMAGE_ANIMATOR_VIEW_Y;\r
                 HumidityimageAnimatorInfo[i].width = UV_IMAGE_ANIMATOR_VIEW_W;\r