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

65 lines
1.9 KiB
C++

#include "TjdUiAppOpenLogoView.h"
#include "NativeAbility.h"
#include "sql_bt.h"
#include "service_startup.h"
extern "C" {
#include "pm.h"
}
using namespace OHOS;
namespace TJD {
TjdUiOpenLogoView *g_pv_TjdUiOpenLogoView = nullptr;
TjdUiOpenLogoView::TjdUiOpenLogoView() { g_pv_TjdUiOpenLogoView = this; }
TjdUiOpenLogoView::~TjdUiOpenLogoView() { g_pv_TjdUiOpenLogoView = nullptr; }
TjdUiOpenLogoView *TjdUiOpenLogoView::GetInstance() { return g_pv_TjdUiOpenLogoView; }
void TjdUiOpenLogoView::OnStart()
{
uapi_pm_add_sleep_veto(PM_ID_SCREEN);
printf("TjdUiOpenLogoView::OnStart\n");
containerAll_ = new UIViewGroup();
containerAll_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
logo_ = new OpenLogoAnimator();
logo_->SetPosition(78, 129, 308, 222);
logo_->SetAutoEnable(false);
logo_->SetResizeMode(OHOS::UIImageView::CENTER);
logo_->SetAnimatorStopListener(logo_);
logo_->SetImageAnimatorSrc(presenter_->GetAnimatorInfo(), IMAGE_NUM, 150);
logo_->SetRepeat(false);
containerAll_->Add(logo_);
AddViewToRootContainer(containerAll_);
logo_->Start();
}
void TjdUiOpenLogoView::OnStop()
{
printf("TjdUiOpenLogoView::OnStop\n");
if (containerAll_ != nullptr) {
delete containerAll_;
containerAll_ = nullptr;
}
if (logo_ != nullptr) {
delete logo_;
logo_ = nullptr;
}
}
OpenLogoAnimator::OpenLogoAnimator() {
timer = new OHOS::GraphicTimer(2000, [](void* arg){
if(sql_bt_get_start_complete_flag()) {
NativeAbility::GetInstance().ChangeSlice(TJD_APP_VIEW_MAIN);
tjd_service_startup_task_ui_update(true);
} else {
NativeAbility::GetInstance().ChangeSlice(TJD_APP_VIEW_STARTUP);
}
uapi_pm_remove_sleep_veto(PM_ID_SCREEN);
}, nullptr);
}
} // namespace TJD