159 lines
5.0 KiB
C++
159 lines
5.0 KiB
C++
/*----------------------------------------------------------------------------
|
|
* Copyright (c) TJD Technologies Co., Ltd. 2024. All rights reserved.
|
|
*
|
|
* Description:
|
|
*
|
|
* Author: huangshuyi
|
|
*
|
|
* Create: 2024-8
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
#include "TjdUiFemaleWaitDataPage.h"
|
|
#include "components/ui_label.h"
|
|
#include "wearable_log.h"
|
|
#include "common/image_cache_manager.h"
|
|
#include <time.h>
|
|
#include <unordered_map>
|
|
#include "gfx_utils/image_info.h"
|
|
#include "gfx_utils/heap_base.h"
|
|
#include "TjdUiImageIds.h"
|
|
#include "ui_label.h"
|
|
#include "ui_label_ext.h"
|
|
#include "components/ui_label_ext.h"
|
|
#include "TjdUiMultiLanguageExt.h"
|
|
#include "sys_config.h"
|
|
#include "components/ui_view.h"
|
|
#include "TjdUiMemManage.h"
|
|
#include <ctime>
|
|
#include "TjdUiFemaleHealthView.h"
|
|
|
|
using namespace OHOS;
|
|
|
|
namespace TJD {
|
|
|
|
#define ENABLE_PRINT_INFO 1
|
|
#if ENABLE_PRINT_INFO
|
|
#define static_print_info(...) sys_ui_log_i(__VA_ARGS__) //一般信息打印宏控制
|
|
#define static_print_warn(...) sys_ui_log_w(__VA_ARGS__) //警告信息打印一般常开
|
|
#define static_print_error(...) sys_ui_log_e(__VA_ARGS__) //错误信息打印一般常开
|
|
#define static_print_debug(...) sys_ui_log_d(__VA_ARGS__)
|
|
#else
|
|
#define static_print_info(...)
|
|
#define static_print_warn(...)
|
|
#define static_print_error(...)
|
|
#define static_print_debug(...)
|
|
#endif
|
|
|
|
#define IMAGE_BIN_PATH TJD_IMAGE_PATH"img_female.bin"
|
|
#define FEMALE_LOADING_IMAGE_BIN_PATH TJD_IMAGE_PATH "img_loading.bin"
|
|
#define WAIT_ANIMATOR_COUNT 11
|
|
|
|
static TjdUiFemaleWaitDataPage *g_pFemaleWaitData = nullptr;
|
|
static OHOS::ImageAnimatorInfo g_pv_waitInfo_[WAIT_ANIMATOR_COUNT];
|
|
static void WaitAnimatorImageInfo()
|
|
{
|
|
const int waitAnimatorId[WAIT_ANIMATOR_COUNT] = {
|
|
IMG_LOADING_LOADING_01_06, IMG_LOADING_LOADING_02_06, IMG_LOADING_LOADING_03_06, IMG_LOADING_LOADING_04_06,
|
|
IMG_LOADING_LOADING_05_06, IMG_LOADING_LOADING_06_06, IMG_LOADING_LOADING_07_06, IMG_LOADING_LOADING_08_06,
|
|
IMG_LOADING_LOADING_09_06, IMG_LOADING_LOADING_10_06, IMG_LOADING_LOADING_11_06,
|
|
};
|
|
auto &imgManager = OHOS::ImageCacheManager::GetInstance();
|
|
imgManager.LoadAllInMultiRes(FEMALE_LOADING_IMAGE_BIN_PATH);
|
|
|
|
for (int i = 0; i < WAIT_ANIMATOR_COUNT; i++) {
|
|
g_pv_waitInfo_[i].imageInfo = imgManager.LoadOneInMultiRes(waitAnimatorId[i], FEMALE_LOADING_IMAGE_BIN_PATH);
|
|
g_pv_waitInfo_[i].pos = {178, 154};
|
|
g_pv_waitInfo_[i].width = 121;
|
|
g_pv_waitInfo_[i].height = 121;
|
|
g_pv_waitInfo_[i].imageType = OHOS::IMG_SRC_IMAGE_INFO;
|
|
}
|
|
}
|
|
|
|
TjdUiFemaleWaitDataPage::TjdUiFemaleWaitDataPage()
|
|
{
|
|
//SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
|
|
g_pFemaleWaitData = this;
|
|
}
|
|
|
|
TjdUiFemaleWaitDataPage::~TjdUiFemaleWaitDataPage()
|
|
{
|
|
OHOS::ImageCacheManager::GetInstance().UnloadAllInMultiRes(FEMALE_LOADING_IMAGE_BIN_PATH);
|
|
if (waitTimer_) {
|
|
delete waitTimer_;
|
|
waitTimer_ = nullptr;
|
|
}
|
|
g_pFemaleWaitData = nullptr;
|
|
}
|
|
|
|
TjdUiFemaleWaitDataPage *TjdUiFemaleWaitDataPage::GetInstance(void)
|
|
{
|
|
return g_pFemaleWaitData;
|
|
}
|
|
|
|
void TjdUiFemaleWaitDataPage::TimerCallback(void* arg)
|
|
{
|
|
static_print_debug("TjdUiFemaleWaitDataPage::Timeout\n");
|
|
if (g_pFemaleWaitData)
|
|
g_pFemaleWaitData->Stop();
|
|
}
|
|
|
|
void TjdUiFemaleWaitDataPage::Start(void)
|
|
{
|
|
if (animator_)
|
|
animator_->Start();
|
|
if (waitTimer_)
|
|
waitTimer_->Start();
|
|
}
|
|
|
|
void TjdUiFemaleWaitDataPage::Stop()
|
|
{
|
|
if (animator_)
|
|
animator_->Stop();
|
|
if (waitTimer_)
|
|
waitTimer_->Stop();
|
|
}
|
|
|
|
void TjdUiFemaleWaitDataPage::HideView(void)
|
|
{
|
|
static_print_debug("TjdUiFemaleWaitDataPage::HideView\n");
|
|
pageGroup_->SetVisible(false);
|
|
Stop();
|
|
}
|
|
|
|
void TjdUiFemaleWaitDataPage::ShowView(void)
|
|
{
|
|
static_print_debug("TjdUiFemaleWaitDataPage::ShowView\n");
|
|
pageGroup_->SetVisible(true);
|
|
Start();
|
|
}
|
|
|
|
UIViewGroup *TjdUiFemaleWaitDataPage::PageInit(void)
|
|
{
|
|
|
|
UIViewGroup *container = (UIViewGroup *)TjdUiFemaleHealthView::GetInstance()->GetContainer();
|
|
pageGroup_ = new UIViewGroup();
|
|
container->Add(pageGroup_);
|
|
pageGroup_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
|
|
|
|
animator_ = new UIImageAnimatorView();
|
|
animator_->SetPosition(150, 113, 166, 164);
|
|
pageGroup_->Add(animator_);
|
|
|
|
UILabel *labelWait = new UILabel();
|
|
pageGroup_->Add(labelWait);
|
|
labelWait->SetFont(TJD_VECTOR_FONT_FILENAME, 34);
|
|
pageGroup_->Add(labelWait);
|
|
labelWait->SetText("数据加载中,请稍后...");
|
|
labelWait->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
|
|
labelWait->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
|
|
labelWait->LayoutLeftOfParent((pageGroup_->GetWidth() - labelWait->GetWidth()) / 2);
|
|
labelWait->LayoutTopOfParent(287);
|
|
|
|
waitTimer_ = new OHOS::GraphicTimer(3000, TimerCallback, nullptr, false);
|
|
WaitAnimatorImageInfo();
|
|
animator_->SetImageAnimatorSrc(g_pv_waitInfo_, WAIT_ANIMATOR_COUNT, 100);
|
|
return pageGroup_;
|
|
}
|
|
|
|
}
|