* @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
*/
#include "NativeLauncher.h"
#include "NativeAbility.h"
#include "BaseView.h"
-
+#include "components/ui_image_animator.h"
namespace OHOS {
enum RebootPresenterNum : uint8_t {
REBOOTVIEW = 0,
class RebootView;
class RebootPresenter : public Presenter<RebootView>,
- public UIView::OnClickListener,
+ public UIView::OnClickListener,public UIImageAnimatorView::AnimatorStopListener,
public UIView::OnDragListener {
public:
RebootPresenter();
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
* @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"
{
// 重启
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)
{
// GetPMSDefaultInterface()->ShutDownDevice(NULL, NULL);
RebootView::GetInstance()->ChangeView(SHUTDOWNDEVICEVIEW, SHUTDOWNANIMATORVIEW);
ShutDownAnimatorView::GetInstance()->GeShutDownImageAnimatorView()->Start();
- if (ShutDownAnimatorView::GetInstance()->GeShutDownImageAnimatorView()->GetState() == false)
- {
- uapi_poweroff_device();
- }
}
return true;
}
}
return true;
}
+
+ void RebootPresenter::OnAnimatorStop(UIView &view)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootPresenter::OnAnimatorStop");
+ uapi_poweroff_device();
+ }
}
#include "rebootdevice/include/ShutDownAnimatorView.h"
#include "wearable_log.h"
+#include "rebootdevice/include/RebootPresenter.h"
namespace OHOS
{
group = nullptr;
}
- UIImageAnimatorView *ShutDownAnimatorView::GeShutDownImageAnimatorView(void)
+ UIImageAnimatorView *ShutDownAnimatorView::GeShutDownImageAnimatorView(void)
{
return ShutDownImageAnimatorView;
}
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;