统一动画数组生成以及释放函数。
authorCaisking <3449750381@qq.com>
Fri, 30 Aug 2024 12:01:17 +0000 (20:01 +0800)
committerCaisking <3449750381@qq.com>
Fri, 30 Aug 2024 12:01:17 +0000 (20:01 +0800)
29 files changed:
code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.cpp
code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.h
code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceConnectingView.h
code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceListeningView.h
code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceThinkingView.h
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceConnectingView.cpp
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceListeningView.cpp
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceThinkingView.cpp
code/sdk/application/wearable/fd230app/nativeui/findphone/include/FindPhoneView.h
code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhoneView.cpp
code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartChartView.cpp
code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/ShutDownImageAnimatorView.h
code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/ShutDownImageAnimatorView.cpp
code/sdk/application/wearable/fd230app/nativeui/respiratorytraining/include/RespiratoryTrainingView.h
code/sdk/application/wearable/fd230app/nativeui/respiratorytraining/src/RespiratoryTrainingView.cpp
code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveElePresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepTimeView.h
code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepControlPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/takephotos/include/TakephotosView.h
code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosView.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardView.h
code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardView.cpp
code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherReportView.h
code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherView.h
code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherReportView.cpp
code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherView.cpp
code/sdk/application/wearable/service/msg_center/include/notify/pairing_notification.h
code/sdk/application/wearable/service/msg_center/src/notify/charge_notification.cpp
code/sdk/application/wearable/service/msg_center/src/notify/pairing_notification.cpp

index 6ef2228..d16a4ff 100644 (file)
@@ -1,3 +1,9 @@
+/***
+ * @Date: 2024-08-29 19:24:30
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-30 18:57:46
+ * @FilePath: /FD230/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.cpp
+ */
 /***
  * @Date: 2024-05-10 10:27:30
  * @LastEditors: Caisking 3449750381@qq.com
@@ -426,7 +432,15 @@ namespace OHOS
         imageView->SetPosition(left, top);
         imageView->SetAutoEnable(true);
         imageView->SetViewId(viewId);
-        imageView->SetSrc(imagePath);
+
+        ImageInfo *image = ImageCacheManager::GetInstance().LoadSingleRes(imagePath, false);
+        if (image == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LoadAllDialFromRam loadimage %s fail",
+                          imagePath);
+            return false;
+        }
+        imageView->SetSrc(image);
         return true;
     }
     /*带默认参数的初始化label*/
@@ -438,23 +452,56 @@ namespace OHOS
     /* -------------------------------------------------------------------------- */
     /**
      * 创建包含图片文件路径的数组
-     * @param  basePath  包含图片文件的基本路径
-     * @param  fileExtension  图片文件的扩展名
-     * @param  numImages  图片文件的数量
-     * @return  返回包含图片文件路径的数组
+     * @param basePath 包含图片文件的基本路径
+     * @param fileExtension 图片文件的扩展名
+     * @param numImages 图片文件的数量
+     * @return 返回包含图片文件路径的数组
      */
-    const char **CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages)
+    const char **CreateImagePathsArray(const char *basePath, int numImages, const char *fileExtension)
     {
-        const char **imagePaths = new const char *[numImages];
+        const char **imagePaths = static_cast<const char **>(UIMalloc(numImages * sizeof(const char *)));
+        if (imagePaths == nullptr)
+        {
+            return nullptr; // 检查内存分配是否成功
+        }
+
         char buffer[256];
         for (int i = 0; i < numImages; i++)
         {
             snprintf(buffer, sizeof(buffer), "%s/%d.%s", basePath, i + 1, fileExtension);
-            imagePaths[i] = strdup(buffer);
+            imagePaths[i] = static_cast<char *>(UIMalloc(strlen(buffer) + 1)); // 分配内存来存储每个路径
+            if (imagePaths[i] == nullptr)
+            {
+                // 如果分配失败,释放已经分配的内存并返回 nullptr
+                for (int j = 0; j < i; j++)
+                {
+                    UIFree(const_cast<char *>(imagePaths[j])); // 释放已分配的内存
+                }
+                UIFree(imagePaths);
+                return nullptr;
+            }
+            strcpy(const_cast<char *>(imagePaths[i]), buffer); // 使用 strcpy 拷贝字符串
         }
         return imagePaths;
     }
 
+    /**
+     * 释放创建的图片路径数组
+     * @param imagePaths 包含图片路径的数组
+     * @param numImages 图片文件的数量
+     */
+    void FreeImagePathsArray(const char **imagePaths, int numImages)
+    {
+        if (imagePaths != nullptr)
+        {
+            for (int i = 0; i < numImages; i++)
+            {
+                UIFree(const_cast<char *>(imagePaths[i])); // 释放每个路径字符串
+            }
+            UIFree(const_cast<const char **>(imagePaths)); // 释放整个数组
+        }
+    }
+
     /*解析动画资源数组 imageche*/
     std::vector<ImageInfo *> AnalysisArray(const char *filename, uint32_t startId, uint32_t lastId)
     {
index a496743..aa7d265 100644 (file)
@@ -1,27 +1,4 @@
-/*** 
- * @Date: 2024-07-29 10:31:48
- * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-08-21 16:17:07
- * @FilePath: /FD230/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.h
- */
-/***
- * @Date: 2024-05-30 15:59:37
- * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-07-29 14:19:44
- * @FilePath: /FD230/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.h
- */
-/***
- * @Date: 2024-05-30 15:59:37
- * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-06-27 15:04:48
- * @FilePath: /FD230/code/sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.h
- */
-/***
- * @Date: 2024-05-10 10:27:30
- * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-05-10 11:04:28
- * @FilePath: /sdk/application/wearable/CustomUIComponentTool/uicomponents/UIComponents.h
- */
+
 
 #ifndef UICOMPONENTS_H
 #define UICOMPONENTS_H
@@ -29,6 +6,8 @@
 #include "BaseView.h"
 #include "View.h"
 #include <string>
+
+// UI 组件
 #include "components/ui_scroll_view.h"
 #include "components/ui_view_group.h"
 #include "components/ui_label.h"
 #include "components/ui_chart.h"
 #include "components/ui_list.h"
 #include "components/icon_adapter.h"
+#include "components/ui_card_page.h"
+
+// 日志和类型定义
 #include "wearable_log.h"
 #include "ohos_types.h"
-#include "components/ui_card_page.h"
+#include "common/image_cache_manager.h"
+
 #ifdef FD230
 #include "traing/include/TraingModel.h"
 #include "ui_resource_string.h"
 #endif
-#include "common/image_cache_manager.h"
 
 namespace OHOS
 {
-    /*初始化label[可使用text]*/
+
+    // 初始化和创建 UI 组件
+    // =======================
+    /* 初始化 UILabel */
     bool InitLabel(UILabelExt *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize);
-    /*初始化label[可使用text]*/
     bool InitUILabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize);
-    /*初始化button*/
+
+    /* 初始化 UIButton */
     bool InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId);
