/*
- * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved.
- * Description: Reboot Presenter
- * Create: 2022-04-28
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-02-21 19:06:02
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-03-20 19:47:13
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootPresenter.cpp
*/
-
-#include "RebootPresenter.h"
-#include "RebootView.h"
-#include "RebootModel.h"
+#include "rebootdevice/include/RebootPresenter.h"
+#include "rebootdevice/include/RebootView.h"
+#include "rebootdevice/include/RebootModel.h"
#include "drag_event.h"
#include "wearable_log.h"
#include "custom_utils.h"
-namespace OHOS {
-static RebootPresenter *g_pRebootPresenter = nullptr;
-
-RebootPresenter::RebootPresenter()
+#include "components/ui_image_animator.h"
+namespace OHOS
{
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootPresenter::RebootPresenter");
- g_pRebootPresenter = this;
-}
+ static RebootPresenter *g_pRebootPresenter = nullptr;
-RebootPresenter::~RebootPresenter()
-{
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootPresenter::~RebootPresenter");
- g_pRebootPresenter = nullptr;
-}
-
-RebootPresenter *RebootPresenter::GetInstance()
-{
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootPresenter GetInstance");
- return g_pRebootPresenter;
-}
-
-void RebootPresenter::OnStart()
-{
- Presenter<RebootView>::OnStart();
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootPresenter::On Start ");
-}
+ RebootPresenter::RebootPresenter()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootPresenter::RebootPresenter");
+ g_pRebootPresenter = this;
+ }
-void RebootPresenter::OnPause(void) {}
+ RebootPresenter::~RebootPresenter()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootPresenter::~RebootPresenter");
+ g_pRebootPresenter = nullptr;
+ }
-void RebootPresenter::OnResume(void) {}
+ RebootPresenter *RebootPresenter::GetInstance()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootPresenter GetInstance");
+ return g_pRebootPresenter;
+ }
-void RebootPresenter::OnStop(void) {}
+ void RebootPresenter::OnStart()
+ {
+ Presenter<RebootView>::OnStart();
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootPresenter::On Start ");
+ }
+ void RebootPresenter::OnPause(void) {}
-bool RebootPresenter::OnClick(UIView& view, const ClickEvent& event)
-{
- UNUSED(event);
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnClick OnClick");
- if (strcmp(view.GetViewId(), REBOOT_BUTTON) == 0) {
- RebootView::GetInstance()->ChangeView(REBOOTVIEW, REBOOTDEVICEVIEW);
- } else if (strcmp(view.GetViewId(), SHUTDOWN_BUTTON) == 0) {
- RebootView::GetInstance()->ChangeView(REBOOTVIEW, SHUTDOWNDEVICEVIEW);
- } else if (strcmp(view.GetViewId(), REBOOTDEVICE_BUTTON) == 0) {
- // 重启
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "REBOOTDEVICE_BUTTON OnClick");
- uapi_reboot_device();
+ void RebootPresenter::OnResume(void) {}
- } else if (strcmp(view.GetViewId(), SHUTDOWNDEVICE_BUTTON) == 0) {
- // 关机
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SHUTDOWNDEVICE_BUTTON OnClick");
- // GetPMSDefaultInterface()->ShutDownDevice(NULL, NULL);
- uapi_poweroff_device();
+ void RebootPresenter::OnStop(void) {}
+ bool RebootPresenter::OnClick(UIView &view, const ClickEvent &event)
+ {
+ UNUSED(event);
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnClick OnClick");
+ if (strcmp(view.GetViewId(), REBOOT_BUTTON) == 0)
+ {
+ RebootView::GetInstance()->ChangeView(REBOOTVIEW, REBOOTDEVICEVIEW);
+ }
+ else if (strcmp(view.GetViewId(), SHUTDOWN_BUTTON) == 0)
+ {
+ RebootView::GetInstance()->ChangeView(REBOOTVIEW, SHUTDOWNDEVICEVIEW);
+ }
+ else if (strcmp(view.GetViewId(), REBOOTDEVICE_BUTTON) == 0)
+ {
+ // 重启
+ 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();
+ }
+ }
+ else if (strcmp(view.GetViewId(), SHUTDOWNDEVICE_BUTTON) == 0)
+ {
+ // 关机
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SHUTDOWNDEVICE_BUTTON OnClick");
+ // 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;
-}
-bool RebootPresenter::OnDrag(UIView& view, const DragEvent& event)
-{
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootPresenter::OnDrag");
- if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) {
- if (strcmp(view.GetViewId(), REBOOT_VIEW) == 0) {
- NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN);
- } else if (strcmp(view.GetViewId(), REBOOTDEVICE_VIEW) == 0) {
- if (RebootModel::GetInstance()->GetExitsView() == 0) {
- RebootView::GetInstance()->ChangeView(REBOOTDEVICEVIEW, REBOOTVIEW);
- } else {
- NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING);
- RebootModel::GetInstance()->SetExitsView(false);
+ bool RebootPresenter::OnDrag(UIView &view, const DragEvent &event)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootPresenter::OnDrag");
+ if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
+ {
+ if (strcmp(view.GetViewId(), REBOOT_VIEW) == 0)
+ {
+ NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN);
+ }
+ else if (strcmp(view.GetViewId(), REBOOTDEVICE_VIEW) == 0)
+ {
+ if (RebootModel::GetInstance()->GetExitsView() == 0)
+ {
+ RebootView::GetInstance()->ChangeView(REBOOTDEVICEVIEW, REBOOTVIEW);
+ }
+ else
+ {
+ NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING);
+ RebootModel::GetInstance()->SetExitsView(false);
+ }
}
- } else if (strcmp(view.GetViewId(), SHUTDOWNDEVICE_VIEW) == 0) {
- if (RebootModel::GetInstance()->GetExitsView() == 0) {
- RebootView::GetInstance()->ChangeView(SHUTDOWNDEVICEVIEW, REBOOTVIEW);
- } else {
- NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING);
- RebootModel::GetInstance()->SetExitsView(false);
+ else if (strcmp(view.GetViewId(), SHUTDOWNDEVICE_VIEW) == 0)
+ {
+ if (RebootModel::GetInstance()->GetExitsView() == 0)
+ {
+ RebootView::GetInstance()->ChangeView(SHUTDOWNDEVICEVIEW, REBOOTVIEW);
+ }
+ else
+ {
+ NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING);
+ RebootModel::GetInstance()->SetExitsView(false);
+ }
}
}
+ return true;
}
- return true;
-}
}
* Create: 2022-04-28
*/
-#include "RebootView.h"
-#include "RebootModel.h"
+#include "rebootdevice/include/RebootView.h"
+#include "rebootdevice/include/RebootModel.h"
#include "wearable_log.h"
#include "UiConfig.h"
#include "RebootPresenter.h"
-namespace OHOS {
-static RebootView *g_pRebootView{nullptr};
-RebootView::RebootView()
-{
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView::RebootView");
- preProcessView[REBOOTVIEW] = &RebootView::ChangeRebootView;
- preProcessView[REBOOTDEVICEVIEW] = &RebootView::ChangeRebootDeviceView;
- preProcessView[SHUTDOWNDEVICEVIEW] = &RebootView::ChangeShutdownDeviceView;
- g_pRebootView = this;
-}
+static constexpr int16_t BOOT_IMAGE_ANIMATOR_VIEW_X = 0;
+static constexpr int16_t BOOT_IMAGE_ANIMATOR_VIEW_Y = 0;
+static constexpr int16_t BOOT_IMAGE_ANIMATOR_VIEW_W = 466;
+static constexpr int16_t BOOT_IMAGE_ANIMATOR_VIEW_H = 466;
+static constexpr int16_t BOOT_IMAGE_ANIMATOR_VIEW_NUM_FRAMES = 24; // 图片帧数
+static constexpr int16_t BOOT_IMAGE_ANIMATOR_TIME = 100; // 图片更新间隔
+
+static constexpr char *BootPaths = "";
-RebootView::~RebootView()
+namespace OHOS
{
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView::~RebootView");
- if (group != nullptr) {
- group->RemoveAll();
+ static RebootView *g_pRebootView{nullptr};
+ RebootView::RebootView()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView::RebootView");
+ preProcessView[REBOOTVIEW] = &RebootView::ChangeRebootView;
+ preProcessView[REBOOTDEVICEVIEW] = &RebootView::ChangeRebootDeviceView;
+ preProcessView[SHUTDOWNDEVICEVIEW] = &RebootView::ChangeShutdownDeviceView;
+ preProcessView[SHUTDOWNANIMATORVIEW] = &RebootView::ChangeShutDownAnimatorView;
+ g_pRebootView = this;
}
- delete rebootLabel;
- rebootLabel = nullptr;
- delete rebootButton;
- rebootButton = nullptr;
- delete shutdownLabel;
- shutdownLabel = nullptr;
- delete shutdownButton;
- shutdownButton = nullptr;
- delete group;
- group = nullptr;
- g_pRebootView = nullptr;
-}
-RebootView *RebootView::GetInstance()
-{
- return g_pRebootView;
-}
+ RebootView::~RebootView()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView::~RebootView");
+ if (group != nullptr)
+ {
+ group->RemoveAll();
+ }
+ delete rebootLabel;
+ rebootLabel = nullptr;
+ delete rebootButton;
+ rebootButton = nullptr;
+ delete shutdownLabel;
+ shutdownLabel = nullptr;
+ delete shutdownButton;
+ shutdownButton = nullptr;
+ delete group;
+ group = nullptr;
+ g_pRebootView = nullptr;
+ }
-void RebootView::OnStart()
-{
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView::~OnStart");
- View<RebootPresenter>::OnStart();
- BaseView::RootView(Color::Black().full);
- if (RebootModel::GetInstance()->GetSelectView() == REBOOT) {
- ChangeView(REBOOT_MAX, REBOOTVIEW);
- } else if (RebootModel::GetInstance()->GetSelectView() == REBOOTDEVICE) {
- ChangeView(REBOOT_MAX, REBOOTDEVICEVIEW);
- RebootModel::GetInstance()->SetSelectViewId(REBOOT);
- } else if (RebootModel::GetInstance()->GetSelectView() == SHUTDOWNDEVICE) {
- ChangeView(REBOOT_MAX, SHUTDOWNDEVICEVIEW);
- RebootModel::GetInstance()->SetSelectViewId(REBOOT);
+ RebootView *RebootView::GetInstance()
+ {
+ return g_pRebootView;
}
- RootView::GetInstance()->Invalidate();
- return;
-}
-void RebootView::OnSetUpView()
-{
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView::~OnSetUpView");
- View<RebootPresenter>::OnSetUpView();
- Draw();
-}
+ void RebootView::OnStart()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView::~OnStart");
+ View<RebootPresenter>::OnStart();
+ BaseView::RootView(Color::Black().full);
+ if (RebootModel::GetInstance()->GetSelectView() == REBOOT)
+ {
+ ChangeView(REBOOT_MAX, REBOOTVIEW);
+ }
+ else if (RebootModel::GetInstance()->GetSelectView() == REBOOTDEVICE)
+ {
+ ChangeView(REBOOT_MAX, REBOOTDEVICEVIEW);
+ RebootModel::GetInstance()->SetSelectViewId(REBOOT);
+ }
+ else if (RebootModel::GetInstance()->GetSelectView() == SHUTDOWNDEVICE)
+ {
+ ChangeView(REBOOT_MAX, SHUTDOWNDEVICEVIEW);
+ RebootModel::GetInstance()->SetSelectViewId(REBOOT);
+ }
+ RootView::GetInstance()->Invalidate();
+ return;
+ }
-void RebootView::OnTearDownView()
-{
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView::~OnTearDownView");
- View<RebootPresenter>::OnTearDownView();
- return;
-}
+ void RebootView::OnSetUpView()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView::~OnSetUpView");
+ View<RebootPresenter>::OnSetUpView();
+ Draw();
+ }
-void RebootView::OnStop()
-{
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView::~OnStop");
- View<RebootPresenter>::OnStop();
- if (container_ != nullptr) {
- container_->RemoveAll();
- delete container_;
- container_ = nullptr;
+ void RebootView::OnTearDownView()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView::~OnTearDownView");
+ View<RebootPresenter>::OnTearDownView();
+ return;
}
- RootView::GetInstance()->ClearOnKeyActListener();
- RootView::GetInstance()->RemoveAll();
- return;
-}
-bool RebootView::ShowUpRebootView()
-{
- if (rebootLabel == nullptr) {
- rebootLabel = new UILabel();
- if (rebootLabel == nullptr) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowUpRebootView rebootLabel new fail");
- return false;
+ void RebootView::OnStop()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView::~OnStop");
+ View<RebootPresenter>::OnStop();
+ if (container_ != nullptr)
+ {
+ container_->RemoveAll();
+ delete container_;
+ container_ = nullptr;
}
+ RootView::GetInstance()->ClearOnKeyActListener();
+ RootView::GetInstance()->RemoveAll();
+ return;
}
- rebootLabel->SetPosition(49, 272, 150, 45); // 49:x 272:y 150:width 45:height
- rebootLabel->SetText("重启");
- rebootLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); // 35:font data
- rebootLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE);
- rebootLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER,
- UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER);
- if (rebootButton == nullptr) {
- rebootButton = new UIButton();
- if (rebootButton == nullptr) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowUpRebootView rebootButton new fail");
- return false;
+ bool RebootView::ShowUpRebootView()
+ {
+ if (rebootLabel == nullptr)
+ {
+ rebootLabel = new UILabel();
+ if (rebootLabel == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowUpRebootView rebootLabel new fail");
+ return false;
+ }
}
- }
- rebootButton->SetPosition(69, 147, 110, 110); // 69:x 147:y 110:width 110:height
- rebootButton->SetImageSrc(PNG_REBOOT_BUTTON_IMAGE, PNG_REBOOT_BUTTON_IMAGE);
- rebootButton->SetViewId(REBOOT_BUTTON);
- UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::RebootPresenter::GetInstance();
- if (clickListener == nullptr) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance nullptr");
- return false;
- }
- rebootButton->SetOnClickListener(clickListener);
- return true;
-}
+ rebootLabel->SetPosition(49, 272, 150, 45); // 49:x 272:y 150:width 45:height
+ rebootLabel->SetText("重启");
+ rebootLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); // 35:font data
+ rebootLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE);
+ rebootLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER,
+ UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER);
-bool RebootView::ShowUpShutdownView()
-{
- if (shutdownLabel == nullptr) {
- shutdownLabel = new UILabel();
- if (shutdownLabel == nullptr) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowUpShutdownView shutdownLabel new fail");
+ if (rebootButton == nullptr)
+ {
+ rebootButton = new UIButton();
+ if (rebootButton == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowUpRebootView rebootButton new fail");
+ return false;
+ }
+ }
+ rebootButton->SetPosition(69, 147, 110, 110); // 69:x 147:y 110:width 110:height
+ rebootButton->SetImageSrc(PNG_REBOOT_BUTTON_IMAGE, PNG_REBOOT_BUTTON_IMAGE);
+ rebootButton->SetViewId(REBOOT_BUTTON);
+ UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::RebootPresenter::GetInstance();
+ if (clickListener == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance nullptr");
return false;
}
+ rebootButton->SetOnClickListener(clickListener);
+ return true;
}
- shutdownLabel->SetPosition(255, 272, 150, 45); // 255:x 272:y 150:width 45:height
- shutdownLabel->SetText("关机");
- shutdownLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); // 35:font data
- shutdownLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE);
- shutdownLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER,
- UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER);
- if (shutdownButton == nullptr) {
- shutdownButton = new UIButton();
- if (shutdownButton == nullptr) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowUpShutdownView shutdownButton new fail");
+ bool RebootView::ShowUpShutdownView()
+ {
+ if (shutdownLabel == nullptr)
+ {
+ shutdownLabel = new UILabel();
+ if (shutdownLabel == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowUpShutdownView shutdownLabel new fail");
+ return false;
+ }
+ }
+ shutdownLabel->SetPosition(255, 272, 150, 45); // 255:x 272:y 150:width 45:height
+ shutdownLabel->SetText("关机");
+ shutdownLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); // 35:font data
+ shutdownLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE);
+ shutdownLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER,
+ UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER);
+
+ if (shutdownButton == nullptr)
+ {
+ shutdownButton = new UIButton();
+ if (shutdownButton == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowUpShutdownView shutdownButton new fail");
+ return false;
+ }
+ }
+ shutdownButton->SetPosition(275, 147, 110, 110); // 275:x 147:y 110:width 110:height
+ shutdownButton->SetImageSrc(PNG_SHUTDOWN_BUTTON_IMAGE, PNG_SHUTDOWN_BUTTON_IMAGE);
+ shutdownButton->SetViewId(SHUTDOWN_BUTTON);
+ UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::RebootPresenter::GetInstance();
+ if (clickListener == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance nullptr");
return false;
}
+ shutdownButton->SetOnClickListener(clickListener);
+ return true;
}
- shutdownButton->SetPosition(275, 147, 110, 110); // 275:x 147:y 110:width 110:height
- shutdownButton->SetImageSrc(PNG_SHUTDOWN_BUTTON_IMAGE, PNG_SHUTDOWN_BUTTON_IMAGE);
- shutdownButton->SetViewId(SHUTDOWN_BUTTON);
- UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::RebootPresenter::GetInstance();
- if (clickListener == nullptr) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance nullptr");
- return false;
- }
- shutdownButton->SetOnClickListener(clickListener);
- return true;
-}
-UIViewGroup *RebootView::InitShowUpView(void)
-{
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView::InitShowUpView");
- bool ret;
- if (group == nullptr) {
- group = new UIViewGroup();
- if (group == nullptr) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail");
+ /*
+ * @brief 初始化开关机视图
+ */
+ UIViewGroup *RebootView::InitShowUpView(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView::InitShowUpView");
+ bool ret;
+ if (group == nullptr)
+ {
+ group = new UIViewGroup();
+ if (group == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail");
+ return nullptr;
+ }
+ group->SetPosition(0, 0); // 0:x; 0:y
+ group->SetWidth(HORIZONTAL_RESOLUTION);
+ group->SetHeight(VERTICAL_RESOLUTION);
+ }
+ ret = ShowUpRebootView();
+ if (ret == false)
+ {
return nullptr;
}
- group->SetPosition(0, 0); // 0:x; 0:y
- group->SetWidth(HORIZONTAL_RESOLUTION);
- group->SetHeight(VERTICAL_RESOLUTION);
- }
- ret = ShowUpRebootView();
- if (ret == false) {
- return nullptr;
- }
- group->Add(rebootLabel);
- group->Add(rebootButton);
+ group->Add(rebootLabel);
+ group->Add(rebootButton);
- ret = ShowUpShutdownView();
- if (ret == false) {
- return nullptr;
- }
- group->Add(shutdownLabel);
- group->Add(shutdownButton);
- UIView::OnDragListener *rebootDragListener = (UIView::OnDragListener *)OHOS::RebootPresenter::GetInstance();
- if (rebootDragListener == nullptr) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rebootDragListener GetInstance fail");
- return nullptr;
- }
- group->SetOnDragListener(rebootDragListener);
- group->SetViewId(REBOOT_VIEW);
- group->SetDraggable(true);
- group->SetTouchable(true);
- return group;
-}
-
-bool RebootView::ChangeRebootView(int16_t hideView, int16_t thisView)
-{
- UNUSED(hideView);
- // init view
- UIViewGroup *group = InitShowUpView();
- if (group == nullptr) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail");
- return false;
+ ret = ShowUpShutdownView();
+ if (ret == false)
+ {
+ return nullptr;
+ }
+ group->Add(shutdownLabel);
+ group->Add(shutdownButton);
+ UIView::OnDragListener *rebootDragListener = (UIView::OnDragListener *)OHOS::RebootPresenter::GetInstance();
+ if (rebootDragListener == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rebootDragListener GetInstance fail");
+ return nullptr;
+ }
+ group->SetOnDragListener(rebootDragListener);
+ group->SetViewId(REBOOT_VIEW);
+ group->SetDraggable(true);
+ group->SetTouchable(true);
+ return group;
}
- container[thisView] = group;
- RootView::GetInstance()->Add(container[thisView]);
- return true;
-}
-bool RebootView::ChangeRebootDeviceView(int16_t hideView, int16_t thisView)
-{
- UNUSED(hideView);
- if (container[thisView] == nullptr) {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeRebootDeviceView");
- rebootDeviceView = new RebootDeviceView();
- if (rebootDeviceView == nullptr) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rebootDeviceView new fail");
- return false;
- }
+ /*
+ * @brief 切换到重启和开关机视图
+ */
+ bool RebootView::ChangeRebootView(int16_t hideView, int16_t thisView)
+ {
+ UNUSED(hideView);
// init view
- UIViewGroup *group = rebootDeviceView->InitShowUpView();
- if (group == nullptr) {
+ UIViewGroup *group = InitShowUpView();
+ if (group == nullptr)
+ {
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail");
return false;
}
container[thisView] = group;
RootView::GetInstance()->Add(container[thisView]);
+ return true;
}
- return true;
-}
-bool RebootView::ChangeShutdownDeviceView(int16_t hideView, int16_t thisView)
-{
- UNUSED(hideView);
- if (container[thisView] == nullptr) {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeShutdownDeviceView");
- shutdownDeviceView = new ShutdownDeviceView();
- if (shutdownDeviceView == nullptr) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "shutdownDeviceView new fail");
- return false;
- }
- // init view
- UIViewGroup *group = shutdownDeviceView->InitShowUpView();
- if (group == nullptr) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail");
- return false;
+ /*
+ * @brief 切换到重启设备视图
+ */
+ bool RebootView::ChangeRebootDeviceView(int16_t hideView, int16_t thisView)
+ {
+ UNUSED(hideView);
+ if (container[thisView] == nullptr)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeRebootDeviceView");
+ rebootDeviceView = new RebootDeviceView();
+ if (rebootDeviceView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rebootDeviceView new fail");
+ return false;
+ }
+ // init view
+ UIViewGroup *group = rebootDeviceView->InitShowUpView();
+ if (group == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail");
+ return false;
+ }
+ container[thisView] = group;
+ RootView::GetInstance()->Add(container[thisView]);
}
- container[thisView] = group;
- RootView::GetInstance()->Add(container[thisView]);
+ return true;
}
- return true;
-}
-bool RebootView::CheckViewParam(int16_t hideView, int16_t showView)
-{
- if (showView < 0 || showView >= REBOOT_MAX) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootView::CheckViewParam showView err.");
- return false;
+ /*
+ * @brief 切换到开启设备视图
+ */
+ bool RebootView::ChangeShutdownDeviceView(int16_t hideView, int16_t thisView)
+ {
+ UNUSED(hideView);
+ if (container[thisView] == nullptr)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeShutdownDeviceView");
+ shutdownDeviceView = new ShutdownDeviceView();
+ if (shutdownDeviceView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "shutdownDeviceView new fail");
+ return false;
+ }
+ // init view
+ UIViewGroup *group = shutdownDeviceView->InitShowUpView();
+ if (group == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail");
+ return false;
+ }
+ container[thisView] = group;
+ RootView::GetInstance()->Add(container[thisView]);
+ }
+ return true;
}
- if (hideView < 0 || hideView > REBOOT_MAX) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootView::CheckViewParam hideView err.");
- return false;
+ /*
+ * @brief 切换到关机动画视图
+ */
+ bool RebootView::ChangeShutDownAnimatorView(int16_t hideView, int16_t thisView)
+ {
+ UNUSED(hideView);
+ if (container[thisView] == nullptr)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeShutdownDeviceView");
+ shutDownAnimatorView = new ShutDownAnimatorView();
+ if (shutDownAnimatorView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "shutDownAnimatorView new fail");
+ return false;
+ }
+ UIViewGroup *group = shutDownAnimatorView->ShutDownAnimatorViewInit();
+ if (group == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail");
+ return false;
+ }
+ container[thisView] = group;
+ RootView::GetInstance()->Add(container[thisView]);
+ }
+ return true;
}
- return true;
-}
+ /*
+ * @brief 用于检查传递给 ChangeView 方法的视图索引参数是否有效
+ */
+ bool RebootView::CheckViewParam(int16_t hideView, int16_t showView)
+ {
+ if (showView < 0 || showView >= REBOOT_MAX)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootView::CheckViewParam showView err.");
+ return false;
+ }
-void RebootView::ChangeView(int16_t hideView, int16_t showView)
-{
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView::ChangeView %d, %d", hideView, showView);
+ if (hideView < 0 || hideView > REBOOT_MAX)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootView::CheckViewParam hideView err.");
+ return false;
+ }
- if (CheckViewParam(hideView, showView) == false) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootView::CheckViewParam failed.");
- return;
+ return true;
}
- PreprosssChangeView tmpPreProcessView = preProcessView[showView];
+ /*
+ * @brief 执行视图切换逻辑
+ */
+ void RebootView::ChangeView(int16_t hideView, int16_t showView)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView::ChangeView %d, %d", hideView, showView);
- if ((this->*tmpPreProcessView)(hideView, showView) == false) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootView::ChangeView %d %dfailed", showView, hideView);
- return;
- }
- if (hideView != REBOOT_MAX) {
- if (container[hideView] == nullptr) {
+ if (CheckViewParam(hideView, showView) == false)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootView::CheckViewParam failed.");
+ return;
+ }
+
+ PreprosssChangeView tmpPreProcessView = preProcessView[showView];
+
+ if ((this->*tmpPreProcessView)(hideView, showView) == false)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootView::ChangeView %d %dfailed", showView, hideView);
return;
}
- container[hideView]->SetVisible(false);
+ if (hideView != REBOOT_MAX)
+ {
+ if (container[hideView] == nullptr)
+ {
+ return;
+ }
+ container[hideView]->SetVisible(false);
+ }
+ container[showView]->SetVisible(true);
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView:: ChangeView end!!!%d", showView);
+ RootView::GetInstance()->Invalidate();
}
- container[showView]->SetVisible(true);
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView:: ChangeView end!!!%d", showView);
- RootView::GetInstance()->Invalidate();
-}
+
}