mcu_hi3321_watch/tjd/ui/app/ota/TjdUiAppOtaPresenter.cpp
2025-05-26 20:15:20 +08:00

107 lines
2.8 KiB
C++

#include "TjdUiAppOtaPresenter.h"
#include "TjdUiAppOtaView.h"
#include "wearable_log.h"
#include "dock/input_device.h"
#include "TjdUiScreenManage.h"
#include "TjdUiRegisterManager.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "ble_api.h"
#ifdef __cplusplus
}
#endif
namespace TJD {
TJD_REGIST_SLICE(TJD_APP_VIEW_OTA, TjdUiAppOtaView, TjdUiAppOtaPresenter);
static TjdUiAppOtaPresenter *g_pv_AppOtaPresenter = nullptr;
TjdUiAppOtaPresenter::TjdUiAppOtaPresenter() { g_pv_AppOtaPresenter = this; }
TjdUiAppOtaPresenter::~TjdUiAppOtaPresenter() { g_pv_AppOtaPresenter = nullptr; }
TjdUiAppOtaPresenter *TjdUiAppOtaPresenter::GetInstance(void) { return g_pv_AppOtaPresenter; }
void TjdUiAppOtaPresenter::OnStart() {
TjdUiCommonOnKeyListener::GetInstance()->SetOnKeyActListener(this, KeyModelType::APP_KEY_TYPE);
TjdUiScreenManage::SetScreenAlwayOn();
}
void TjdUiAppOtaPresenter::OnPause()
{
Presenter::OnPause();
}
void TjdUiAppOtaPresenter::OnResume()
{
Presenter::OnResume();
}
bool TjdUiAppOtaPresenter::OnKeyAct(OHOS::UIView &view, const OHOS::KeyEvent &event)
{
if(!TjdUiCommonOnKeyListener::GetInstance()->CheckIsExitEvent(event)) {
return true;
}
return true;
// if (event.GetState() == OHOS::InputDevice::STATE_LONG_PRESS) {
// // OHOS::NativeAbility::GetInstance().ChangeSlice(TJD_APP_VIEW_MAIN);
// printf("shutdown in here!\n\r");
// return true;
// }
// return true;
}
void TjdUiAppOtaPresenter::OnStop()
{
TjdUiCommonOnKeyListener::GetInstance()->ClearOnKeyActListener(KeyModelType::APP_KEY_TYPE);
}
bool TjdUiAppOtaPresenter::OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event)
{
printf("TjdUiAppOtaPresenter onclcik\r\n");
TjdUiAppOtaView *otaView = TjdUiAppOtaView::GetInstance();
std::string viewId = view.GetViewId();
if (viewId.empty()) {
return false;
}
// if (viewId == BTN_OTA_UPGRADE_ID) {
// otaView->ShowView(OtaViewIndex::OTA_UPGRADE_VIEW, OtaViewIndex::OTA_INTERRUPT_VIEW);
// return true;
// }else
if(viewId == BTN_OTA_ENTER_ID){
// otaView->ShowView(OtaViewIndex::OTA_INTERRUPT_VIEW, OtaViewIndex::OTA_FAIL_VIEW);
OHOS::NativeAbility::GetInstance().ChangeSlice(TJD_APP_VIEW_MAIN);
return true;
}
// else if(viewId == BTN_OTA_FAIL_ID){
// otaView->ShowView(OtaViewIndex::OTA_FAIL_VIEW, OtaViewIndex::OTA_UPGRADE_VIEW);
// return true;
// }
return false;
}
bool TjdUiAppOtaPresenter::OnDragStart(OHOS::UIView &view, const OHOS::DragEvent &event)
{
return false;
}
bool TjdUiAppOtaPresenter::OnDrag(OHOS::UIView &view, const OHOS::DragEvent &event)
{
return false;
}
bool TjdUiAppOtaPresenter::OnDragEnd(OHOS::UIView &view, const OHOS::DragEvent &event)
{
return false;
}
}//tjd