-    /*初始化labelbutton*/
+
+    /* 初始化 UILabelButton */
     bool InitLabelButton(UILabelButton *&button, int left, int top, int width, int height, const char *viewId, const char *text, int fontSize);
-    /*初始化image*/
+
+    /* 初始化 UIImageView */
     bool InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath);
-    /*生成动画资源数组*/
-    const char **CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages);
-    /*自适应label*/
+
+    /* 初始化动画资源 */
+    void InitImageAnimatorSource(UIImageAnimatorView *&imageAnimator, const std::vector<std::string> &imagePaths, int numFrames, int left, int top, int width, int height, const char *viewId, int time);
+
+    /* 自适应 UILabel */
     bool InitLabelAdapt(UILabelExt *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize);
+
+    // 默认参数的 UILabel 初始化
+    void InitLabelDefault(UILabelExt *&label, int x, int y, int width, int height, const char *viewId, const char *text, int fontSize = 30, const char *fontName = DEFAULT_VECTOR_FONT_FILENAME);
+
+    /*生成动画资源数组*/
+    const char **CreateImagePathsArray(const char *basePath, int numImages, const char *fileExtension = "bin");
+
+    /*释放动画资源数组*/
+    void FreeImagePathsArray(const char **imagePaths, int numImages);
+
     /*初始化动画资源*/
     void InitImageAnimatorSource(UIImageAnimatorView *&imageAnimator, const char **imagePaths, int numFrames, int left, int top, int width, int height, const char *viewId, int time);
-    /*InitLabel[默认参数]*/
-    void InitLabelDefault(UILabelExt *&label, int x, int y, int width, int height, const char *viewId, const char *text, int fontSize = 30, const char *fontName = DEFAULT_VECTOR_FONT_FILENAME);
+
 #ifdef FD230
-    /*初始化labelExt*/
+    // 扩展功能
+    // =======================
     bool InitLabelExt(UILabelExt *&label, int left, int top, int width, int height, const char *viewId, UIResourceTextId id, const char *fontName, int fontSize);
     bool InitButtonExt(UILabelButtonExt *&button, int left, int top, int width, int height, const char *viewId, UIResourceTextId id, int fontSize);
-    /*通用替换*/
+
+    // 更新 Label 的文本
     std::string UpdateLabelText(UILabelExt *&label, const std::string &newText, UIResourceTextId id);
-    /*更新label的数字*/
     std::string UpdateLabel(UILabelExt *&label, int num, UIResourceTextId id);
-    /*更新label的字符串*/
     std::string UpdateLabel(UILabelExt *&label, const std::string &updatestr, UIResourceTextId id);
-    /*通过labelext获取Id设置label*/
+
+    // 设置 Label ID
     void SetLabelId(UILabel *&label, UIResourceTextId id);
-#endif
-    /*解析动画资源数组 imageche*/
-    std::vector<ImageInfo *> AnalysisArray(const char *filename, uint32_t startId, uint32_t lastId);
-}
+#endif // FD230
+
+} // namespace OHOS
+
 #endif // UICOMPONENTS_H
