* @Author: luozheng 1732036298@qq.com
* @Date: 2024-07-18 14:26:31
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-20 11:15:27
+ * @LastEditTime: 2024-07-30 10:25:25
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownPresenter.h
*/
void OnPause() override;
void OnStop() override;
+ private:
+ void handleSlider(UISlider *slider, bool isShutdown);
+
private:
bool OnClick(UIView &view, const ClickEvent &event) override;
bool OnDrag(UIView &view, const DragEvent &event) override;
RebootAndShutdownModel *model;
bool X_DRAG_FLAG{false};
bool isShutDownOperation{false};
+ bool isShutDownImageAnimatorStart{false};
};
}
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-06-20 15:11:17
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-27 13:03:52
+ * @LastEditTime: 2024-07-30 10:23:45
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/RebootAndShutdownPresenter.cpp
*/
#include "AppViewIDs.h"
{
RebootAndShutdownView::GetInstance()->ChangeView(FACTORYRESET, REBOOTANDSHUTDOWN);
}
- else if (strcmp(view.GetViewId(), SHUTDOWN_SLIDER_VIEWID) == 0)
+ else if (strcmp(view.GetViewId(), SHUTDOWN_SLIDER_VIEWID) == 0)
{
auto shutdownSlider = view_->GetShutdownSlider();
if (shutdownSlider != nullptr)
shutdownSlider->SetValue(SLIDER_VALUE_MIN);
}
}
- else if (strcmp(view.GetViewId(), REBOOT_SLIDER_VIEWID) == 0)
+ else if (strcmp(view.GetViewId(), REBOOT_SLIDER_VIEWID) == 0)
{
auto rebootSlider = view_->GetRebootSlider();
if (rebootSlider != nullptr)
auto shutdownSlider = view_->GetShutdownSlider();
auto rebootSlider = view_->GetRebootSlider();
- if (shutdownSlider->GetValue() < SLIDER_VALUE_MAX)
- {
- shutdownSlider->SetValue(SLIDER_VALUE_MIN);
- }
- else
- {
- shutdownSlider->SetValue(SLIDER_VALUE_MAX);
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "关机!!");
-
- RebootAndShutdownView::GetInstance()->ChangeView(REBOOTANDSHUTDOWN, SHUTDOWNANIMATOR);
-
- start_shutdown_or_reboot();
- shutdown_reboot_prejobs();
-
- ShutDownImageAnimatorView::GetInstance()->GeShutDownImageAnimatorView()->Start();
+ handleSlider(shutdownSlider, true);
+ handleSlider(rebootSlider, false);
+ }
- isShutDownOperation = true;
+ void RebootAndShutdownPresenter::handleSlider(UISlider *slider, bool isShutdown)
+ {
+ if (!slider)
+ {
+ return;
}
- if (rebootSlider->GetValue() < SLIDER_VALUE_MAX)
+ if (slider->GetValue() < SLIDER_VALUE_MAX)
{
- rebootSlider->SetValue(SLIDER_VALUE_MIN);
+ slider->SetValue(SLIDER_VALUE_MIN);
}
else
{
- rebootSlider->SetValue(SLIDER_VALUE_MAX);
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "重启!!");
- RebootAndShutdownView::GetInstance()->ChangeView(REBOOTANDSHUTDOWN, SHUTDOWNANIMATOR);
+ slider->SetValue(SLIDER_VALUE_MAX);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s!!", isShutdown ? "关机" : "重启");
+ view_->ChangeView(REBOOTANDSHUTDOWN, SHUTDOWNANIMATOR);
start_shutdown_or_reboot();
shutdown_reboot_prejobs();
- ShutDownImageAnimatorView::GetInstance()->GeShutDownImageAnimatorView()->Start();
-
- isShutDownOperation = false;
+ if (ShutDownImageAnimatorView::GetInstance() != nullptr && ShutDownImageAnimatorView::GetInstance()->GeShutDownImageAnimatorView() != nullptr)
+ {
+ ShutDownImageAnimatorView::GetInstance()->GeShutDownImageAnimatorView()->Start();
+ isShutDownImageAnimatorStart = true;
+ }
+ isShutDownOperation = isShutdown;
}
}
// 如果是power键,且是亮屏状态,按键释放就返回上一级
if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0)
{
- NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);
+ if (!isShutDownImageAnimatorStart)
+ {
+ NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);
+ }
}
return true;
}