From ab76b30cefad8d2e8cddd516150314d4a090689f Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Wed, 20 Mar 2024 20:34:50 +0800 Subject: [PATCH] =?utf8?q?=E8=A7=A3=E5=86=B3=E5=85=B3=E6=9C=BA=E9=87=8D?= =?utf8?q?=E5=A4=8D=E6=92=AD=E6=94=BE=E5=85=B3=E6=9C=BA=E5=8A=A8=E7=94=BB?= =?utf8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../rebootdevice/include/RebootPresenter.h | 8 ++++---- .../rebootdevice/src/RebootPresenter.cpp | 19 ++++++++----------- .../rebootdevice/src/ShutDownAnimatorView.cpp | 12 +++++++++++- 3 files changed, 23 insertions(+), 16 deletions(-) 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; -- 2.17.1