\ No newline at end of file
index 5be7c8a..dfeb450 100644 (file)
@@ -1,3 +1,9 @@
+/*** 
+ * @Date: 2024-08-19 19:20:08
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-30 18:57:30
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceConnectingView.h
+ */
 /*
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-08-03 11:09:56
@@ -58,8 +64,6 @@ namespace OHOS
         UIScrollView *CreateAiVoiceConnectingView(void);
         UIScrollView *CreateAiVoiceConnectingView(uint8_t);
     private:
-        const char **CreateImagePathsArray(const char *basePath, const int numImages, const char *fileExtension = "bin");
-        void FreeImagePathsArray(const char **imagePaths, const int numImages);
         UIImageAnimatorView *connectingImageAnimatorInit(ImageAnimatorConfig &imageanimatorconfig);
         UILabelExt *AiVoiceConnectingViewLabelInit(LabelConfig &labelconfig);
         UIButton *AiVoiceConnectingViewButtonInit(ButtonConfig &buttonconfig);
index 9b02ffd..c897043 100644 (file)
@@ -1,3 +1,9 @@
+/*** 
+ * @Date: 2024-06-26 16:59:51
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-30 18:57:36
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceListeningView.h
+ */
 /*
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-06-22 16:46:26
@@ -67,8 +73,6 @@ namespace OHOS
 
     private:
         void ClearAll(void);
-        const char **CreateImagePathsArray(const char *basePath, const int numImages, const char *fileExtension = "bin");
-        void FreeImagePathsArray(const char **imagePaths, const int numImages);
         UILabelExt *AivoiceListeningLabelInit(LabelConfig &labelconfig);
         UIButton *AivoiceListeningButtonInit(ButtonConfig &buttonconfig);
         UIImageAnimatorView *AivoiceListeningImageAnimatorInit(ImageAnimatorConfig &imageanimatorconfig);
index 93a223e..cad3da1 100644 (file)
@@ -67,8 +67,6 @@ namespace OHOS
 
     private:
         void ClearAll(void);
-        const char **CreateImagePathsArray(const char *basePath, const int numImages, const char *fileExtension = "bin");
-        void FreeImagePathsArray(const char **imagePaths, const int numImages);
         UILabelExt *AivoiceThinkingLabelInit(LabelConfig &labelconfig);
         UIButton *AivoiceThinkingButtonInit(ButtonConfig &buttonconfig);
         UIImageAnimatorView *AivoiceThinkingImageAnimatorInit(ImageAnimatorConfig &imageanimatorconfig);
index 8e8d88f..2df64ab 100644 (file)
@@ -10,6 +10,7 @@
 #include "wearable_log.h"
 #include "ui_resource_string.h"
 #include "common/image_cache_manager.h"
+#include "uicomponents/UIComponents.h"
 
 namespace OHOS
 {
@@ -106,34 +107,6 @@ namespace OHOS
         return button;
     }
 
-    const char **AiVoiceConnectingView::CreateImagePathsArray(const char *basePath, const int numImages, const char *fileExtension)
-    {
-        const char **imagePaths = new const char *[numImages];
-        if (imagePaths == nullptr)
-        {
-            return nullptr;
-        }
-
-        char buffer[256];
-        for (int i = 0; i < numImages; i++)
-        {
-            snprintf(buffer, sizeof(buffer), "%s%d.%s", basePath, i + 1, fileExtension);
-            imagePaths[i] = strdup(buffer);
-            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " imagePaths[%d] = %s", i, imagePaths[i]);
-        }
-        return imagePaths;
-    }
-
-    void AiVoiceConnectingView::FreeImagePathsArray(const char **imagePaths, const int numImages)
-    {
-        for (int i = 0; i < numImages; i++)
-        {
-            // ImageCacheManager::GetInstance().UnloadSingleRes(imagePaths[i]);
-            delete imagePaths[i];
-            imagePaths[i] = nullptr;
-        }
-    }
-
     UIImageAnimatorView *AiVoiceConnectingView::connectingImageAnimatorInit(ImageAnimatorConfig &imageanimatorconfig)
     {
         UIImageAnimatorView *animatorView = new UIImageAnimatorView();
index 808c30d..237a342 100644 (file)
@@ -10,6 +10,7 @@
 #include "wearable_log.h"
 #include "ui_resource_string.h"
 #include <UiConfig.h>
+#include "uicomponents/UIComponents.h"
 // #include "common/image_cache_manager.h"
 namespace OHOS
 {
@@ -73,34 +74,6 @@ namespace OHOS
         }
     }
 
-    const char **AivoiceListeningView::CreateImagePathsArray(const char *basePath, const int numImages, const char *fileExtension)
-    {
-        const char **imagePaths = new const char *[numImages];
-        if (imagePaths == nullptr)
-        {
-            return nullptr;
-        }
-
-        char buffer[256];
-        for (int i = 0; i < numImages; i++)
-        {
-            snprintf(buffer, sizeof(buffer), "%s%d.%s", basePath, i + 1, fileExtension);
-            imagePaths[i] = strdup(buffer);
-            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " imagePaths[%d] = %s", i, imagePaths[i]);
-        }
-        return imagePaths;
-    }
-
-    void AivoiceListeningView::FreeImagePathsArray(const char **imagePaths, const int numImages)
-    {
-        for (int i = 0; i < numImages; i++)
-        {
-            // ImageCacheManager::GetInstance().UnloadSingleRes(imagePaths[i]);
-            delete imagePaths[i];
-            imagePaths[i] = nullptr;
-        }
-    }
-
     UILabelExt *AivoiceListeningView::AivoiceListeningLabelInit(LabelConfig &labelconfig)
     {
         UILabelExt *label = new UILabelExt();
index 5275510..4065451 100644 (file)
@@ -10,6 +10,7 @@
 #include "wearable_log.h"
 #include "ui_resource_string.h"
 #include <UiConfig.h>
+#include "uicomponents/UIComponents.h"
 // #include "common/image_cache_manager.h"
 namespace OHOS
 {
@@ -73,34 +74,6 @@ namespace OHOS
         }
     }
 
-    const char **AivoiceThinkingView::CreateImagePathsArray(const char *basePath, const int numImages, const char *fileExtension)
-    {
-        const char **imagePaths = new const char *[numImages];
-        if (imagePaths == nullptr)
-        {
-            return nullptr;
-        }
-
-        char buffer[256];
-        for (int i = 0; i < numImages; i++)
-        {
-            snprintf(buffer, sizeof(buffer), "%s%d.%s", basePath, i + 1, fileExtension);
-            imagePaths[i] = strdup(buffer);
-            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " imagePaths[%d] = %s", i, imagePaths[i]);
-        }
-        return imagePaths;
-    }
-
-    void AivoiceThinkingView::FreeImagePathsArray(const char **imagePaths, const int numImages)
-    {
-        for (int i = 0; i < numImages; i++)
-        {
-            // ImageCacheManager::GetInstance().UnloadSingleRes(imagePaths[i]);
-            delete imagePaths[i];
-            imagePaths[i] = nullptr;
-        }
-    }
-
     UILabelExt *AivoiceThinkingView::AivoiceThinkingLabelInit(LabelConfig &labelconfig)
     {
         UILabelExt *label = new UILabelExt();
index c033ea4..e6cb391 100644 (file)
@@ -35,8 +35,6 @@ namespace OHOS
         void FindPhoneViewInit_BlueToothConnected(void);
         void FindPhoneViewInit_BlueToothDisConnected(void);
         void ClearAll();
-        const char **CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages);
-        void FreeImagePathsArray(const char **imagePaths, const int numImages);
         UIViewGroup *FindPhoneGroupView = nullptr;
         UILabelExt *FindPhoneTitleLabel = nullptr;
         UILabelExt *FindPhoneLabel = nullptr;
index 541f80f..f01084c 100644 (file)
@@ -1,3 +1,9 @@
+/***
+ * @Date: 2024-06-19 19:25:22
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-30 19:23:15
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhoneView.cpp
+ */
 /*
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-03-27 10:47:46
@@ -13,6 +19,7 @@
 #include "bletest.h"
 #include "bleEvent.h"
 #include "ui_resource_string.h"
+#include "uicomponents/UIComponents.h"
 namespace OHOS
 {
 
@@ -82,33 +89,6 @@ namespace OHOS
         }
     }
 
-    const char **FindPhoneView::CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages)
-    {
-        const char **imagePaths = new const char *[numImages];
-        char buffer[256];
-        for (int i = 0; i < numImages; i++)
-        {
-            snprintf(buffer, sizeof(buffer), "%s%d.%s", basePath, i + 1, fileExtension);
-            imagePaths[i] = strdup(buffer);
-            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " imagePaths[%d] = %s", i, imagePaths[i]);
-        }
-        return imagePaths;
-    }
-
-    /*
-     * @brief: 释放图片路径数组指针
-     * @param {char} imagePaths 图片路径数组
-     * @param {int} numImages 图片数量
-     */
-    void FindPhoneView::FreeImagePathsArray(const char **imagePaths, const int numImages)
-    {
-        for (int i = 0; i < numImages; i++)
-        {
-            delete imagePaths[i];
-            imagePaths[i] = nullptr;
-        }
-    }
-
     /*蓝牙如果是未连接状态*/
     void FindPhoneView::FindPhoneViewInit_BlueToothDisConnected(void)
     {
@@ -134,7 +114,7 @@ namespace OHOS
             FindPhoneTitleLabel->SetPosition(133, 51, 200, 40);
             FindPhoneTitleLabel->SetStyle(STYLE_TEXT_FONT, 30);
             FindPhoneTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
-            //FindPhoneTitleLabel->SetText("查找手机");
+            // FindPhoneTitleLabel->SetText("查找手机");
             FindPhoneTitleLabel->SetTextId(STR_FIND_PHONE);
             FindPhoneTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
             FindPhoneTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
@@ -158,7 +138,7 @@ namespace OHOS
             FindPhoneLabel->SetPosition(33, 270, 400, 40);
             FindPhoneLabel->SetStyle(STYLE_TEXT_FONT, 30);
             FindPhoneLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
-            //FindPhoneLabel->SetText("蓝牙未连接");
+            // FindPhoneLabel->SetText("蓝牙未连接");
             FindPhoneLabel->SetTextId(STR_BLUETOOTH_DISCONNECTED);
             FindPhoneLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
             FindPhoneLabel->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff));
