解决关机重复播放关机动画问题
authorluozheng <1732036298@qq.com>
Wed, 20 Mar 2024 12:34:50 +0000 (20:34 +0800)
committerluozheng <1732036298@qq.com>
Wed, 20 Mar 2024 12:34:50 +0000 (20:34 +0800)
code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootPresenter.h
code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/ShutDownAnimatorView.cpp

index 7037daf..990884f 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-01-29 15:37:44
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-03-20 16:57:59
+ * @LastEditTime: 2024-03-20 20:25:14
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootPresenter.h
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -19,7 +19,7 @@
 #include "NativeLauncher.h"
 #include "NativeAbility.h"
 #include "BaseView.h"
-
+#include "components/ui_image_animator.h"
 namespace OHOS {
 enum RebootPresenterNum : uint8_t {
         REBOOTVIEW = 0,
@@ -40,7 +40,7 @@ enum RebootPresenterNum : uint8_t {
 
 class RebootView;
 class RebootPresenter : public Presenter<RebootView>,
-                        public UIView::OnClickListener,
+                        public UIView::OnClickListener,public UIImageAnimatorView::AnimatorStopListener, 
                         public UIView::OnDragListener {
 public:
     RebootPresenter();
@@ -52,7 +52,7 @@ public:
     void OnStop() override;
     bool OnClick(UIView& view, const ClickEvent& event) override;
     bool OnDrag(UIView& view, const DragEvent& event) override;
-
+    virtual void OnAnimatorStop(UIView &view) override;
 private:
 };
 } // namespace OHOS
index da11427..004af71 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-02-21 19:06:02
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-03-20 19:47:13
+ * @LastEditTime: 2024-03-20 20:30:01
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootPresenter.cpp
  */
 #include "rebootdevice/include/RebootPresenter.h"
@@ -62,12 +62,7 @@ namespace OHOS
         {
             // 重启
             WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "REBOOTDEVICE_BUTTON OnClick");
-            RebootView::GetInstance()->ChangeView(REBOOTDEVICEVIEW, SHUTDOWNANIMATORVIEW);
-            ShutDownAnimatorView::GetInstance()->GeShutDownImageAnimatorView()->Start();
-            if (ShutDownAnimatorView::GetInstance()->GeShutDownImageAnimatorView()->GetState() == false)
-            {
-                uapi_reboot_device();
-            }
+            uapi_reboot_device();
         }
         else if (strcmp(view.GetViewId(), SHUTDOWNDEVICE_BUTTON) == 0)
         {
@@ -76,10 +71,6 @@ namespace OHOS
             // GetPMSDefaultInterface()->ShutDownDevice(NULL, NULL);
             RebootView::GetInstance()->ChangeView(SHUTDOWNDEVICEVIEW, SHUTDOWNANIMATORVIEW);
             ShutDownAnimatorView::GetInstance()->GeShutDownImageAnimatorView()->Start();
-            if (ShutDownAnimatorView::GetInstance()->GeShutDownImageAnimatorView()->GetState() == false)
-            {
-                uapi_poweroff_device();
-            }
         }
         return true;
     }
@@ -120,4 +111,10 @@ namespace OHOS
         }
         return true;
     }
+
+    void RebootPresenter::OnAnimatorStop(UIView &view)
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootPresenter::OnAnimatorStop");
+        uapi_poweroff_device();
+    }
 }
index fda96c0..953902f 100644 (file)
@@ -1,5 +1,6 @@
 #include "rebootdevice/include/ShutDownAnimatorView.h"
 #include "wearable_log.h"
+#include "rebootdevice/include/RebootPresenter.h"
 namespace OHOS
 {
 
@@ -56,7 +57,7 @@ namespace OHOS
         group = nullptr;
     }
 
-        UIImageAnimatorView *ShutDownAnimatorView::GeShutDownImageAnimatorView(void)
+    UIImageAnimatorView *ShutDownAnimatorView::GeShutDownImageAnimatorView(void)
     {
         return ShutDownImageAnimatorView;
     }
@@ -87,6 +88,15 @@ namespace OHOS
             ShutDownImageAnimatorView->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
             ShutDownImageAnimatorView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
             ShutDownImageAnimatorView->SetImageAnimatorSrc(ShutDownImageInfo, SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES, 100);
+            ShutDownImageAnimatorView->SetRepeat(false);
+            ShutDownImageAnimatorView->SetRepeatTimes(1);
+            UIImageAnimatorView::AnimatorStopListener *stoplistener = static_cast<UIImageAnimatorView::AnimatorStopListener *>(RebootPresenter::GetInstance());
+            if (stoplistener == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to Create stoplistener!!");
+                return false;
+            }
+            ShutDownImageAnimatorView->SetAnimatorStopListener(stoplistener);
         }
 
         return true;