#include "UiConfig.h"
#include "AlarmPopUpPresenter.h"
#include "components/ui_image_view.h"
+#include "components/ui_image_animator.h"
#include "components/ui_label.h"
#include "components/ui_label_ext.h"
#include "components/ui_label_button_ext.h"
#ifdef SUPPORT_BLE_SERVICE
#include "bleEvent.h"
#endif
+#include <cstdio>
+
namespace OHOS
{
#define BUTTONWINOK "buttom_win"
+ /* 与运动目标达成弹窗一致的动画参数 */
+ static constexpr uint16_t GOAL_WIN_IMAGE_POS_X = 173;
+ static constexpr uint16_t GOAL_WIN_IMAGE_POS_Y = 100;
+ static constexpr uint16_t GOAL_WIN_IMAGE_SIZE = 120;
+ static constexpr uint16_t GOAL_WIN_ANIMATOR_FRAMES = 94;
+ static constexpr uint16_t GOAL_WIN_ANIMATOR_SPEED = 30;
+
static UIScrollView *getView{nullptr};
/*达成训练目标弹窗*/
static UILabelExt *labelpre = nullptr;
static UILabelButtonExt *buttonok_ = nullptr;
static UIImageAnimatorView *imageAnimator{nullptr};
- static const ImageInfo **winimageInfos{nullptr};
- static ImageAnimatorInfo *winimageAnimatorInfo{nullptr};
- static std::string winbasePath = "/user/res/Training/training_GIF/win/";
+ /* 与运动目标达成弹窗相同的静态动画资源(文件路径 + ImageAnimatorInfo) */
+ static char g_goalWinPaths[GOAL_WIN_ANIMATOR_FRAMES][64];
+ static ImageAnimatorInfo g_goalWinAnimatorInfo[GOAL_WIN_ANIMATOR_FRAMES];
+ static bool g_goalWinAnimatorInfoInited = false;
static osTimerId_t GoalviewShow_timer = NULL;
if (imageAnimator)
{
imageAnimator->Stop();
- FreeImageInfoArray(winimageInfos, winbasePath.c_str(), 94);
delete imageAnimator;
imageAnimator = nullptr;
-
- delete[] winimageAnimatorInfo;
- winimageAnimatorInfo = nullptr;
}
if (GoalviewShow_timer)
{
InitLabel(labeltag, 70, 215, 326, 97, "label2", tagString.c_str(),DEFAULT_VECTOR_FONT_FILENAME, 80);
labeltag->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff));
labeltag->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
- // 初始化图片数组以及动画
- winimageInfos = CreateImageInfoArray(winbasePath.c_str(), 94);
- winimageAnimatorInfo = new ImageAnimatorInfo[94];
- InitImageAnimatorSource(imageAnimator, winimageAnimatorInfo, winimageInfos,
- 94, 173, 100, 120, 120, "imageAnimator1", 10);
- imageAnimator->Start();
+ /* 与运动目标达成弹窗相同的动画绘制:静态 ImageAnimatorInfo + SetImageAnimatorSrc */
+ if (!g_goalWinAnimatorInfoInited)
+ {
+ for (int i = 0; i < GOAL_WIN_ANIMATOR_FRAMES; i++)
+ {
+ snprintf(g_goalWinPaths[i], sizeof(g_goalWinPaths[i]),
+ "/user/res/Training/training_GIF/win/%d.bin", i + 1);
+ g_goalWinAnimatorInfo[i].imagePath = g_goalWinPaths[i];
+ g_goalWinAnimatorInfo[i].pos.x = GOAL_WIN_IMAGE_POS_X;
+ g_goalWinAnimatorInfo[i].pos.y = GOAL_WIN_IMAGE_POS_Y;
+ g_goalWinAnimatorInfo[i].width = GOAL_WIN_IMAGE_SIZE;
+ g_goalWinAnimatorInfo[i].height = GOAL_WIN_IMAGE_SIZE;
+ g_goalWinAnimatorInfo[i].imageType = IMG_SRC_FILE_PATH;
+ }
+ g_goalWinAnimatorInfoInited = true;
+ }
+ if (imageAnimator == nullptr)
+ {
+ imageAnimator = new UIImageAnimatorView();
+ }
+ if (imageAnimator != nullptr)
+ {
+ imageAnimator->SetImageAnimatorSrc(g_goalWinAnimatorInfo,
+ GOAL_WIN_ANIMATOR_FRAMES,
+ GOAL_WIN_ANIMATOR_SPEED);
+ imageAnimator->SetRepeat(true);
+ imageAnimator->Start();
+ }
}
static uint8_t GoalviewShowCallBack_FALG = 0;