@@ -174,7 +154,7 @@ namespace OHOS
             FindPhoneLabelButton->SetPosition(0, 366, 466, 100);
             FindPhoneLabelButton->SetViewId(FINDPHONE_LABELBUTTON);
             FindPhoneLabelButton->SetImageSrc(PNG_BUTTON_466x100_IMAGE, PNG_BUTTON_466x100_IMAGE);
-            //FindPhoneLabelButton->SetText("关闭");
+            // FindPhoneLabelButton->SetText("关闭");
             FindPhoneLabelButton->SetTextId(STR_CLOSE);
             FindPhoneLabelButton->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff));
             FindPhoneLabelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
@@ -215,13 +195,13 @@ namespace OHOS
             FindPhoneTitleLabel->SetPosition(133, 51, 200, 40);
             FindPhoneTitleLabel->SetStyle(STYLE_TEXT_FONT, 30);
             FindPhoneTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
-            //FindPhoneTitleLabel->SetText("查找手机");
+            // FindPhoneTitleLabel->SetText("查找手机");
             FindPhoneTitleLabel->SetTextId(STR_FIND_PHONE);
             FindPhoneTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
             FindPhoneTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
             FindPhoneTitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
             /* ----------------------- FindPhoneImageAnimator ---------------------- */
-            FindPhonePathsArray = CreateImagePathsArray("/user/res/findphone/", "bin", FINDPHONE_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+            FindPhonePathsArray = CreateImagePathsArray("/user/res/findphone/",FINDPHONE_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
             if (FindPhoneImageAnimator == nullptr)
             {
                 FindPhoneImageAnimator = new UIImageAnimatorView();
@@ -256,7 +236,7 @@ namespace OHOS
             FindPhoneLabel->SetPosition(33, 270, 400, 40);
             FindPhoneLabel->SetStyle(STYLE_TEXT_FONT, 30);
             FindPhoneLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
-            //FindPhoneLabel->SetText("手机正在响铃/震动");
+            // FindPhoneLabel->SetText("手机正在响铃/震动");
             FindPhoneLabel->SetTextId(STR_PHONE_RINGING_VIBRATING);
             FindPhoneLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
             FindPhoneLabel->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff));
@@ -272,7 +252,7 @@ namespace OHOS
             FindPhoneLabelButton->SetPosition(0, 366, 466, 100);
             FindPhoneLabelButton->SetViewId(FINDPHONE_LABELBUTTON);
             FindPhoneLabelButton->SetImageSrc(PNG_466x100BUTTON_IMAGE, PNG_466x100BUTTON_IMAGE);
-            //FindPhoneLabelButton->SetText("停止");
+            // FindPhoneLabelButton->SetText("停止");
             FindPhoneLabelButton->SetTextId(STR_STOP);
             FindPhoneLabelButton->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff));
             FindPhoneLabelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
index b98dd72..036b66a 100644 (file)
@@ -68,10 +68,11 @@ namespace OHOS
     HeartChartView::~HeartChartView()
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HeartChartView::~HeartChartView");
-        imageAnimator->Stop();
+
+        // imageAnimator->Stop();
         /*
-                UIViewGroup *tmpGroup = dynamic_cast<UIViewGroup *>(container_);
-                UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup);
+            UIViewGroup *tmpGroup = dynamic_cast<UIViewGroup *>(container_);
+            UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup);
         */
 
         delete CurrentHeartText;
@@ -95,7 +96,6 @@ namespace OHOS
         delete imageAnimator;
         imageAnimator = nullptr;
 
-
         heartchart->ClearDataSerial();
         delete heartSerial;
         heartSerial = nullptr;
@@ -292,7 +292,7 @@ namespace OHOS
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartChartView::InitHeartView fail");
         }
 
-        HeartImageAnimator();
+        // HeartImageAnimator();
         InitChartView();
         SetDataChart();
         SetDataTopAndBottom();
index ae0efbb..89cc1e5 100644 (file)
@@ -37,8 +37,7 @@ namespace OHOS
         void OnAnimatorStop(UIView &view) override;
         void ClearAll(void);
         bool ShowUpShutDownAnimatorView();
-        const char **CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages);
-        void FreeImagePathsArray(const char **imagePaths, const int numImages);
+
         UIViewGroup *group{nullptr};
         UIImageAnimatorView *shutDownImageAnimatorView{nullptr};                      // 关机动画
         ImageAnimatorInfo ShutDownImageInfo[SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES]; // 关机图像的信息
index a9504e4..b73683f 100644 (file)
@@ -1,7 +1,14 @@
+/***
+ * @Date: 2024-08-29 11:02:07
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-30 19:24:04
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/ShutDownImageAnimatorView.cpp
+ */
 #include "rebootandshutdown/include/ShutDownImageAnimatorView.h"
 #include "rebootandshutdown/include/RebootAndShutdownPresenter.h"
 #include "wearable_log.h"
 #include <custom_utils.h>
+#include "uicomponents/UIComponents.h"
 namespace OHOS
 {
 
@@ -22,28 +29,6 @@ namespace OHOS
         return g_pShutDownAnimatorView;
     }
 
-    const char **ShutDownImageAnimatorView::CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages)
-    {
-        const char **imagePaths = new const char *[numImages];
-        char buffer[256];
-        for (int i = 0; i < numImages; i++)
-        {
-            snprintf(buffer, sizeof(buffer), "%s%d.%s", basePath, i + 1, fileExtension);
-            imagePaths[i] = strdup(buffer);
-            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " imagePaths[%d] = %s", i, imagePaths[i]);
-        }
-        return imagePaths;
-    }
-
-    void ShutDownImageAnimatorView::FreeImagePathsArray(const char **imagePaths, const int numImages)
-    {
-        for (int i = 0; i < numImages; i++)
-        {
-            delete imagePaths[i];
-            imagePaths[i] = nullptr;
-        }
-    }
-
     void ShutDownImageAnimatorView::ClearAll(void)
     {
         if (group != nullptr)
@@ -87,7 +72,7 @@ namespace OHOS
         isShutDownImageAnimatorStart = true;
     }
 
