{
InitLabel(label, x, y, width, height, viewId, text, fontName, fontSize);
}
+ /* -------------------------------------------------------------------------- */
+ /**
+ * 创建包含图片文件路径的数组
+ * @param basePath 包含图片文件的基本路径 PullUp_%d.bin
+ * @param fileExtension 图片文件的扩展名
+ * @param numImages 图片文件的数量
+ * @return 返回包含图片文件info的数组
+ */
+ const ImageInfo**CreateImageInfoArray(const char *basePath, int numImages, const char *fileExtension)
+ {
+ const ImageInfo **imageinfo_array = static_cast<const ImageInfo **>(UIMalloc(numImages * sizeof(const ImageInfo *)));
+ if(imageinfo_array==nullptr)
+ {
+ return nullptr; // 检查内存分配是否成功
+ }
+ for(int i = 0; i < numImages; i++)
+ {
+ char buffer[256]={0};
+ snprintf(buffer, sizeof(buffer), "%s%d.%s", basePath, i + 1, fileExtension);
+ imageinfo_array[i]=ImageCacheManager::GetInstance().LoadSingleRes(buffer);
+ if( imageinfo_array[i]==nullptr)
+ {
+ UIFree(imageinfo_array);
+ return nullptr; // 检查内存分配是否成功
+ }
+ }
+ return imageinfo_array;
+ }
+ void FreeImageInfoArray( const ImageInfo** array,const char *basePath, int numImages, const char *fileExtension)
+ {
+ for(int i = 0; i < numImages; i++)
+ {
+ char buffer[256]={0};
+ snprintf(buffer, sizeof(buffer), "%s%d.%s", basePath, i + 1, fileExtension);
+ ImageCacheManager::GetInstance().UnloadSingleRes(buffer);
+ }
+ UIFree(array);
+ return ;
+ }
/* -------------------------------------------------------------------------- */
/**
* 创建包含图片文件路径的数组
/*生成动画资源数组*/
const char **CreateImagePathsArray(const char *basePath, int numImages, const char *fileExtension = "bin");
+ /*生成动画资源结构体*/
+ const ImageInfo**CreateImageInfoArray(const char *basePath, int numImages, const char *fileExtension = "bin");
+
+ void FreeImageInfoArray( const ImageInfo** array,const char *basePath, int numImages, const char *fileExtension = "bin");
/*释放动画资源数组*/
void FreeImagePathsArray(const char **imagePaths, int numImages);
UILabelExt *InitLabelExt(int x, int y, int w, int h, const char *text, int textfont, int lineheight);
private:
- const char **CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages);
- void FreeImagePathsArray(const char **imagePaths, const int numImages);
void DumpWeatherInfo();
std::string WeatherImag; // 天气图片
std::string Temperature; // 温度
#include "components/ui_image_view.h"
#include "components/ui_image_animator.h"
#include "components/ui_circle_progress.h"
+#include "common/image_cache_manager.h"
#include "wearable_log.h"
#include "AppGroupView.h"
private:
UILabelExt *InitLabelExt(int x, int y, int w, int h, const char *text, int textfont, int lineheight);
- private:
- void CreateImagePathsArray(const char **,const char *basePath, const char *fileExtension, int numImages);
- void FreeImagePathsArray(const char **imagePaths, const int numImages);
-
private:
UICircleProgress * circleProgress1_{nullptr}; //步数进度条
UIImageAnimatorView *PullUpAnimatorView{nullptr}; // 上拉动画
UIImageAnimatorView *stepAnimatorView{nullptr}; // 走路动画
ImageAnimatorInfo goalAnimatorInfo[20]{0};
-
- const char *PullUpPathsArray[70]{nullptr};
- const char *goalPathsArray[20]{nullptr};
+ const ImageInfo** goalAnimator_imageInfo{nullptr};
+ const ImageInfo** PullUpimageAnimator_imageInfo{nullptr};
+ // const char **PullUpPathsArray{nullptr};
+ // const char **goalPathsArray{nullptr};
bool viewInitStatus{false};
};
} // namespace OHOS
#include "goal/include/goalmodel.h"
#include "common/image_cache_manager.h"
#include "goal/include/goalview.h"
+#include "uicomponents/UIComponents.h"
/*
当至天气界面时,主动获取最新天气数据。
(此操作静默将进行,获取到则立刻更新显示,获取不到则重试
return viewInitStatus;
}
- const char **GoalotherView::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 GoalotherView::FreeImagePathsArray(const char **imagePaths, const int numImages)
- {
- for (int i = 0; i < numImages; i++)
- {
- ImageCacheManager::GetInstance().UnloadSingleRes(imagePaths[i]);
- if(imagePaths[i])
- free( (void *)imagePaths[i]);
- imagePaths[i] = nullptr;
- }
- delete imagePaths;
- imagePaths = nullptr;
- }
}
\ No newline at end of file
#include "goal/include/goalmodel.h"
#include "common/image_cache_manager.h"
#include "gfx_utils/mem_api.h"
+#include "uicomponents/UIComponents.h"
/*
当至天气界面时,主动获取最新天气数据。
(此操作静默将进行,获取到则立刻更新显示,获取不到则重试
// }
ImageCacheManager::GetInstance().UnloadSingleRes("/user/res/step/step_b.bin");
-
- FreeImagePathsArray(PullUpPathsArray, PULLUP_ANIMATOR_VIEW_NUM_FRAMES);
- FreeImagePathsArray(goalPathsArray, 20);
+ FreeImageInfoArray(goalAnimator_imageInfo,stepPaths, 20);
+ FreeImageInfoArray(PullUpimageAnimator_imageInfo,PullUpPaths, PULLUP_ANIMATOR_VIEW_NUM_FRAMES);
+ // FreeImagePathsArray(PullUpPathsArray, PULLUP_ANIMATOR_VIEW_NUM_FRAMES);
+ // FreeImagePathsArray(goalPathsArray, 20);
// if(goalAnimatorInfo)
// {
circleProgress1_->SetCapType(CAP_ROUND);
/*----------------------------------------------------------------------------- */
- CreateImagePathsArray(goalPathsArray,stepPaths, "bin", 20);
+ goalAnimator_imageInfo=CreateImageInfoArray(stepPaths, 20);
if (stepAnimatorView == nullptr)
{
stepAnimatorView = new UIImageAnimatorView();
//goalAnimatorInfo[i].imageType = IMG_SRC_IMAGE_INFO;
//goalAnimatorInfo=new ImageAnimatorInfo [20];
//goalAnimatorInfo[i].imageInfo=nullptr;
- goalAnimatorInfo[i].imageInfo = ImageCacheManager::GetInstance().LoadSingleRes(goalPathsArray[i]);
+ goalAnimatorInfo[i].imageInfo = goalAnimator_imageInfo[i];
goalAnimatorInfo[i].imageType = IMG_SRC_IMAGE_INFO;
//goalAnimatorInfo[i].imagePath = goalPathsArray[i];
- CreateImagePathsArray( PullUpPathsArray,PullUpPaths, "bin", PULLUP_ANIMATOR_VIEW_NUM_FRAMES);
+ PullUpimageAnimator_imageInfo =CreateImageInfoArray(PullUpPaths, PULLUP_ANIMATOR_VIEW_NUM_FRAMES);
if (PullUpAnimatorView == nullptr)
{
PullUpAnimatorView = new UIImageAnimatorView();
{
//PullUpimageAnimatorInfo[i].imageInfo = ImageCacheManager::GetInstance().LoadSingleRes(PullUpPathsArray[i]);
//PullUpimageAnimatorInfo[i].imageType = IMG_SRC_IMAGE_INFO;
- PullUpimageAnimatorInfo[i].imageInfo = ImageCacheManager::GetInstance().LoadSingleRes(PullUpPathsArray[i]);
+ PullUpimageAnimatorInfo[i].imageInfo = PullUpimageAnimator_imageInfo[i];
//PullUpPathsArray[i];
PullUpimageAnimatorInfo[i].imageType = IMG_SRC_IMAGE_INFO;
PullUpimageAnimatorInfo[i].pos.x = PULLUP_ANIMATOR_VIEW_X;
}
- void GoalView::CreateImagePathsArray(const char **imagePaths,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++)
- {
- imagePaths[i]=(char *)UIMalloc(128);
- memset_s((void *)imagePaths[i],128,0,128);
- snprintf(buffer, sizeof(buffer), "%s%d.%s", basePath, i + 1, fileExtension);
- memcpy_s((void*)imagePaths[i],128,(void*)buffer,128);
- // imagePaths[i] = strdup(buffer);
- //WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " imagePaths[%d] = %s", i, imagePaths[i]);
- }
- return ;
- }
-
- /*
- * @brief: 释放图片路径数组指针
- * @param {char} imagePaths 图片路径数组
- * @param {int} numImages 图片数量
- */
- void GoalView::FreeImagePathsArray(const char **imagePaths, const int numImages)
- {
- for (int i = 0; i < numImages; i++)
- {
- //ImageCacheManager::GetInstance().UnloadSingleRes(imagePaths[i]);
- ImageCacheManager::GetInstance().UnloadSingleRes(imagePaths[i]);
-
- if(imagePaths[i])
- UIFree((void*)imagePaths[i]);
- //imagePaths[i] = nullptr;
- }
- // delete[] imagePaths;
- // imagePaths=nullptr;
- }
}
\ No newline at end of file