osTimerId_t Chargeing_timer= NULL;
// 实际的UI更新逻辑(在图形线程中执行)
- static void Chargeing_Timer_CallBackProc(int data) {
- // 检查必要的UI组件是否存在(batteryprogress可能为nullptr,不影响更新)
+ static void Chargeing_Timer_CallBackProc(int data)
+ {
if (UIViewGroup_charge == nullptr ||
UILabel_power == nullptr ||
UILabel_time == nullptr) {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Chargeing_Timer_CallBackProc: UI组件为空,跳过更新");
return;
}
}
// 定时器回调函数(通过PostGraphicEvent投递到图形线程)
- void Chargeing_Timer_CallBack(int data) {
+ void Chargeing_Timer_CallBack(int data)
+ {
GraphicService::GetInstance()->PostGraphicEvent(
std::bind(Chargeing_Timer_CallBackProc, data));
}
{
if (UIViewGroup_charge != nullptr)
{
-
- if(Chargeing_timer)
- {
- osTimerStop(Chargeing_timer);
- osTimerDelete(Chargeing_timer);
- Chargeing_timer = NULL;
- }
-
- UIViewGroup_charge->RemoveAll();
-
- // if (batteryprogress) {
- // delete batteryprogress;
- // batteryprogress = nullptr;
- // }
-
- if(image_lightning)
- {
- delete image_lightning;
- image_lightning = nullptr;
- }
-
- if(UILabel_time)
- {
- delete UILabel_time;
- UILabel_time = nullptr;
- }
-
- if(UILabel_power)
- {
- delete UILabel_power;
- UILabel_power = nullptr;
-
- }
-
- if (chargeAnimatorView)
- {
- chargeAnimatorView->Stop();
- delete chargeAnimatorView;
- chargeAnimatorView = nullptr;
- }
- if (ChargeAnimationInfoArray)
- {
- FreeImageInfoArray(ChargeAnimationInfoArray, ChargeAnimationPaths,
- CHARGE_ANIMATION_VIEW_NUM_FRAMES);
- ChargeAnimationInfoArray = nullptr;
- }
-
- RootView::GetInstance()->SetOnKeyActListener(g_onKeyActListener);
- // if(UILabel_Chargeing)
- // {
- // delete UILabel_Chargeing;
- // UILabel_Chargeing = nullptr;
-
- // }
-
-
- RootView::GetInstance()->Remove(UIViewGroup_charge);
- delete UIViewGroup_charge;
- UIViewGroup_charge = nullptr;
+ if(Chargeing_timer)
+ {
+ osTimerStop(Chargeing_timer);
+ osTimerDelete(Chargeing_timer);
+ Chargeing_timer = NULL;
+ }
+ UIViewGroup_charge->RemoveAll();
+ if(image_lightning)
+ {
+ delete image_lightning;
+ image_lightning = nullptr;
+ }
+ if(UILabel_time)
+ {
+ delete UILabel_time;
+ UILabel_time = nullptr;
+ }
+ if(UILabel_power)
+ {
+ delete UILabel_power;
+ UILabel_power = nullptr;
+ }
+ if (chargeAnimatorView)
+ {
+ chargeAnimatorView->Stop();
+ delete chargeAnimatorView;
+ chargeAnimatorView = nullptr;
+ }
+ if (ChargeAnimationInfoArray)
+ {
+ FreeImageInfoArray(ChargeAnimationInfoArray, ChargeAnimationPaths,
+ CHARGE_ANIMATION_VIEW_NUM_FRAMES);
+ ChargeAnimationInfoArray = nullptr;
+ }
+ RootView::GetInstance()->SetOnKeyActListener(g_onKeyActListener);
+ RootView::GetInstance()->Remove(UIViewGroup_charge);
+ delete UIViewGroup_charge;
+ UIViewGroup_charge = nullptr;
}
}
UIViewGroup * ShowChargeingView(void)
{
-
if (UIViewGroup_charge == nullptr)
{
UIViewGroup_charge = new UIViewGroup();
- UIViewGroup_charge->SetPosition(0, 0, 466, 466);
- //UIViewGroup_charge->SetStyle(STYLE_BACKGROUND_OPA, 0);
+ if(UIViewGroup_charge == nullptr)
+ {
+ printf("UIViewGroup_charge is null\r\n");
+ return nullptr;
+ }
}
+ UIViewGroup_charge->SetPosition(0, 0, 466, 466);
UIViewGroup_charge->SetViewId(CHARGE_GROUP);
UIViewGroup_charge->SetTouchable(true);
UIView::OnClickListener *UIViewGroup_charge_Click = static_cast<UIView::OnClickListener *>(lowppowrViewEventListener::GetInstance());
UIViewGroup_charge->SetOnClickListener(UIViewGroup_charge_Click);
-
-
+ /* -------------------------------------------------------------------------- */
float voltage = 0.0F;
uint8_t power = 0;
#ifdef SUPPORT_BATTERY_SERVICE
power = battery_get_voltage(&voltage);
#endif
-
char buf[16]={0};
sprintf(buf,"%d%c",power,'%');
//printf("power:%s\r\n",buf);
-
time_t currtime;
struct tm *timeinfo;
time(&currtime);
timeinfo = localtime(&currtime);
-
char time_buf[16]={0};
sprintf_s(time_buf,16,"%02d:%02d",timeinfo->tm_hour,timeinfo->tm_min);
-
-
-
- if (UILabel_power == nullptr) {
+ /* -------------------------------------------------------------------------- */
+ if (UILabel_power == nullptr)
+ {
UILabel_power = new UILabelExt();
+ if(UILabel_power == nullptr)
+ {
+ printf("UILabel_power is null\r\n");
+ return nullptr;
+ }
}
- UILabel_power->SetPosition(133, 202); // widget's left position and top position
- UILabel_power->Resize(200, 60); // widget's width and height
- UILabel_power->SetViewId("label5");// Set style
+ UILabel_power->SetPosition(133, 202);
+ UILabel_power->Resize(200, 60);
UILabel_power->SetStyle(STYLE_TEXT_FONT, 40);
-
UILabel_power->SetText(buf);
UILabel_power->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
UILabel_power->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
UILabel_power->SetRollSpeed(0);
UILabel_power->SetFont(GILROY_BOLD_FONT, 40);
UILabel_power->SetVisible(true);
-
-
-
-
-
- if (UILabel_time == nullptr) {
+ UIViewGroup_charge->Add(UILabel_power);
+ /* -------------------------------------------------------------------------- */
+ if (UILabel_time == nullptr)
+ {
UILabel_time = new UILabelExt();
+ if(UILabel_time == nullptr)
+ {
+ printf("UILabel_time is null\r\n");
+ return nullptr;
+ }
}
- UILabel_time->SetPosition(173, 65); // widget's left position and top position
- UILabel_time->Resize(120, 48); // widget's width and height
- UILabel_time->SetViewId("label3");// Set style
+ UILabel_time->SetPosition(173, 65);
+ UILabel_time->Resize(120, 48);
UILabel_time->SetStyle(STYLE_TEXT_FONT, 40);
- // Set additional property
UILabel_time->SetText(time_buf);
UILabel_time->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
UILabel_time->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
UILabel_time->SetRollSpeed(0);
UILabel_time->SetFont(GILROY_BOLD_FONT, 40);
UILabel_time->SetVisible(true);
-
+ UIViewGroup_charge->Add(UILabel_time);
+ /* -------------------------------------------------------------------------- */
osStatus_t retTimer;
Chargeing_timer = osTimerNew((osTimerFunc_t)Chargeing_Timer_CallBack, osTimerPeriodic, NULL, NULL);
retTimer = osTimerStart(Chargeing_timer, 1000*1);
osTimerDelete(Chargeing_timer);
Chargeing_timer = NULL;
}
-
-
-
-
// 充电动画初始化与添加
- if (chargeAnimatorView == nullptr) {
+ if (chargeAnimatorView == nullptr)
+ {
chargeAnimatorView = new UIImageAnimatorView();
+ if(chargeAnimatorView == nullptr)
+ {
+ printf("chargeAnimatorView is null\r\n");
+ return nullptr;
+ }
}
- if (ChargeAnimationInfoArray == nullptr) {
+ if (ChargeAnimationInfoArray == nullptr)
+ {
// 加载 /user/res/charge/ 目录中的帧序列:1.bin ... N.bin
ChargeAnimationInfoArray = CreateImageInfoArray(ChargeAnimationPaths, CHARGE_ANIMATION_VIEW_NUM_FRAMES);
}
- if (ChargeAnimationInfoArray != nullptr && chargeAnimatorView != nullptr) {
+ if (ChargeAnimationInfoArray != nullptr && chargeAnimatorView != nullptr)
+ {
for (uint8_t i = 0; i < CHARGE_ANIMATION_VIEW_NUM_FRAMES; i++) {
ChargeAnimationInfo[i].imageInfo = (ChargeAnimationInfoArray[i]);
ChargeAnimationInfo[i].imageType = IMG_SRC_IMAGE_INFO;
chargeAnimatorView->Start();
UIViewGroup_charge->Add(chargeAnimatorView);
}
-
g_onKeyActListener = RootView::GetInstance()->GetOnKeyActListener();
RootView::GetInstance()->SetOnKeyActListener(lowppowrViewEventListener::GetInstance());
-
- UIViewGroup_charge->Add(UILabel_time);
- UIViewGroup_charge->Add(UILabel_power);
-
NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeChargePower);
return UIViewGroup_charge;
}
-///////////////////////////////////////////////////////////////////////////////////
-//低电量弹窗
+
+ //低电量弹窗
void ShowUpShutDownAnimatorView()
{
group = new UIViewGroup();
return ;
}
group->SetPosition(0, 0, 466, 466);
-
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShutDownAnimatorView::ShowUpShutDownAnimatorView");
ShutDownInfoArray = CreateImageInfoArray(ShutDownPaths, SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
-
if (ShutDownImageAnimatorView == nullptr)
{
ShutDownImageAnimatorView = new UIImageAnimatorView();
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to Create stoplistener!!");
return;
}
-
ShutDownImageAnimatorView->SetVisible(true);
//ShutDownImageAnimatorView->Start();
group->SetVisible(false);
{
if (UIViewGroup_lowpower != nullptr)
{
- UIViewGroup_lowpower->RemoveAll();
- if(alarm_img)
- {
- delete alarm_img;
- alarm_img = nullptr;
- }
- if(alarm_UILabel)
- {
- delete alarm_UILabel;
- alarm_UILabel = nullptr;
- }
- if(alarm_labelbutton)
- {
- delete alarm_labelbutton;
- alarm_labelbutton = nullptr;
- }
- if(group)
- {
- group->RemoveAll();
- ShutDownImageAnimatorView->Stop();
- if(ShutDownImageAnimatorView)
+ UIViewGroup_lowpower->RemoveAll();
+ if(alarm_img)
+ {
+ delete alarm_img;
+ alarm_img = nullptr;
+ }
+ if(alarm_UILabel)
+ {
+ delete alarm_UILabel;
+ alarm_UILabel = nullptr;
+ }
+ if(alarm_labelbutton)
{
- delete ShutDownImageAnimatorView;
- ShutDownImageAnimatorView = nullptr;
+ delete alarm_labelbutton;
+ alarm_labelbutton = nullptr;
}
- FreeImageInfoArray(ShutDownInfoArray,ShutDownPaths,SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
- delete group;
- group = nullptr;
+ if(group)
+ {
+ group->RemoveAll();
+ ShutDownImageAnimatorView->Stop();
+ if(ShutDownImageAnimatorView)
+ {
+ delete ShutDownImageAnimatorView;
+ ShutDownImageAnimatorView = nullptr;
+ }
+ FreeImageInfoArray(ShutDownInfoArray,ShutDownPaths,SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+ delete group;
+ group = nullptr;
- }
- //FreeImagePathsArray(ShutDownPathsArray,SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
-
- RootView::GetInstance()->Remove(UIViewGroup_lowpower);
- delete UIViewGroup_lowpower;
- UIViewGroup_lowpower = nullptr;
+ }
+ RootView::GetInstance()->Remove(UIViewGroup_lowpower);
+ delete UIViewGroup_lowpower;
+ UIViewGroup_lowpower = nullptr;
}
}
static uint8_t timer_falg_low_power=6;
void low_power_play()
{
- //uapi_poweroff_device(); // 关机
-
- //osTimerStop(low_power_timer);
+ if(group)
group->SetVisible(true);
UIImageAnimatorView::AnimatorStopListener *stoplistener = static_cast<UIImageAnimatorView::AnimatorStopListener *>(lowppowrAnimatorStopListener::GetInstance());
- ShutDownImageAnimatorView->SetAnimatorStopListener(stoplistener);
- if (stoplistener == nullptr)
+ if(ShutDownImageAnimatorView)
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to Create stoplistener!!");
- return ;
- }
+ ShutDownImageAnimatorView->SetAnimatorStopListener(stoplistener);
ShutDownImageAnimatorView->Start();
+ }
#ifdef SUPPORT_BATTERY_SERVICE
set_lowpower_show(1,0);
#endif
-
-
-
}
UIViewGroup *lowPowerShow()
{
-
- if (UIViewGroup_lowpower == nullptr) {
+ if (UIViewGroup_lowpower == nullptr)
+ {
UIViewGroup_lowpower = new UIViewGroup();
UIViewGroup_lowpower->SetPosition(0, 0, 466, 466);
- //UIViewGroup_lowpower->SetStyle(STYLE_BACKGROUND_OPA, 0);
+ UIViewGroup_lowpower->SetTouchable(true);
}
- // Add ImageView to App
- if (alarm_img == nullptr) {
+ if (alarm_img == nullptr)
+ {
alarm_img = new UIImageView();
}
- alarm_img->SetPosition(171, 155); // widget's left position and top position
- alarm_img->Resize(100, 100); // widget's width and height
- alarm_img->SetViewId("image1");// Set style
-
- // Set additional property
+ alarm_img->SetPosition(171, 155);
+ alarm_img->Resize(100, 100);
const char *imageimagesPath = "/user/res/lowpower.bin";
alarm_img->SetSrc(imageimagesPath);
-
- // Add to rootView
- UIViewGroup_lowpower->Add(alarm_img);
alarm_img->SetVisible(true);
-
- // Add Label to App
- if (alarm_UILabel == nullptr) {
+ UIViewGroup_lowpower->Add(alarm_img);
+ /* -------------------------------------------------------------------------- */
+ if (alarm_UILabel == nullptr)
+ {
alarm_UILabel = new UILabelExt();
}
- alarm_UILabel->SetPosition(101, 215); // widget's left position and top position
- alarm_UILabel->Resize(466, 212); // widget's width and height
- alarm_UILabel->SetViewId("label1");// Set style
+ alarm_UILabel->SetPosition(101, 215);
+ alarm_UILabel->Resize(466, 212);
alarm_UILabel->SetStyle(STYLE_TEXT_FONT, 30);
-
- // Set additional property
+ alarm_UILabel->SetVisible(true);
+ UIViewGroup_lowpower->Add(alarm_UILabel);
+ /* -------------------------------------------------------------------------- */
if(battery_falg==0)
{
- alarm_UILabel->SetPosition(110, 252); // widget's left position and top position
- alarm_UILabel->Resize(245, 70); // widget's width and height
-
+ alarm_UILabel->SetPosition(110, 252);
+ alarm_UILabel->Resize(245, 70);
// alarm_UILabel->SetText("当前电量低于10%请及时充电");
alarm_UILabel->SetTextId(STR_LOW_POWER_NOTIF_1);
-
alarm_UILabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
alarm_UILabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
alarm_UILabel->SetRollSpeed(0);
set_lowpower_show(0,0);
#endif
}
- // Set additional property
if(battery_falg==1)
{
alarm_UILabel->SetPosition(110, 252);
low_power_timer = NULL;
}
timer_falg_low_power=5;
-
-
}
-
- // Add to rootView
- UIViewGroup_lowpower->Add(alarm_UILabel);
- alarm_UILabel->SetVisible(true);
-
- // Add LabelButtonExt to App
- if (alarm_labelbutton == nullptr) {
+ if (alarm_labelbutton == nullptr)
+ {
alarm_labelbutton = new UILabelButtonExt();
}
- // alarm_labelbutton->SetPosition(165, 378); // widget's left position and top position
- // alarm_labelbutton->Resize(135, 88); // widget's width and height
alarm_labelbutton->SetViewId(LOW_POWER_BUTTON);// Set style
alarm_labelbutton->SetPosition(0, 366, 466, 100);
const char *ImgSrc = "/user/res/466x100button.bin";
alarm_labelbutton->SetImageSrc(ImgSrc, ImgSrc);
- // Set additional property
// alarm_labelbutton->SetText("确认");
alarm_labelbutton->SetTextId(STR_KONW);
alarm_labelbutton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
alarm_labelbutton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
-
UIView::OnClickListener *button1Click = static_cast<UIView::OnClickListener *>(lowppowrViewEventListener::GetInstance());
alarm_labelbutton->SetOnClickListener(button1Click);
-
- // Add to rootView
- UIViewGroup_lowpower->Add(alarm_labelbutton);
alarm_labelbutton->SetVisible(true);
- UIViewGroup_lowpower->SetTouchable(true);
+ UIViewGroup_lowpower->Add(alarm_labelbutton);
alarm_labelbutton->SetTouchable(true);
-
ShowUpShutDownAnimatorView();
if(group)
UIViewGroup_lowpower->Add(group);
group->SetVisible(true);
ShutDownImageAnimatorView->Start();
ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); // 关机动画已经开始了不能息屏
-
}
-
NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreelowPower);
return UIViewGroup_lowpower;
}
void lowppowrAnimatorStopListener::OnAnimatorStop(UIView &view)
{
- //UNUSED(view);
- // NotificationManager::GetInstance()->StopNotify();//hcj改动
msleep(500);
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "xxxxxxxxxxxxxxxxxxxxOnAnimatorStop");
-
if(battery_falg==4)
shutdown_reboot_prejobs(REBOOT_TYPE);
else
shutdown_reboot_prejobs(SHUTDOWN_TYPE);
// uapi_poweroff_device(); // 关机
-
-
-
- //NotificationManager::GetInstance()->StopNotify();
- //
- // if(strcmp(view.GetViewId(),LOW_POWER_BUTTON)!=0)
- // {
-
- // }
-
}
bool lowppowrViewEventListener::OnKeyAct(UIView &view, const KeyEvent &event)