From f44228db04a16b38c929c50ca2ba78147b57056d Mon Sep 17 00:00:00 2001 From: zhirong <215782872@qq.com> Date: Mon, 18 Jul 2022 20:43:52 +0800 Subject: [PATCH] animationTransitionController callback Signed-off-by: zhirong <215782872@qq.com> Change-Id: Ic49169bc485b4792f3a6d9c939037c2914e147d9 --- wm/src/window_impl.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/wm/src/window_impl.cpp b/wm/src/window_impl.cpp index dc8d7477..dc37c8fe 100755 --- a/wm/src/window_impl.cpp +++ b/wm/src/window_impl.cpp @@ -1044,11 +1044,6 @@ WMError WindowImpl::Show(uint32_t reason, bool withAnimation) if (ret == WMError::WM_OK || ret == WMError::WM_ERROR_DEATH_RECIPIENT) { state_ = WindowState::STATE_SHOWN; NotifyAfterForeground(); - uint32_t animationFlag = property_->GetAnimationFlag(); - if (animationFlag == static_cast(WindowAnimation::CUSTOM)) { - // CustomAnimation is enabled when animationTranistionController_ exists - animationTranistionController_->AnimationForShown(); - } } else if (ret == WMError::WM_ERROR_INVALID_WINDOW_MODE_OR_SIZE) { NotifyForegroundInvalidWindowMode(); } else { @@ -1705,6 +1700,22 @@ void WindowImpl::RegisterAnimationTransitionController(const sptr propertyToken(property_); + wptr animationTransitionControllerToken(animationTranistionController_); + if (uiContent_) { + uiContent_->SetNextFrameLayoutCallback([propertyToken, animationTransitionControllerToken]() { + auto property = propertyToken.promote(); + auto animationTransitionController = animationTransitionControllerToken.promote(); + if (!property || !animationTransitionController) { + return; + } + uint32_t animationFlag = property->GetAnimationFlag(); + if (animationFlag == static_cast(WindowAnimation::CUSTOM)) { + // CustomAnimation is enabled when animationTranistionController_ exists + animationTransitionController->AnimationForShown(); + } + }); + } } void WindowImpl::RegisterScreenshotListener(const sptr& listener)