-    //获取开机动画是否已经开始
+    // 获取开机动画是否已经开始
     bool ShutDownImageAnimatorView::GetShutDownImageAnimatorIsStart(void)
     {
         return isShutDownImageAnimatorStart;
@@ -96,7 +81,7 @@ namespace OHOS
     bool ShutDownImageAnimatorView::ShowUpShutDownAnimatorView()
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShutDownImageAnimatorView::ShowUpShutDownAnimatorView");
-        ShutDownPathsArray = CreateImagePathsArray(ShutDownPaths, "bin", SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+        ShutDownPathsArray = CreateImagePathsArray(ShutDownPaths,  SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
 
         if (shutDownImageAnimatorView == nullptr)
         {
index d6cf3dc..0ff3584 100644 (file)
@@ -91,8 +91,6 @@ namespace OHOS
         void RespiratoryTrainingViewInit(void);
         void ClearAll(void);
 #if 0
-        const char **CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages);
-        void FreeImagePathsArray(const char **imagePaths, const int numImages);
         void InitializeRespiratoryTrainingImageInfo();
         void SetAnimatorViewProperties();
         void CreateRespiratoryTrainingAnimatorView();
index 04fa4a7..af98867 100644 (file)
@@ -165,32 +165,6 @@ namespace OHOS
         }
     }
 
-    const char **RespiratoryTrainingView::CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages)
-    {
-        const char **imagePaths = new const char *[numImages];
-        char buffer[256];
-        for (int i = 0; i < numImages; i++)
-        {
-            snprintf(buffer, sizeof(buffer), "%s%d.%s", basePath, i + 1, fileExtension);
-            imagePaths[i] = strdup(buffer);
-            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " imagePaths[%d] = %s", i, imagePaths[i]);
-        }
-        return imagePaths;
-    }
-    /*
-     * @brief: 释放图片路径数组指针
-     * @param {char} imagePaths 图片路径数组
-     * @param {int} numImages 图片数量
-     */
-    void RespiratoryTrainingView::FreeImagePathsArray(const char **imagePaths, const int numImages)
-    {
-        for (int i = 0; i < numImages; i++)
-        {
-            delete imagePaths[i];
-            imagePaths[i] = nullptr;
-        }
-    }
-
     // 初始化呼吸训练动画图片信息
     void RespiratoryTrainingView::InitializeRespiratoryTrainingImageInfo()
     {
index e831427..6c084ed 100644 (file)
@@ -19,7 +19,7 @@
 #include "common/key_code.h"\r
 \r
 #include "saveele/include/SaveElePresenter.h"\r
-\r
+#include "gfx_utils/mem_check.h"\r
 namespace OHOS\r
 {\r
 \r
@@ -28,13 +28,17 @@ namespace OHOS
 \r
     SaveElePresenter::SaveElePresenter()\r
     {\r
-\r
+#ifdef MEM_CHECK\r
+        MemCheck::GetInstance()->EnableLeakCheck(true);\r
+#endif\r
         g_pSaveElePresenter = this;\r
     }\r
 \r
     SaveElePresenter::~SaveElePresenter()\r
     {\r
-\r
+#ifdef MEM_CHECK\r
+        MemCheck::GetInstance()->EnableLeakCheck(false);\r
+#endif\r
         g_pSaveElePresenter = nullptr;\r
     }\r
 \r
index faa5c33..f44d3d9 100644 (file)
@@ -51,8 +51,6 @@ namespace OHOS
         void SleepDataRefresh();
 
     private:
-        const char **CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages);
-        void FreeImagePathsArray(const char **imagePaths, const int numImages);
         void DumpWeatherInfo();
 
     private:
index dd9776c..d300dc7 100644 (file)
@@ -33,7 +33,7 @@ namespace OHOS
     {
         g_pSleepControlPresenter = nullptr;
 #ifdef MEM_CHECK
-        MemCheck::GetInstance()->EnableLeakCheck(true);
+        MemCheck::GetInstance()->EnableLeakCheck(false);
 #endif
     }
 
index 37f2024..46717ad 100644 (file)
@@ -83,6 +83,11 @@ namespace OHOS
         UIImageAnimatorView *smileAnimator{nullptr};
 
         bool viewiInitStatus{false};
+
+        std::string creambasePath;
+        const char **creamimagePaths;
+        std::string smilebasePath;
+        const char **smileimagePaths;
     };
 } // namespace OHOS
 #endif // Takephotos_PRESENTER_H
index 4c6614c..76f0871 100644 (file)
@@ -1,3 +1,9 @@
+/***
+ * @Date: 2024-08-29 19:34:29
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-30 19:46:48
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/takephotos/src/TakephotosView.cpp
+ */
 
 #include "takephotos/include/TakephotosView.h"
 #include "takephotos/include/TakephotosModel.h"
@@ -25,7 +31,9 @@ namespace OHOS
         // DeInit();
 
         creamAnimator->Stop();
-        smileAnimator->Start();
+        smileAnimator->Stop();
+        FreeImagePathsArray(creamimagePaths, 50);
+        FreeImagePathsArray(smileimagePaths, 27);
 
         UIViewGroup *tmpGroup = dynamic_cast<UIViewGroup *>(container_);
         UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup);
@@ -137,10 +145,9 @@ namespace OHOS
         buttongo->SetOnClickListener(static_cast<UIView::OnClickListener *>(TakephotosPresenter::GetInstance()));
 
         // 初始化图片数组以及动画
-        const char *basePath = "/user/res/takephotos/cream/";
-        const char *fileExtension = "bin";
-        const char **imagePaths = CreateImagePathsArray(basePath, fileExtension, 50);
-        InitImageAnimatorSource(creamAnimator, imagePaths, 50, 163, 103, 140, 140, "imageAnimator", 100);
+        creambasePath = "/user/res/takephotos/cream/";
+        creamimagePaths = CreateImagePathsArray(creambasePath.c_str(), 50);
+        InitImageAnimatorSource(creamAnimator, creamimagePaths, 50, 163, 103, 140, 140, "imageAnimator", 100);
 
         creamView->Add(creamAnimator);
         creamView->Add(labeltitle_);
@@ -189,10 +196,9 @@ namespace OHOS
         buttontake->SetOnClickListener(static_cast<UIView::OnClickListener *>(TakephotosPresenter::GetInstance()));
 
         // 初始化图片数组以及动画 {修改为统一动画}
-        const char *basePath = "/user/res/takephotos/cream/";
-        const char *fileExtension = "bin";
-        const char **imagePaths = CreateImagePathsArray(basePath, fileExtension, 27);
-        InitImageAnimatorSource(smileAnimator, imagePaths, 27, 163, 140, 140, 140, "imageAnimator", 100);
+        smilebasePath = "/user/res/takephotos/cream/";
+        smileimagePaths = CreateImagePathsArray(smilebasePath.c_str(), 27);
+        InitImageAnimatorSource(smileAnimator, smileimagePaths, 27, 163, 140, 140, 140, "imageAnimator", 100);
 
         takeView->Add(smileAnimator);
         takeView->Add(labeltake_);
index fb8ef2c..a98a151 100644 (file)
@@ -134,6 +134,9 @@ namespace OHOS
 \r
         bool viewiInitStatus{false};\r
         bool momentumFlag{false};\r
+\r
+        std::string winbasePath;\r
+        const char **winimagePaths;\r
     };\r
 } // namespace OHOS\r
 #endif // TraingCard_PRESENTER_H\r
