提醒视图中:解绑设备gif设置
author罗正yun <1732036298@qq.com>
Wed, 20 Dec 2023 08:32:41 +0000 (16:32 +0800)
committer罗正yun <1732036298@qq.com>
Wed, 20 Dec 2023 08:32:41 +0000 (16:32 +0800)
code/sdk/application/wearable/nativeapp/nativeui/remind/include/RemindView3.h
code/sdk/application/wearable/nativeapp/nativeui/remind/src/MainRemindView.cpp
code/sdk/application/wearable/nativeapp/nativeui/remind/src/RemindView3.cpp

index 31e5bbb..cd746cf 100644 (file)
@@ -7,6 +7,7 @@
 #include "components/ui_label.h"
 #include "components/ui_image_animator.h"
 #include "components/ui_button.h"
+#include "traing/include/TraingWinView.h"
 namespace OHOS
 {
     class RemindView3
@@ -23,6 +24,8 @@ namespace OHOS
     private:
         UIScrollView *scrollView1_ = nullptr;
         UIImageAnimatorView *UnBindImageAnimator = nullptr; //解绑的图标动画
+        const char **CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages);
+        TraingWinView *p_TraingWinView{nullptr}; 
         UILabel *label11_ = nullptr;
         UILabel *label2_ = nullptr;
         UILabel *label1_ = nullptr;
index 04f848d..b02028f 100644 (file)
@@ -222,7 +222,7 @@ namespace OHOS
         {
             InitView();
             viewInitStatus = true;
-            ChangeView(0, 5);
+            ChangeView(0, 3);
         }
     }
     void MainRemindView::OnStart()
index 04357ab..74b6e64 100644 (file)
@@ -3,12 +3,6 @@
 
 namespace OHOS
 {
-
-    static ImageAnimatorInfo g_imageAnimator1Info[2] = {
-        {"/user/res/1.bin", {193, 112}, 80, 80, IMG_SRC_FILE_PATH},
-        {"/user/res/15.bin", {193, 112}, 80, 80, IMG_SRC_FILE_PATH},//图片桢有52张
-    };
-    /* -------------------------------------------------------------------------- */
     static RemindView3 *g_pRemindView2{nullptr};
 
     RemindView3::RemindView3()
@@ -31,6 +25,25 @@ namespace OHOS
         return g_pRemindView2;
     }
 
+    /**
+     * 创建包含图片文件路径的数组
+     * @param  basePath  包含图片文件的基本路径
+     * @param  fileExtension  图片文件的扩展名
+     * @param  numImages  图片文件的数量
+     * @return  返回包含图片文件路径的数组
+     */
+    const char **RemindView3::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);
+        }
+        return imagePaths;
+    }
+
     // 提醒视图3:进行设备解绑时弹出该视图
     UIScrollView *RemindView3::InitRemindView3()
     {
@@ -64,24 +77,15 @@ namespace OHOS
         scrollView1_->Add(label11_);
         label11_->SetVisible(true);
         /* -------------------------------------------------------------------------- */
-        // Add ImageAnimatorView to App
-        if (UnBindImageAnimator == nullptr)
+        if (p_TraingWinView == nullptr)
         {
-            UnBindImageAnimator = new UIImageAnimatorView();
+           p_TraingWinView = new TraingWinView();
         }
-        UnBindImageAnimator->SetPosition(193, 112);
-        UnBindImageAnimator->Resize(80, 80);
-        UnBindImageAnimator->SetViewId("imageAnimator1");
-        UnBindImageAnimator->SetStyle(STYLE_BACKGROUND_COLOR, 0x00);
-        UnBindImageAnimator->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
-
-        // Set additional property
-        UnBindImageAnimator->SetImageAnimatorSrc(g_imageAnimator1Info, 2, 200);
-        UnBindImageAnimator->SetTimeOfPause(200);
-        UnBindImageAnimator->SetRepeatTimes(1);
-        UnBindImageAnimator->SetReverse(true);
+        /* -------------------------------------------------------------------------- */
+        const char **imagePaths = CreateImagePathsArray("/user/res/remind/unbind/","bin",52);
+        p_TraingWinView->InitImageAnimatorSource(UnBindImageAnimator, imagePaths,52,193,118,80,80,"imageAnimator1",50);
         UnBindImageAnimator->Start();
-
+        /* -------------------------------------------------------------------------- */
         // Add to scrollView1
         scrollView1_->Add(UnBindImageAnimator);
         UnBindImageAnimator->SetVisible(true);