From: luozheng <1732036298@qq.com> Date: Wed, 20 Mar 2024 12:34:50 +0000 (+0800) Subject: 解决关机重复播放关机动画问题 X-Git-Tag: release_V1.2.70_20241020_135402~1250^2~19^2~2 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=ab76b30cefad8d2e8cddd516150314d4a090689f;p=mirrors%2FFD230.git 解决关机重复播放关机动画问题 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootPresenter.h index 7037daf40..990884f67 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootPresenter.h @@ -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, - 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 diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootPresenter.cpp index da114272e..004af7144 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootPresenter.cpp @@ -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(); + } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/ShutDownAnimatorView.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/ShutDownAnimatorView.cpp index fda96c0a1..953902f82 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/ShutDownAnimatorView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/ShutDownAnimatorView.cpp @@ -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(RebootPresenter::GetInstance()); + if (stoplistener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to Create stoplistener!!"); + return false; + } + ShutDownImageAnimatorView->SetAnimatorStopListener(stoplistener); } return true;