index 2ba20c0..aa5f4f5 100644 (file)
@@ -87,7 +87,9 @@ namespace OHOS
 \r
     TraingCardView::~TraingCardView()\r
     {\r
+        FreeImagePathsArray(winimagePaths, 94);\r
         DeInit();\r
+\r
         g_pTraingCardView = nullptr;\r
         DisableTimer(); // 关闭计时器\r
         TraingModel::GetInstance()->SetTimestamp();\r
@@ -486,10 +488,9 @@ namespace OHOS
         getView->Add(labeltag);\r
 \r
         // 初始化图片数组以及动画\r
-        const char *basePath = "/user/res/Training/training_GIF/win/";\r
-        const char *fileExtension = "bin";\r
-        const char **imagePaths = CreateImagePathsArray(basePath, fileExtension, 94);\r
-        InitImageAnimatorSource(imageAnimator, imagePaths, 94, 173, 100, 120, 120, "imageAnimator1", 10);\r
+        winbasePath = "/user/res/Training/training_GIF/win/";\r
+        winimagePaths = CreateImagePathsArray(winbasePath.c_str(), 94);\r
+        InitImageAnimatorSource(imageAnimator, winimagePaths, 94, 173, 100, 120, 120, "imageAnimator1", 10);\r
         getView->Add(imageAnimator);\r
     }\r
 \r
index b4c9285..a884386 100644 (file)
@@ -57,8 +57,6 @@ namespace OHOS
         std::string WindSpeedData; // 风速数据\r
         std::string HumidityData;  // 湿度数据\r
     private:\r
-        const char **CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages);\r
-        void FreeImagePathsArray(const char **imagePaths, const int numImages);\r
         UILabelExt *SetUpLabel(LabelConfig &labelconfig); // 设置标签\r
         UILabelExt *SetUpLabelExt(LabelConfig &labelconfig);\r
         bool WeatherReportViewLabelInit(void);\r
index 56bc2ff..0eac61d 100644 (file)
@@ -1,3 +1,9 @@
+/*** 
+ * @Date: 2024-08-19 11:01:42
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-30 19:24:56
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherView.h
+ */
 /*
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-03-30 09:14:38
@@ -40,9 +46,6 @@ namespace OHOS
 
     private:
         UILabelExt *InitLabelExt(int x, int y, int w, int h, const char *text, int textfont, int lineheight);
-        const char **CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages);
-        void FreeImagePathsArray(const char **imagePaths, const int numImages);
-
     private:
         void DumpWeatherInfo();
         bool SetImageSource(UIImageView *image, const std::string &source);
index 641e0db..2aa9563 100644 (file)
@@ -1,7 +1,14 @@
+/***\r
+ * @Date: 2024-08-19 11:01:42\r
+ * @LastEditors: Caisking 3449750381@qq.com\r
+ * @LastEditTime: 2024-08-30 19:25:11\r
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherReportView.cpp\r
+ */\r
 #include "weather/include/WeatherReportView.h"\r
 #include "wearable_log.h"\r
 #include "weather/include/WeatherModel.h"\r
 #include "common/image_cache_manager.h"\r
+#include "uicomponents/UIComponents.h"\r
 namespace OHOS\r
 {\r
     static constexpr int16_t UV_IMAGE_ANIMATOR_VIEW_X = 53;\r
@@ -249,7 +256,7 @@ namespace OHOS
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherReportView::WeatherReportViewImageAnimatorViewInit");\r
 \r
         /* ----------------------------- UVImageAnimatorView---------------------------- */\r
-        UVPathsArray = CreateImagePathsArray(UVPaths, "bin", UV_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);\r
+        UVPathsArray = CreateImagePathsArray(UVPaths, UV_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);\r
         if (UVImageAnimatorView == nullptr)\r
         {\r
             UVImageAnimatorView = new UIImageAnimatorView();\r
@@ -275,7 +282,7 @@ namespace OHOS
             UVImageAnimatorView->Start();\r
         }\r
         /* ----------------------- WindSpeedImageAnimatorView ----------------------- */\r
-        WindSpeedPathsArray = CreateImagePathsArray(WindSpeedPaths, "bin", WINDSPEED_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);\r
+        WindSpeedPathsArray = CreateImagePathsArray(WindSpeedPaths, WINDSPEED_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);\r
         if (WindSpeedImageAnimatorView == nullptr)\r
         {\r
             WindSpeedImageAnimatorView = new UIImageAnimatorView();\r
@@ -301,7 +308,7 @@ namespace OHOS
             WindSpeedImageAnimatorView->Start();\r
         }\r
         /* ------------------------ HumidityImageAnimatorView ----------------------- */\r
-        HumidityPathsArray = CreateImagePathsArray(HumidityPaths, "bin", HUMIDITY_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);\r
+        HumidityPathsArray = CreateImagePathsArray(HumidityPaths, HUMIDITY_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);\r
         if (HumidityImageAnimatorView == nullptr)\r
         {\r
             HumidityImageAnimatorView = new UIImageAnimatorView();\r
@@ -373,32 +380,6 @@ namespace OHOS
         return true;\r
     }\r
 \r
-    const char **WeatherReportView::CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages)\r
-    {\r
-        const char **imagePaths = new const char *[numImages];\r
-        char buffer[256];\r
-        for (int i = 0; i < numImages; i++)\r
-        {\r
-            snprintf(buffer, sizeof(buffer), "%s%d.%s", basePath, i + 1, fileExtension);\r
-            imagePaths[i] = strdup(buffer);\r
-            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " imagePaths[%d] = %s", i, imagePaths[i]);\r
-        }\r
-        return imagePaths;\r
-    }\r
-\r
-    /*\r
-     * @brief: 释放图片路径数组指针\r
-     * @param {char} imagePaths 图片路径数组\r
-     * @param {int} numImages 图片数量\r
-     */\r
-    void WeatherReportView::FreeImagePathsArray(const char **imagePaths, const int numImages)\r
-    {\r
-        for (int i = 0; i < numImages; i++)\r
-        {\r
-            delete imagePaths[i];\r
-            imagePaths[i] = nullptr;\r
-        }\r
-    }\r
 \r
     // 设置文本标签的通用函数\r
     bool WeatherReportView::SetTextLabel(UILabel *label, const std::string &text)\r
index e23379c..fae96ec 100644 (file)
@@ -328,33 +328,7 @@ namespace OHOS
         return true;
     }
 
