删除ConfigModel文件中无用的ImageAnimator类
authorluozheng <1732036298@qq.com>
Fri, 12 Apr 2024 12:23:35 +0000 (20:23 +0800)
committerluozheng <1732036298@qq.com>
Fri, 12 Apr 2024 12:23:35 +0000 (20:23 +0800)
code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModel.h
code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp

index 277e043..93346b5 100644 (file)
@@ -205,36 +205,5 @@ namespace OHOS
         bool model_initialled{false};
         /* -------------------------------------------------------------------------- */
     };
-
-    /* ------------------------------ ImageAnimator ----------------------------- */
-    /*
-     * 图片动画类
-     */
-    class ImageAnimator
-    {
-    public:
-        struct ImageAnimatorConfig
-        {
-            int16_t x;
-            int16_t y;
-            int16_t w;
-            int16_t h;
-
-            int numFrames;
-            int time; // 更新的时间间隔
-        } imageAnimatorConfig;
-        // 构造函数
-        ImageAnimator();
-        // 析构函数
-        ~ImageAnimator();
-
-        const char **CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages);
-
-        void InitImageAnimatorSource(UIImageAnimatorView *&imageAnimator, ImageAnimatorInfo *&imageAnimatorInfo, const char **imagePaths, const ImageAnimatorConfig &imageAnimatorConfig);
-
-        void FreeImagePathsArray(const char **imagePaths, const int numImages);
-
-        void DeleteImageAnimatorInfo(ImageAnimatorInfo *&imageAnimatorInfo);
-    };
 }
 #endif
\ No newline at end of file
index d71f9bf..02859fc 100644 (file)
@@ -670,101 +670,6 @@ namespace OHOS
         WriteJsonToFile(jsonString, filePath.c_str());
         cJSON_free(jsonString);
     }
-
-
-    /* ------------------------------ ImageAnimator ----------------------------- */
-
-    ImageAnimator::ImageAnimator()
-    {
-        // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ImageAnimator::ImageAnimator");
-    }
-
-    ImageAnimator::~ImageAnimator()
-    {
-        // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ImageAnimator::~ImageAnimator");
-    }
-
-    /*
-     * @brief 创建并初始化图像路径数组
-     * @param  basePath 包含图片文件的基本路径
-     * @param  fileExtension 图片文件的扩展名
-     * @param  numImages 图片文件的数量
-     * @return 返回包含图片文件路径的数组
-     */
-    const char **ImageAnimator::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 初始化UIImageAnimatorView,并设置为GIF动画
-     * 该函数用于使用提供的GIF图像和属性初始化UIImageAnimatorView
-     * @param imageAnimator 要初始化的UIImageAnimatorView对象的引用
-     * @param imagePaths 图片路径
-     * @param imageAnimatorInfo 图片映像的信息
-     * @param imageAnimatorConfig 样式配置信息
-     */
-    void ImageAnimator::InitImageAnimatorSource(UIImageAnimatorView *&imageAnimator, ImageAnimatorInfo *&imageAnimatorInfo, const char **imagePaths, const ImageAnimatorConfig &imageAnimatorConfig)
-    {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ImageAnimator::InitImageAnimatorSource");
-
-        if (imageAnimator == nullptr)
-        {
-            imageAnimator = new UIImageAnimatorView();
-        }
-        imageAnimator->SetPosition(imageAnimatorConfig.x, imageAnimatorConfig.y, imageAnimatorConfig.w, imageAnimatorConfig.h);
-        imageAnimator->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
-        imageAnimator->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
-
-        imageAnimatorInfo = new ImageAnimatorInfo[imageAnimatorConfig.numFrames];
-        for (int i = 0; i < imageAnimatorConfig.numFrames; i++)
-        {
-            imageAnimatorInfo[i].imagePath = imagePaths[i];
-            imageAnimatorInfo[i].pos.x = imageAnimatorConfig.x;
-            imageAnimatorInfo[i].pos.y = imageAnimatorConfig.y;
-            imageAnimatorInfo[i].width = imageAnimatorConfig.w;
-            imageAnimatorInfo[i].height = imageAnimatorConfig.h;
-            imageAnimatorInfo[i].imageType = IMG_SRC_FILE_PATH;
-        }
-
-        imageAnimator->SetImageAnimatorSrc(imageAnimatorInfo, imageAnimatorConfig.numFrames, imageAnimatorConfig.time); // 200 is the default delay time
-        imageAnimator->SetTimeOfPause(imageAnimatorConfig.time);
-        imageAnimator->SetRepeat(true);
-    }
-    /*
-     * 释放图片文件路径数组占用的内存
-     * @param  imagePaths  图片文件路径数组
-     * @param  numImages  图片文件的数量
-     */
-    void ImageAnimator::FreeImagePathsArray(const char **imagePaths, const int numImages)
-    {
-        for (int i = 0; i < numImages; i++)
-        {
-            delete imagePaths[i];
-            imagePaths[i] = nullptr;
-        }
-    }
-
-    void ImageAnimator::DeleteImageAnimatorInfo(ImageAnimatorInfo *&imageAnimatorInfo)
-    {
-        if (imageAnimatorInfo != nullptr)
-        {
-            // 由于 imageAnimatorInfo 是一个数组,我们需要使用 delete[] 来删除它
-            delete[] imageAnimatorInfo;
-
-            // 重置指针防止悬空指针
-            imageAnimatorInfo = nullptr;
-        }
-    }
-
 }
 
 #ifdef __cplusplus