From: xue <2144439972@qq.com> Date: Sat, 7 Feb 2026 06:12:01 +0000 (+0800) Subject: 优化活动目标达成弹窗动画 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=0ab2d284ce81ad49ca64ae338ca8b0aea2f78d51;p=mirrors%2FFD230.git 优化活动目标达成弹窗动画 --- diff --git a/code/sdk/application/wearable/fd272/service/msg_center/src/notify/goal_notification.cpp b/code/sdk/application/wearable/fd272/service/msg_center/src/notify/goal_notification.cpp index 33915881b..5395dbb44 100644 --- a/code/sdk/application/wearable/fd272/service/msg_center/src/notify/goal_notification.cpp +++ b/code/sdk/application/wearable/fd272/service/msg_center/src/notify/goal_notification.cpp @@ -5,6 +5,7 @@ #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" @@ -29,11 +30,20 @@ #ifdef SUPPORT_BLE_SERVICE #include "bleEvent.h" #endif +#include + 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}; /*达成训练目标弹窗*/ @@ -44,9 +54,10 @@ namespace OHOS 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; @@ -83,12 +94,8 @@ namespace OHOS if (imageAnimator) { imageAnimator->Stop(); - FreeImageInfoArray(winimageInfos, winbasePath.c_str(), 94); delete imageAnimator; imageAnimator = nullptr; - - delete[] winimageAnimatorInfo; - winimageAnimatorInfo = nullptr; } if (GoalviewShow_timer) { @@ -273,12 +280,34 @@ namespace OHOS 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;