-    const char **WeatherView::CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages)
-    {
-        const char **imagePaths = new const char *[numImages];
-        char buffer[256];
-        for (int i = 0; i < numImages; i++)
-        {
-            snprintf(buffer, sizeof(buffer), "%s%d.%s", basePath, i + 1, fileExtension);
-            imagePaths[i] = strdup(buffer);
-            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " imagePaths[%d] = %s", i, imagePaths[i]);
-        }
-        return imagePaths;
-    }
-
-    /*
-     * @brief: 释放图片路径数组指针
-     * @param {char} imagePaths 图片路径数组
-     * @param {int} numImages 图片数量
-     */
-    void WeatherView::FreeImagePathsArray(const char **imagePaths, const int numImages)
-    {
-        for (int i = 0; i < numImages; i++)
-        {
-            delete imagePaths[i];
-            imagePaths[i] = nullptr;
-        }
-    }
-
+   
     // 设置文本标签的通用函数
     bool WeatherView::SetTextLabel(UILabel *label, const std::string &text)
     {
index 1edfdc3..eb1ca80 100644 (file)
@@ -23,8 +23,6 @@ namespace OHOS
     {
     public:
         static PairingViewEventListener &GetInstance(void);
-        const char **CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages);
-        void FreeImagePathsArray(const char **imagePaths, const int numImages);
         bool OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event) override;
         void SetDeviceName(char *Name);
         char *GetDeviceName();
index 87f2fa7..a67451a 100644 (file)
@@ -298,29 +298,6 @@ namespace OHOS
     }
 
 
-    static void FreeImagePathsArray(const char **imagePaths, const int numImages)
-    {
-        for (int i = 0; i < numImages; i++)
-        {
-            // ImageCacheManager::GetInstance().UnloadSingleRes(imagePaths[i]);
-            delete imagePaths[i];
-            imagePaths[i] = nullptr;
-        }
-    }
-
-    static const char ** CreateImagePathsArray_(const char *basePath, const char *fileExtension, int numImages)
-    {
-        const char **imagePaths = new const char *[numImages];
-        char buffer[256];
-        for (int i = 0; i < numImages; i++)
-        {
-            snprintf(buffer, sizeof(buffer), "%s%d.%s", basePath, i + 1, fileExtension);
-            imagePaths[i] = strdup(buffer);
-            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " imagePaths[%d] = %s", i, imagePaths[i]);
-        }
-        return imagePaths;
-    }
-
     void ShowUpShutDownAnimatorView()
     {
         group = new UIViewGroup();
@@ -332,7 +309,7 @@ namespace OHOS
         group->SetPosition(0, 0, 466, 466);
 
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShutDownAnimatorView::ShowUpShutDownAnimatorView");
-        ShutDownPathsArray = CreateImagePathsArray_(ShutDownPaths, "bin", SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+        ShutDownPathsArray = CreateImagePathsArray(ShutDownPaths, SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
 
         if (ShutDownImageAnimatorView == nullptr)
         {
index d7456b7..dc90b53 100644 (file)
@@ -17,7 +17,6 @@
 
 #endif
 
-
 #include <cmsis_os2.h>
 #include <cmsis_os.h>
 #include <ohos_types.h>
@@ -25,6 +24,7 @@
 #include "iostream"
 #include <broadcast_feature.h>
 #include <custom_utils.h>
+#include "uicomponents/UIComponents.h"
 
 namespace OHOS
 {
@@ -85,10 +85,10 @@ namespace OHOS
         {
             PairingViewEventListener::GetInstance().Pairing_StopTimer();
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceBindingButtonCancel  OnClick");
-            // 终止当前的绑定流程并关闭相关的通知界面。
-            #ifdef SUPPORT_BLE_SERVICE
+// 终止当前的绑定流程并关闭相关的通知界面。
+#ifdef SUPPORT_BLE_SERVICE
             comfirmPaire(0);
-            #endif
+#endif
             NotificationManager::GetInstance()->StopNotify();
         }
         else if (&view == DeviceBindingButtonOK) // 设备绑定确认按钮
@@ -101,45 +101,44 @@ namespace OHOS
              * 3.发送绑定请求到设备或服务器等.
              */
             PairingViewEventListener::GetInstance().Pairing_StopTimer();
-            // 关闭通知界面
-            #ifdef SUPPORT_BLE_SERVICE
+// 关闭通知界面
+#ifdef SUPPORT_BLE_SERVICE
             comfirmPaire(1);
-            #endif
+#endif
             NotificationManager::GetInstance()->StopNotify();
         }
         else if (&view == DeviceUnBindingButtonCancel) // 设备解绑取消按钮
         {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceUnBindingButtonCancel  OnClick");
-            // 不想执行解绑动作,并关闭解绑的通知界面。
-            #ifdef SUPPORT_BLE_SERVICE
-                cleanUnbindInfor(0);
-            #endif
+// 不想执行解绑动作,并关闭解绑的通知界面。
+#ifdef SUPPORT_BLE_SERVICE
+            cleanUnbindInfor(0);
+#endif
             NotificationManager::GetInstance()->StopNotify();
         }
         else if (&view == DeviceUnBindingButtonOK) // 设备解绑确认按钮
         {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceUnBindingButtonOK  OnClick");
-            /*
-             * 可能会执行的解绑流程:
-             * 1.通知设备或服务器执行解绑操作.
-             * 2.从绑定设备列表移除设备.
-             * 3.更新UI状态.
-             */
+/*
+ * 可能会执行的解绑流程:
+ * 1.通知设备或服务器执行解绑操作.
+ * 2.从绑定设备列表移除设备.
+ * 3.更新UI状态.
+ */
 
-            // 关闭通知界面
-            #ifdef SUPPORT_BLE_SERVICE
-                cleanUnbindInfor(1);
-            #endif
+// 关闭通知界面
+#ifdef SUPPORT_BLE_SERVICE
+            cleanUnbindInfor(1);
+#endif
             NotificationManager::GetInstance()->StopNotify();
         }
         else if (&view == DeviceUnbindingRequestButtonOK) // 设备解除绑定请求(与新设备连接)确认
         {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceUnbindingRequestButtonOK  OnClick");
-            
-           
+
             NotificationManager::GetInstance()->StopNotify();
         }
-        else if (&view == DeviceUnbindingRequestButtonCancel) //设备解除绑定请求(与新设备连接)取消
+        else if (&view == DeviceUnbindingRequestButtonCancel) // 设备解除绑定请求(与新设备连接)取消
         {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PairingViewEventListener:: DeviceUnbindingRequestButtonCancel  OnClick");
             NotificationManager::GetInstance()->StopNotify();
@@ -147,32 +146,6 @@ namespace OHOS
         return true;
     }
 
-    const char **PairingViewEventListener::CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages)
-    {
-        const char **imagePaths = new const char *[numImages];
-        char buffer[256];
-        for (int i = 0; i < numImages; i++)
-        {
-            snprintf(buffer, sizeof(buffer), "%s%d.%s", basePath, i + 1, fileExtension);
-            imagePaths[i] = strdup(buffer);
-            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " imagePaths[%d] = %s", i, imagePaths[i]);
-        }
-        return imagePaths;
-    }
-    /*
-     * @brief: 释放图片路径数组指针
-     * @param {char} imagePaths 图片路径数组
-     * @param {int} numImages 图片数量
-     */
-    void PairingViewEventListener::FreeImagePathsArray(const char **imagePaths, const int numImages)
-    {
-        for (int i = 0; i < numImages; i++)
-        {
-            delete imagePaths[i];
-            imagePaths[i] = nullptr;
-        }
-    }
-
     static UIButton *CreateButton(unsigned int x, unsigned int y, unsigned int w, unsigned int h, const char *imageSrc)
     {
         UIButton *button = new UIButton();
@@ -191,24 +164,24 @@ namespace OHOS
     void PairingViewEventListener::SetDeviceName(char *Name)
     {
         // printf("Name:%s\r\n",Name);
-        memset(DeviceName,0,sizeof(DeviceName));
-        if(Name == NULL)
+        memset(DeviceName, 0, sizeof(DeviceName));
+        if (Name == NULL)
         {
-            strcpy(DeviceName,"phone");
+            strcpy(DeviceName, "phone");
             return;
         }
         int len = strlen(Name);
-        if(len > sizeof(DeviceName))
+        if (len > sizeof(DeviceName))
             len = sizeof(DeviceName);
-            Name[len]='\0';
-        
-        memcpy(DeviceName,Name,len);
+        Name[len] = '\0';
+
+        memcpy(DeviceName, Name, len);
     }
 
     /*获取设备名称*/
     char *PairingViewEventListener::GetDeviceName(void)
     {
-        return DeviceName; //先用固定字符串测试
+        return DeviceName; // 先用固定字符串测试
     }
 
     /*
@@ -257,13 +230,15 @@ namespace OHOS
             DeviceBindingName->SetStyle(STYLE_TEXT_FONT, 30);
             DeviceBindingName->SetStyle(STYLE_LINE_HEIGHT, 35);
 
-            if(strlen(devanme)){
+            if (strlen(devanme))
+            {
                 DeviceBindingName->SetText(devanme);
-            }else
+            }
+            else
             {
                 DeviceBindingName->SetText(" ");
             }
-            
+
             DeviceBindingName->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
             DeviceBindingName->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
             DeviceBindingName->SetRollSpeed(60);
@@ -307,9 +282,9 @@ namespace OHOS
             DeviceBindingView->Add(DeviceBindingViewLabel);
             DeviceBindingView->Add(DeviceBindingButtonCancel);
             DeviceBindingView->Add(DeviceBindingButtonOK);
-            #if NO_LCD_TEST_CONNECT
+#if NO_LCD_TEST_CONNECT
             PairingViewEventListener::GetInstance().Pairing_StartTimer();
-            #endif
+#endif
         }
 
         NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeDeviceBindingView);
@@ -335,7 +310,7 @@ namespace OHOS
             DeviceUnBindingView->SetDraggable(true);
             DeviceUnBindingView->SetTouchable(true);
             /* ----------------------- DeviceUnBindingAnimatorView ---------------------- */
-            UnBindPathsArray = PairingViewEventListener::GetInstance().CreateImagePathsArray("/user/res/remind/unbind/", "bin", UNBIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+            UnBindPathsArray = CreateImagePathsArray("/user/res/remind/unbind/", UNBIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
             if (DeviceUnBindingAnimatorView == nullptr)
             {
                 DeviceUnBindingAnimatorView = new UIImageAnimatorView();
@@ -385,13 +360,14 @@ namespace OHOS
             DeviceUnBindingName->SetStyle(STYLE_TEXT_FONT, 30);
             DeviceUnBindingName->SetStyle(STYLE_LINE_HEIGHT, 35);
 
-            
             char *devanme = PairingViewEventListener::GetInstance().GetDeviceName();
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingName devanme :%s",devanme);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingName devanme :%s", devanme);
 
-            if(strlen(devanme)){
+            if (strlen(devanme))
+            {
                 DeviceUnBindingName->SetText(devanme);
-            }else
+            }
+            else
             {
                 DeviceUnBindingName->SetText(" ");
             }
@@ -440,7 +416,6 @@ namespace OHOS
             DeviceUnBindingView->Add(DeviceUnBindingViewLabel);
             DeviceUnBindingView->Add(DeviceUnBindingButtonCancel);
             DeviceUnBindingView->Add(DeviceUnBindingButtonOK);
-
         }
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] DeviceUnBindingView new success!!");
         NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeDeviceUnBindingView);
@@ -515,7 +490,7 @@ namespace OHOS
             DeviceUnbindingRequestViewLabel[0]->SetStyle(STYLE_LINE_HEIGHT, 40);
             char str[512];
             memset(str, 0, 512);
-            
+
             sprintf(str, "当前设备已经与 %s 绑定", PairingViewEventListener::GetInstance().GetDeviceName());
             DeviceUnbindingRequestViewLabel[0]->SetText(str);
             DeviceUnbindingRequestViewLabel[0]->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
@@ -623,25 +598,21 @@ namespace OHOS
             delete DeviceUnBindingViewTitleLabel;
             DeviceUnBindingViewTitleLabel = nullptr;
 
-            PairingViewEventListener::GetInstance().FreeImagePathsArray(UnBindPathsArray, UNBIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
-            
+            FreeImagePathsArray(UnBindPathsArray, UNBIND_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+
             DeviceUnBindingAnimatorView->Stop();
             delete DeviceUnBindingAnimatorView;
             DeviceUnBindingAnimatorView = nullptr;
 
-
             delete DeviceUnBindingName;
             DeviceUnBindingName = nullptr;
 
-
             delete DeviceUnBindingViewLabel;
             DeviceUnBindingViewLabel = nullptr;
 
-
             delete DeviceUnBindingButtonCancel;
             DeviceUnBindingButtonCancel = nullptr;
 
-
             delete DeviceUnBindingButtonOK;
             DeviceUnBindingButtonOK = nullptr;
 
@@ -695,7 +666,7 @@ namespace OHOS
     }
 
     /* -------------------------------------------------------------------------- */
-    
+
     // 声明定时器变量
     static osTimerId_t g_timer = NULL;
 
@@ -703,22 +674,22 @@ namespace OHOS
     static void Pairing_TimerCallbackProc(int data)
     {
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Pairing_TimerCallbackProc");
-        #ifdef SUPPORT_BLE_SERVICE
-        #if NO_LCD_TEST_CONNECT
+#ifdef SUPPORT_BLE_SERVICE
+#if NO_LCD_TEST_CONNECT
         comfirmPaire(1);
-        #else
+#else
         comfirmPaire(0);
-        #endif
-        #endif
-        if( NotificationManager::GetInstance()->GetShowingNotifyId() == TOPIC_EVENT_DEVICE_BIND &&
+#endif
+#endif
+        if (NotificationManager::GetInstance()->GetShowingNotifyId() == TOPIC_EVENT_DEVICE_BIND &&
             NotificationManager::GetInstance()->HasNotifyShowing() == true)
         {
             NotificationManager::GetInstance()->StopNotify();
         }
-        
+
         PairingViewEventListener::GetInstance().Pairing_StopTimer();
     }
-    
+
     /*
      * @brief 回调函数
      */