#include "TjdUiAppBreathingView.h" #include "TjdUiImageIds.h" #include "TjdUiMemManage.h" #include "TjdUiMultiLanguageExt.h" #include "TjdUiScreenManage.h" #include "TjdUiUtils.h" #include "common/image_cache_manager.h" #include "gfx_utils/mem_check.h" #include "notification_manager.h" #include "style.h" #define IF_MEM_CHECK 0 namespace TJD { using namespace OHOS; #define BREATHING_IMAGE_BIN_PATH TJD_IMAGE_PATH "img_breathing.bin" #define INHALE_ANIMATOR_COUNT 10 #define EXHALE_ANIMATOR_COUNT 10 #define HALE_ANIMATOR_COUNT 10 enum BreathingImageInfoIndex { BREATHING_INFO_TIME, BREATHING_INFO_MODEL, BREATHING_INFO_START, BREATHING_INFO_NOT_SELECT, BREATHING_INFO_SELECT, BREATHING_INFO_BACKGROUND_START, BREATHING_INFO_HEART, BREATHING_INFO_COUNT }; int InhaleAnimatorId[] = {IMG_BREATHING_BREATHE_DT_11_03, IMG_BREATHING_BREATHE_DT_12_03, IMG_BREATHING_BREATHE_DT_13_03, IMG_BREATHING_BREATHE_DT_14_03, IMG_BREATHING_BREATHE_DT_15_03, IMG_BREATHING_BREATHE_DT_16_03, IMG_BREATHING_BREATHE_DT_17_03, IMG_BREATHING_BREATHE_DT_18_03, IMG_BREATHING_BREATHE_DT_19_03, IMG_BREATHING_BREATHE_DT_20_03}; int ExhaleAnimatorId[] = {IMG_BREATHING_BREATHE_DT_01_03, IMG_BREATHING_BREATHE_DT_02_03, IMG_BREATHING_BREATHE_DT_03_03, IMG_BREATHING_BREATHE_DT_04_03, IMG_BREATHING_BREATHE_DT_05_03, IMG_BREATHING_BREATHE_DT_06_03, IMG_BREATHING_BREATHE_DT_07_03, IMG_BREATHING_BREATHE_DT_08_03, IMG_BREATHING_BREATHE_DT_09_03, IMG_BREATHING_BREATHE_DT_10_03}; int HaleAnimatorId[] = { IMG_BREATHING_BREATHE_DT_05_03, IMG_BREATHING_BREATHE_DT_06_03, IMG_BREATHING_BREATHE_DT_07_03, IMG_BREATHING_BREATHE_DT_08_03, IMG_BREATHING_BREATHE_DT_09_03, IMG_BREATHING_BREATHE_DT_10_03, IMG_BREATHING_BREATHE_DT_11_03, IMG_BREATHING_BREATHE_DT_12_03, IMG_BREATHING_BREATHE_DT_13_03, IMG_BREATHING_BREATHE_DT_14_03, IMG_BREATHING_BREATHE_DT_15_03, IMG_BREATHING_BREATHE_DT_16_03, }; int pic_count = 0; // 当前动画帧 bool breatheFlag = false; // 吸气状态标记 bool trainingFinished = false; // 训练结束标记 static uint32_t lastTime_ = 0; static OHOS::GraphicTimer *breathingTimer_ = nullptr; // breathing timer static OHOS::ImageInfo *g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_COUNT]{nullptr}; static OHOS::ImageInfo *g_pv_animatorInfo1_[INHALE_ANIMATOR_COUNT]; static OHOS::ImageInfo *g_pv_animatorInfo2_[EXHALE_ANIMATOR_COUNT]; static OHOS::ImageAnimatorInfo g_imageAnimatorInfo[20]; static TjdUiAppBreathingView *g_pv_AppBreathingView = nullptr; static int8_t status_ = 0; static int8_t model_to_status = 1; static int8_t value = 0; static int8_t mins = 1; static int8_t change1_ = 0; // static int8_t hr_num_ =0; bool BreathUIScrollView::OnDragStartEvent(const OHOS::DragEvent &event) { if (TjdUiAppBreathingView::GetInstance()->GetCurrentView() != BreathingViewIndex::BREATHING_CHOOSE_VIEW) { return true; } isOnStart_ = true; return OHOS::UIScrollViewNested::OnDragStartEvent(event); } bool BreathUIScrollView::OnDragEvent(const OHOS::DragEvent &event) { if (!isOnStart_) { return true; } if (TjdUiAppBreathingView::GetInstance()->GetCurrentView() != BreathingViewIndex::BREATHING_CHOOSE_VIEW) { return true; } return OHOS::UIScrollViewNested::OnDragEvent(event); } bool BreathUIScrollView::OnDragEndEvent(const OHOS::DragEvent &event) { if (!isOnStart_) { return true; } isOnStart_ = false; if (TjdUiAppBreathingView::GetInstance()->GetCurrentView() != BreathingViewIndex::BREATHING_CHOOSE_VIEW) { return true; } return OHOS::UIScrollViewNested::OnDragEndEvent(event); } TjdUiAppBreathingView::TjdUiAppBreathingView() { if (IF_MEM_CHECK) OHOS::MemCheck::GetInstance()->EnableLeakCheck(true); g_pv_AppBreathingView = this; } TjdUiAppBreathingView::~TjdUiAppBreathingView() { if (IF_MEM_CHECK) OHOS::MemCheck::GetInstance()->EnableLeakCheck(false); g_pv_AppBreathingView = nullptr; } TjdUiAppBreathingView *TjdUiAppBreathingView::GetInstance(void) { return g_pv_AppBreathingView; } void TjdUiAppBreathingView::OnStart() { View::OnStart(); InitBreathingImage(); if (containerAll_ == nullptr) { containerAll_ = new BreathUIScrollView(); } containerAll_->SetPosition(0, 0, OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION); breathingView[BreathingViewIndex::BREATHING_CHOOSE_VIEW] = InitBreathingChooseView(); breathingView[BreathingViewIndex::BREATHING_TIME_VIEW] = InitBreathingTimeView(); breathingView[BreathingViewIndex::BREATHING_MODEL_VIEW] = InitBreathingModelView(); breathingView[BreathingViewIndex::BREATHING_START_VIEW] = InitBreathingStartView(); breathingView[BreathingViewIndex::BREATHING_ANIMATOR_VIEW] = InitBreathingAnimationView(); breathingView[BreathingViewIndex::BREATHING_FINISH_VIEW] = InitBreathingTrainingFinishedView(); containerAll_->Add(breathingView[BreathingViewIndex::BREATHING_CHOOSE_VIEW]); containerAll_->Add(breathingView[BreathingViewIndex::BREATHING_TIME_VIEW]); containerAll_->Add(breathingView[BreathingViewIndex::BREATHING_MODEL_VIEW]); containerAll_->Add(breathingView[BreathingViewIndex::BREATHING_START_VIEW]); containerAll_->Add(breathingView[BreathingViewIndex::BREATHING_ANIMATOR_VIEW]); containerAll_->Add(breathingView[BreathingViewIndex::BREATHING_FINISH_VIEW]); AddViewToRootContainer(containerAll_); } void TjdUiAppBreathingView::OnStop() { if (backgroundBreathing_ != nullptr) { backgroundBreathing_->Stop(); } if (timerbreath1_ != nullptr) { timerbreath1_->Stop(); delete timerbreath1_; timerbreath1_ = nullptr; } if (animator_ != nullptr) { animator_->Stop(); delete animator_; animator_ = nullptr; } ImageCacheManager::GetInstance().UnloadAllInMultiRes(BREATHING_IMAGE_BIN_PATH); TjdUiMemManage::DeleteChildren(containerAll_); RemoveAll(); } void TjdUiAppBreathingView::ShowView(BreathingViewIndex hideView, BreathingViewIndex showView) { if (breathingView[hideView] != nullptr) { if (hideView == BreathingViewIndex::BREATHING_ANIMATOR_VIEW) { animator_->Stop(); auto imageinfo = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_BREATHING_BREATHE_DT_05_03, BREATHING_IMAGE_BIN_PATH); if (imageinfo != nullptr) imageBreathing_->SetSrc(imageinfo); TjdUiScreenManage::ResetScreenKeepOnTimeout(); } else if (hideView == BreathingViewIndex::BREATHING_CHOOSE_VIEW) { if (backgroundBreathing_ != nullptr) { backgroundBreathing_->Stop(); } } breathingView[hideView]->SetVisible(false); } if (breathingView[showView] != nullptr) { if (showView == BreathingViewIndex::BREATHING_ANIMATOR_VIEW) { pic_count = 0; breatheFlag = false; lastTime_ = HALTick::GetInstance().GetTime(); TjdUiScreenManage::SetScreenKeepOnTimeout(1000 * 60 * 60); } else if (showView == BreathingViewIndex::BREATHING_CHOOSE_VIEW) { if (backgroundBreathing_ != nullptr) { backgroundBreathing_->Start(); } } breathingView[showView]->SetVisible(true); currentView_ = showView; } } void TjdUiAppBreathingView::InitBreathingImage() { g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_TIME] = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_BREATHING_BREATHING_TIME, BREATHING_IMAGE_BIN_PATH); g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_MODEL] = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_BREATHING_BREATHING_SET, BREATHING_IMAGE_BIN_PATH); g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_START] = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_BREATHING_BREATHING_CH, BREATHING_IMAGE_BIN_PATH); g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_NOT_SELECT] = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_BREATHING_BREATHING_NOT_SELECTED, BREATHING_IMAGE_BIN_PATH); g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_SELECT] = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_BREATHING_BREATHING_SELECTED, BREATHING_IMAGE_BIN_PATH); g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_BACKGROUND_START] = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_BREATHING_BREATHE_DT_10_03, BREATHING_IMAGE_BIN_PATH); g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_HEART] = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_BREATHING_BREATHING_HEART, BREATHING_IMAGE_BIN_PATH); ImageCacheManager &imgManager = ImageCacheManager::GetInstance(); for (uint8_t i = 0; i < sizeof(HaleAnimatorId) / sizeof(HaleAnimatorId[0]); i++) { auto imgInfo = imgManager.LoadOneInMultiRes(HaleAnimatorId[i], BREATHING_IMAGE_BIN_PATH); g_imageAnimatorInfo[i].imageInfo = imgInfo; g_imageAnimatorInfo[i].pos = {89, 100}; g_imageAnimatorInfo[i].width = 267; g_imageAnimatorInfo[i].height = 264; g_imageAnimatorInfo[i].imageType = IMG_SRC_IMAGE_INFO; } for (int j = 0; j < EXHALE_ANIMATOR_COUNT; j++) { g_pv_animatorInfo1_[j] = imgManager.LoadOneInMultiRes(InhaleAnimatorId[j], BREATHING_IMAGE_BIN_PATH); } for (int k = 0; k < EXHALE_ANIMATOR_COUNT; k++) { g_pv_animatorInfo2_[k] = imgManager.LoadOneInMultiRes(ExhaleAnimatorId[k], BREATHING_IMAGE_BIN_PATH); } } void TjdUiAppBreathingView::Changestatus() { printf("Changestatus\n"); value -= 1; std::string text = std::to_string(value) + "s"; lblLabel3_->SetText(text.c_str()); if (value <= 0) { timerbreath1_->Stop(); delete timerbreath1_; timerbreath1_ = nullptr; } } void TjdUiAppBreathingView::StopAnimator(int8_t heartrateval) { TjdUiAppBreathingView::GetInstance()->ShowView(BreathingViewIndex::BREATHING_ANIMATOR_VIEW, BreathingViewIndex::BREATHING_FINISH_VIEW); lblLabel3_->SetText("3s"); if (heartrateval < 100) { lblLabel6_->SetPosition(248, 247); } else { lblLabel6_->SetPosition(265, 247); } std::string text_ = std::to_string(heartrateval); lblHeart_->SetText(text_.c_str()); // imageAnimatorinhale_->Stop(); // imageAnimatorinhale_->SetVisible(false); // breathingTimer_->Stop(); animator_->Stop(); } void TimerCallback1_(void *param) { printf("TimerCallback1_\n"); TjdUiAppBreathingView::GetInstance()->Changestatus(); } void TjdUiAppBreathingView::ChooseModel() { // if(model_to_status==1) // { // imageAnimatorinhale_->SetImageAnimatorSrc(g_pv_animatorInfo3_, HALE_ANIMATOR_COUNT, 300); // } // if(model_to_status==2) // { // imageAnimatorinhale_->SetImageAnimatorSrc(g_pv_animatorInfo3_, HALE_ANIMATOR_COUNT, 400); // } // if(model_to_status==3) // { // imageAnimatorinhale_->SetImageAnimatorSrc(g_pv_animatorInfo2_, EXHALE_ANIMATOR_COUNT, 300); // } } void TjdUiAppBreathingView::StartTime(int val, int status) { value = val; status_ = status; lblLabel3_->SetText("3s"); if (timerbreath1_ == nullptr) { timerbreath1_ = new OHOS::GraphicTimer(1000, TimerCallback1_, nullptr, true); } timerbreath1_->Start(); } void TjdUiAppBreathingView::GetNum(int val, int status) { lblLabel3_->SetText("3s"); value = val; status_ = status; } void TjdUiAppBreathingView::StartAnimator() { lblLabel4_->SetTextId(STR_ID_133); TjdUiAppBreathingView::GetInstance()->ShowView(BreathingViewIndex::BREATHING_START_VIEW, BreathingViewIndex::BREATHING_ANIMATOR_VIEW); // imageAnimatorinhale_->SetVisible(true); // imageAnimatorinhale_->Start(); // breathingTimer_->Start(); animator_->Start(); } void TjdUiAppBreathingView::ChangeLabel1() { lblLabel4_->SetTextId(STR_ID_134); // TjdUiUtils::AutoAlignHorizontalCenter(*lblLabel4_); breatheFlag = true; pic_count = 0; } void TjdUiAppBreathingView::ChangeLabel2() { // lblLabel4_->SetText("吸气"); lblLabel4_->SetTextId(STR_ID_133); // TjdUiUtils::AutoAlignHorizontalCenter(*lblLabel4_); breatheFlag = false; pic_count = 0; } void TjdUiAppBreathingView::Addselect(int statu) { if (statu == 1) { lblLabel1_->SetText("1min"); mins = 1; notselectBreathing1_->SetSrc(g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_SELECT]); notselectBreathing2_->SetSrc(g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_NOT_SELECT]); notselectBreathing3_->SetSrc(g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_NOT_SELECT]); lblAllTimes_->SetText("01 : 00"); } else if (statu == 2) { lblLabel1_->SetText("2min"); mins = 2; notselectBreathing1_->SetSrc(g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_NOT_SELECT]); notselectBreathing2_->SetSrc(g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_SELECT]); notselectBreathing3_->SetSrc(g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_NOT_SELECT]); lblAllTimes_->SetText("02 : 00"); } else if (statu == 3) { lblLabel1_->SetText("3min"); mins = 3; notselectBreathing1_->SetSrc(g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_NOT_SELECT]); notselectBreathing2_->SetSrc(g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_NOT_SELECT]); notselectBreathing3_->SetSrc(g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_SELECT]); lblAllTimes_->SetText("03 : 00"); } else if (statu == 4) { lblLabel2_->SetTextId(STR_ID_131); model_to_status = 2; notselectBreathing4_->SetSrc(g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_SELECT]); notselectBreathing5_->SetSrc(g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_NOT_SELECT]); notselectBreathing6_->SetSrc(g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_NOT_SELECT]); } else if (statu == 5) { lblLabel2_->SetTextId(STR_ID_128); model_to_status = 1; notselectBreathing4_->SetSrc(g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_NOT_SELECT]); notselectBreathing5_->SetSrc(g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_SELECT]); notselectBreathing6_->SetSrc(g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_NOT_SELECT]); } else if (statu == 6) { lblLabel2_->SetTextId(STR_ID_132); model_to_status = 3; notselectBreathing4_->SetSrc(g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_NOT_SELECT]); notselectBreathing5_->SetSrc(g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_NOT_SELECT]); notselectBreathing6_->SetSrc(g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_SELECT]); } } OHOS::UIScrollView *TjdUiAppBreathingView::InitBreathingChooseView() { OHOS::UIScrollView *breathingChooseUiView = new OHOS::UIScrollView(); breathingChooseUiView->SetPosition(0, 0, 466, 466); breathingChooseUiView->SetOnClickListener(TjdUiAppBreathingPresenter::GetInstance()); if (OHOS::PageTransitionMgr::GetInstance().GetTopSlideBackImage() == nullptr) { breathingChooseUiView->SetOnDragListener(TjdUiAppBreathingPresenter::GetInstance()); } if (lblBreathingchoosehead_ == nullptr) { lblBreathingchoosehead_ = new UILabelExt(); } lblBreathingchoosehead_->SetFont(TJD_VECTOR_FONT_FILENAME, 28); // lblBreathingchoosehead_->SetText("呼吸训练"); lblBreathingchoosehead_->SetTextId(STR_ID_04); // lblBreathingchoosehead_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); lblBreathingchoosehead_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); lblBreathingchoosehead_->SetPosition(0, 18, 466, 37); if (timeBreathing_ == nullptr) { timeBreathing_ = new OHOS::UIImageView(); } timeBreathing_->SetPosition(27 - 20, 207 - 20, 52, 52); timeBreathing_->SetViewId(TIMEBREATHING_ID); timeBreathing_->SetTouchable(true); timeBreathing_->SetStyle(STYLE_BORDER_WIDTH, 20); timeBreathing_->SetOnClickListener(TjdUiAppBreathingPresenter::GetInstance()); if (g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_TIME] != nullptr) { timeBreathing_->SetSrc(g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_TIME]); } if (modelBreathing_ == nullptr) { modelBreathing_ = new OHOS::UIImageView(); } modelBreathing_->SetPosition(392 - 20, 207 - 20, 52, 52); modelBreathing_->SetViewId(MODELBREATHING_ID); modelBreathing_->SetTouchable(true); modelBreathing_->SetStyle(STYLE_BORDER_WIDTH, 20); modelBreathing_->SetOnClickListener(TjdUiAppBreathingPresenter::GetInstance()); if (g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_MODEL] != nullptr) { modelBreathing_->SetSrc(g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_MODEL]); } if (backgroundBreathing_ == nullptr) { backgroundBreathing_ = new OHOS::UIImageAnimatorView(); } backgroundBreathing_->SetPosition(89, 100, 267, 264); backgroundBreathing_->SetViewId(STARTBACKGROUND_ID); backgroundBreathing_->SetTouchable(true); backgroundBreathing_->SetOnClickListener(TjdUiAppBreathingPresenter::GetInstance()); backgroundBreathing_->SetImageAnimatorSrc(g_imageAnimatorInfo, sizeof(HaleAnimatorId) / sizeof(HaleAnimatorId[0]), 200); backgroundBreathing_->Start(); if (startBreathing_ == nullptr) { startBreathing_ = new OHOS::UIImageView(); } startBreathing_->SetPosition(187, 352, 92, 92); startBreathing_->SetViewId(STARTBREATHING_ID); startBreathing_->SetTouchable(true); startBreathing_->SetOnClickListener(TjdUiAppBreathingPresenter::GetInstance()); if (g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_START] != nullptr) { startBreathing_->SetSrc(g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_START]); } if (lblLabel1_ == nullptr) { lblLabel1_ = new UILabel(); } lblLabel1_->SetFont(TJD_VECTOR_FONT_FILENAME, 28); lblLabel1_->SetText("1min"); lblLabel1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); lblLabel1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); lblLabel1_->SetPosition(24, 274); if (lblLabel2_ == nullptr) { lblLabel2_ = new UILabelExt(); } lblLabel2_->SetFont(TJD_VECTOR_FONT_FILENAME, 28); // lblLabel2_->SetText("常规"); lblLabel2_->SetTextId(STR_ID_128); lblLabel2_->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); lblLabel2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); lblLabel2_->SetPosition(380, 273, 60, 37); breathingChooseUiView->Add(lblBreathingchoosehead_); breathingChooseUiView->Add(timeBreathing_); breathingChooseUiView->Add(modelBreathing_); breathingChooseUiView->Add(backgroundBreathing_); breathingChooseUiView->Add(startBreathing_); breathingChooseUiView->Add(lblLabel1_); breathingChooseUiView->Add(lblLabel2_); breathingChooseUiView->SetVisible(true); return breathingChooseUiView; } OHOS::UIScrollView *TjdUiAppBreathingView::InitBreathingTimeView() { OHOS::UIScrollView *breathingTimeUiView = new OHOS::UIScrollView(); breathingTimeUiView->SetPosition(0, 0, 466, 466); breathingTimeUiView->SetOnDragListener(TjdUiAppBreathingPresenter::GetInstance()); breathingTimeUiView->SetViewId(TIME_VIEW_ID); if (lblTimehead_ == nullptr) { lblTimehead_ = new UILabelExt(); } lblTimehead_->SetFont(TJD_VECTOR_FONT_FILENAME, 28); // lblTimehead_->SetText("分钟"); lblTimehead_->SetTextId(STR_ID_129); lblTimehead_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); lblTimehead_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); lblTimehead_->SetPosition(0, 18, 466, 37); if (labelButton1_ == nullptr) { labelButton1_ = new UILabelButtonExt(); } labelButton1_->SetPosition(70, 68); labelButton1_->Resize(326, 93); labelButton1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff202020); labelButton1_->SetTextId(STR_ID_129); std::string str = std::string("1 ") + std::string(FontGlobalManager::GetInstance()->GetText(STR_ID_129)); labelButton1_->SetText(str.c_str()); labelButton1_->SetAlign(TEXT_ALIGNMENT_LEFT); labelButton1_->SetLabelPosition(43, 0); labelButton1_->SetFont(TJD_VECTOR_FONT_FILENAME, 38); labelButton1_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff0b1928, UIButton::PRESSED); labelButton1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); labelButton1_->SetTouchable(false); if (labelButton2_ == nullptr) { labelButton2_ = new UILabelButtonExt(); } labelButton2_->SetPosition(8, 169); labelButton2_->Resize(450, 128); labelButton2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff202020); labelButton2_->SetTextId(STR_ID_129); str = std::string("2 ") + std::string(FontGlobalManager::GetInstance()->GetText(STR_ID_129)); labelButton2_->SetText(str.c_str()); labelButton2_->SetAlign(TEXT_ALIGNMENT_LEFT); labelButton2_->SetLabelPosition(42, 0); labelButton2_->SetFont(TJD_VECTOR_FONT_FILENAME, 38); labelButton2_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff0b1928, UIButton::PRESSED); labelButton2_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); labelButton2_->SetTouchable(false); if (labelButton3_ == nullptr) { labelButton3_ = new UILabelButtonExt(); } labelButton3_->SetPosition(70, 305); labelButton3_->Resize(326, 93); labelButton3_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff202020); // labelButton3_->SetText("3分钟"); str = std::string("3 ") + std::string(FontGlobalManager::GetInstance()->GetText(STR_ID_129)); labelButton3_->SetText(str.c_str()); labelButton3_->SetAlign(TEXT_ALIGNMENT_LEFT); labelButton3_->SetLabelPosition(43, 0); labelButton3_->SetFont(TJD_VECTOR_FONT_FILENAME, 38); labelButton3_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff0b1928, UIButton::PRESSED); labelButton3_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); labelButton3_->SetTouchable(false); if (notselectBreathing1_ == nullptr) { notselectBreathing1_ = new OHOS::UIImageView(); } notselectBreathing1_->SetPosition(337 - 30, 97 - 25, 36, 36); notselectBreathing1_->SetStyle(STYLE_BORDER_WIDTH, 25); notselectBreathing1_->SetStyle(STYLE_BORDER_OPA, 0); notselectBreathing1_->SetViewId(TIME_LABEL1_ID); notselectBreathing1_->SetTouchable(true); notselectBreathing1_->SetOnClickListener(TjdUiAppBreathingPresenter::GetInstance()); if (g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_SELECT] != nullptr) { notselectBreathing1_->SetSrc(g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_SELECT]); } if (notselectBreathing2_ == nullptr) { notselectBreathing2_ = new OHOS::UIImageView(); } notselectBreathing2_->SetPosition(380 - 30, 215 - 25, 36, 36); notselectBreathing2_->SetStyle(STYLE_BORDER_WIDTH, 25); notselectBreathing2_->SetStyle(STYLE_BORDER_OPA, 0); notselectBreathing2_->SetViewId(TIME_LABEL2_ID); notselectBreathing2_->SetTouchable(true); notselectBreathing2_->SetOnClickListener(TjdUiAppBreathingPresenter::GetInstance()); if (g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_NOT_SELECT] != nullptr) { notselectBreathing2_->SetSrc(g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_NOT_SELECT]); } if (notselectBreathing3_ == nullptr) { notselectBreathing3_ = new OHOS::UIImageView(); } notselectBreathing3_->SetPosition(337 - 30, 333 - 25, 36, 36); notselectBreathing3_->SetStyle(STYLE_BORDER_WIDTH, 25); notselectBreathing3_->SetStyle(STYLE_BORDER_OPA, 0); notselectBreathing3_->SetViewId(TIME_LABEL3_ID); notselectBreathing3_->SetTouchable(true); notselectBreathing3_->SetOnClickListener(TjdUiAppBreathingPresenter::GetInstance()); if (g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_NOT_SELECT] != nullptr) { notselectBreathing3_->SetSrc(g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_NOT_SELECT]); } breathingTimeUiView->Add(lblTimehead_); breathingTimeUiView->Add(labelButton1_); breathingTimeUiView->Add(labelButton2_); breathingTimeUiView->Add(labelButton3_); breathingTimeUiView->Add(notselectBreathing1_); breathingTimeUiView->Add(notselectBreathing2_); breathingTimeUiView->Add(notselectBreathing3_); breathingTimeUiView->SetVisible(false); return breathingTimeUiView; } OHOS::UIScrollView *TjdUiAppBreathingView::InitBreathingModelView() { OHOS::UIScrollView *breathingModelUiView = new OHOS::UIScrollView(); breathingModelUiView->SetPosition(0, 0, 466, 466); breathingModelUiView->SetOnDragListener(TjdUiAppBreathingPresenter::GetInstance()); breathingModelUiView->SetViewId(MODEL_VIEW_ID); if (lblModelhead_ == nullptr) { lblModelhead_ = new UILabelExt(); } lblModelhead_->SetFont(TJD_VECTOR_FONT_FILENAME, 28); // lblModelhead_->SetText("模式"); lblModelhead_->SetTextId(STR_ID_130); lblModelhead_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); lblModelhead_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); lblModelhead_->SetPosition(209, 18); if (labelButton4_ == nullptr) { labelButton4_ = new UILabelButtonExt(); } labelButton4_->SetPosition(70, 69); labelButton4_->Resize(326, 92); labelButton4_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff202020); // labelButton4_->SetText("稍慢"); labelButton4_->SetTextId(STR_ID_131); labelButton4_->SetAlign(TEXT_ALIGNMENT_LEFT); labelButton4_->SetLabelPosition(31, 0); labelButton4_->SetFont(TJD_VECTOR_FONT_FILENAME, 36); labelButton4_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff0b1928, UIButton::PRESSED); labelButton4_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); labelButton4_->SetTouchable(false); if (labelButton5_ == nullptr) { labelButton5_ = new UILabelButtonExt(); } labelButton5_->SetPosition(8, 169); labelButton5_->Resize(450, 128); labelButton5_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff202020); // labelButton5_->SetText("常规"); labelButton5_->SetTextId(STR_ID_128); labelButton5_->SetAlign(TEXT_ALIGNMENT_LEFT); labelButton5_->SetLabelPosition(42, 0); labelButton5_->SetFont(TJD_VECTOR_FONT_FILENAME, 38); labelButton5_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff0b1928, UIButton::PRESSED); labelButton5_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); labelButton5_->SetTouchable(false); if (labelButton6_ == nullptr) { labelButton6_ = new UILabelButtonExt(); } labelButton6_->SetPosition(70, 305); labelButton6_->Resize(326, 93); labelButton6_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff202020); // labelButton6_->SetText("稍快"); labelButton6_->SetTextId(STR_ID_132); labelButton6_->SetAlign(TEXT_ALIGNMENT_LEFT); labelButton6_->SetLabelPosition(31, 0); labelButton6_->SetFont(TJD_VECTOR_FONT_FILENAME, 36); labelButton6_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff0b1928, UIButton::PRESSED); labelButton6_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); labelButton6_->SetTouchable(false); if (notselectBreathing4_ == nullptr) { notselectBreathing4_ = new OHOS::UIImageView(); } notselectBreathing4_->SetPosition(337 - 30, 97 - 25, 36, 36); notselectBreathing4_->SetStyle(STYLE_BORDER_WIDTH, 25); notselectBreathing4_->SetStyle(STYLE_BORDER_OPA, 0); // notselectBreathing4_->SetStyle(STYLE_BORDER_COLOR, 0xff202020); notselectBreathing4_->SetViewId(MODEL_LABEL1_ID); notselectBreathing4_->SetTouchable(true); notselectBreathing4_->SetOnClickListener(TjdUiAppBreathingPresenter::GetInstance()); if (g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_NOT_SELECT] != nullptr) { notselectBreathing4_->SetSrc(g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_NOT_SELECT]); } if (notselectBreathing5_ == nullptr) { notselectBreathing5_ = new OHOS::UIImageView(); } notselectBreathing5_->SetPosition(380 - 30, 215 - 25, 36, 36); notselectBreathing5_->SetStyle(STYLE_BORDER_WIDTH, 25); notselectBreathing5_->SetStyle(STYLE_BORDER_OPA, 0); // notselectBreathing5_->SetStyle(STYLE_BORDER_COLOR, 0xff202020); notselectBreathing5_->SetViewId(MODEL_LABEL2_ID); notselectBreathing5_->SetTouchable(true); notselectBreathing5_->SetOnClickListener(TjdUiAppBreathingPresenter::GetInstance()); if (g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_SELECT] != nullptr) { notselectBreathing5_->SetSrc(g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_SELECT]); } if (notselectBreathing6_ == nullptr) { notselectBreathing6_ = new OHOS::UIImageView(); } notselectBreathing6_->SetPosition(337 - 30, 333 - 25, 36, 36); notselectBreathing6_->SetStyle(STYLE_BORDER_WIDTH, 25); notselectBreathing6_->SetStyle(STYLE_BORDER_OPA, 0); // notselectBreathing6_->SetStyle(STYLE_BORDER_COLOR, 0xff202020); notselectBreathing6_->SetViewId(MODEL_LABEL3_ID); notselectBreathing6_->SetTouchable(true); notselectBreathing6_->SetOnClickListener(TjdUiAppBreathingPresenter::GetInstance()); if (g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_NOT_SELECT] != nullptr) { notselectBreathing6_->SetSrc(g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_NOT_SELECT]); } breathingModelUiView->Add(lblModelhead_); breathingModelUiView->Add(labelButton4_); breathingModelUiView->Add(labelButton5_); breathingModelUiView->Add(labelButton6_); breathingModelUiView->Add(notselectBreathing4_); breathingModelUiView->Add(notselectBreathing5_); breathingModelUiView->Add(notselectBreathing6_); breathingModelUiView->SetVisible(false); return breathingModelUiView; } OHOS::UIScrollView *TjdUiAppBreathingView::InitBreathingStartView() { OHOS::UIScrollView *breathingStartUiView = new OHOS::UIScrollView(); breathingStartUiView->SetPosition(0, 0, 466, 466); breathingStartUiView->SetOnDragListener(TjdUiAppBreathingPresenter::GetInstance()); if (backgroundStart_ == nullptr) { backgroundStart_ = new OHOS::UIImageView(); } backgroundStart_->SetPosition(99, 101, 267, 264); backgroundStart_->SetViewId(STARTVIEW_ID); backgroundStart_->SetOnDragListener(TjdUiAppBreathingPresenter::GetInstance()); if (g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_BACKGROUND_START] != nullptr) { backgroundStart_->SetSrc(g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_BACKGROUND_START]); } if (lblLabel3_ == nullptr) { lblLabel3_ = new UILabel(); } lblLabel3_->SetFont(TJD_VECTOR_FONT_FILENAME, 50); lblLabel3_->SetText("3s"); lblLabel3_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); lblLabel3_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); lblLabel3_->SetPosition(206, 379); breathingStartUiView->Add(backgroundStart_); breathingStartUiView->Add(lblLabel3_); breathingStartUiView->SetVisible(false); return breathingStartUiView; } void BrethingAnimatorCallback::Callback(OHOS::UIView *view) { uint32_t diffTime = 0; switch (model_to_status) { case 1: switch (breatheFlag) { case 0: diffTime = HALTick::GetInstance().GetTime() - lastTime_; if (diffTime >= 450) { lastTime_ = HALTick::GetInstance().GetTime(); TjdUiAppBreathingView::GetInstance()->SetBreathingImage(g_pv_animatorInfo1_[pic_count]); pic_count++; // printf("line = %d ,cxin is test diffTime = %d ==pic_count=%d\n", __LINE__, diffTime, pic_count); } break; case 1: diffTime = HALTick::GetInstance().GetTime() - lastTime_; if (diffTime >= 300) { lastTime_ = HALTick::GetInstance().GetTime(); TjdUiAppBreathingView::GetInstance()->SetBreathingImage(g_pv_animatorInfo2_[pic_count]); pic_count++; // printf("line = %d ,cxin is test diffTime = %d ==pic_count=%d\n", __LINE__, diffTime, pic_count); } break; default: break; } break; case 2: switch (breatheFlag) { case 0: diffTime = HALTick::GetInstance().GetTime() - lastTime_; if (diffTime >= 600) { lastTime_ = HALTick::GetInstance().GetTime(); TjdUiAppBreathingView::GetInstance()->SetBreathingImage(g_pv_animatorInfo1_[pic_count]); pic_count++; // printf("line = %d ,cxin is test diffTime = %d ==pic_count=%d\n", __LINE__, diffTime, pic_count); } break; case 1: diffTime = HALTick::GetInstance().GetTime() - lastTime_; if (diffTime >= 400) { lastTime_ = HALTick::GetInstance().GetTime(); TjdUiAppBreathingView::GetInstance()->SetBreathingImage(g_pv_animatorInfo2_[pic_count]); pic_count++; // printf("line = %d ,cxin is test diffTime = %d ==pic_count=%d\n", __LINE__, diffTime, pic_count); } break; default: break; } break; case 3: switch (breatheFlag) { case 0: diffTime = HALTick::GetInstance().GetTime() - lastTime_; if (diffTime >= 300) { lastTime_ = HALTick::GetInstance().GetTime(); TjdUiAppBreathingView::GetInstance()->SetBreathingImage(g_pv_animatorInfo1_[pic_count]); pic_count++; // printf("line = %d ,cxin is test diffTime = %d ==pic_count=%d\n", __LINE__, diffTime, pic_count); } break; case 1: diffTime = HALTick::GetInstance().GetTime() - lastTime_; if (diffTime >= 300) { lastTime_ = HALTick::GetInstance().GetTime(); TjdUiAppBreathingView::GetInstance()->SetBreathingImage(g_pv_animatorInfo2_[pic_count]); pic_count++; // printf("line = %d ,cxin is test diffTime = %d ==pic_count=%d\n", __LINE__, diffTime, pic_count); } break; default: break; } break; default: break; } } void TjdUiAppBreathingView::SetBreathingImage(OHOS::ImageInfo *imageInfo) { imageBreathing_->SetSrc(imageInfo); } OHOS::UIScrollView *TjdUiAppBreathingView::InitBreathingAnimationView() { OHOS::UIScrollView *breathingAnimationUiView = new OHOS::UIScrollView(); breathingAnimationUiView->SetPosition(0, 0, 466, 466); breathingAnimationUiView->SetOnDragListener(TjdUiAppBreathingPresenter::GetInstance()); if (lblLabel4_ == nullptr) { lblLabel4_ = new UILabelExt(); } lblLabel4_->SetFont(TJD_VECTOR_FONT_FILENAME, 34); // lblLabel4_->SetText("吸气"); lblLabel4_->SetTextId(STR_ID_133); // lblLabel4_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); lblLabel4_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); lblLabel4_->SetPosition(0, 391, 466, 45); // if (imageAnimatorinhale_ == nullptr) { // imageAnimatorinhale_ = new OHOS::UIImageAnimatorView(); // } // imageAnimatorinhale_->SetPosition(111, 60, 272, 281); // imageAnimatorinhale_->SetVisible(true); // imageAnimatorinhale_->SetImageAnimatorSrc(g_pv_animatorInfo3_, HALE_ANIMATOR_COUNT, 300); // // imageAnimatorinhale_->Start(); // breathingAnimationUiView->Add(imageAnimatorinhale_); // if (imageBreathing_ == nullptr) { // imageBreathing_ = new OHOS::UIImageView(); // } // imageBreathing_->SetPosition(60, 60); // auto imageinfo = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_BREATHING_DT_01_03, // BREATHING_IMAGE_BIN_PATH); if(imageinfo != nullptr) // imageBreathing_->SetSrc(imageinfo); // if (breathingTimer_ == nullptr) { // breathingTimer_ = new OHOS::GraphicTimer(225, BreathingTimerCallBack, nullptr, true); // } // breathingAnimationUiView->Add(imageBreathing_); canvas_.SetPosition(0, 0, 466, 466); canvas_.SetStyle(OHOS::STYLE_BACKGROUND_OPA, OHOS::OPA_OPAQUE); breathingAnimationUiView->Add(&canvas_); if (imageBreathing_ == nullptr) { imageBreathing_ = new OHOS::UIImageView(); } imageBreathing_->SetPosition(99, 101, 267, 264); auto imageinfo = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_BREATHING_BREATHE_DT_10_03, BREATHING_IMAGE_BIN_PATH); if (imageinfo != nullptr) imageBreathing_->SetSrc(imageinfo); breathingAnimationUiView->Add(imageBreathing_); callBack_ = new BrethingAnimatorCallback(); animator_ = new Animator(callBack_, &canvas_, 0, true); breathingAnimationUiView->Add(lblLabel4_); breathingAnimationUiView->SetVisible(false); return breathingAnimationUiView; } OHOS::UIViewGroup *TjdUiAppBreathingView::InitBreathingAnotherAnimationView() { OHOS::UIViewGroup *breathingAnotherUiView = new OHOS::UIViewGroup(); breathingAnotherUiView->SetPosition(0, 0, 466, 466); breathingAnotherUiView->SetOnDragListener(TjdUiAppBreathingPresenter::GetInstance()); // if (lblLabel5_ == nullptr) { // lblLabel5_ = new UILabel(); // } // lblLabel5_->SetFont(TJD_VECTOR_FONT_FILENAME, 34); // lblLabel5_->SetText("呼气"); // lblLabel5_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); // lblLabel5_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); // lblLabel5_->SetPosition(199, 391); // imageAnimatorexhale_ = new OHOS::UIImageAnimatorView(); // imageAnimatorexhale_->SetPosition(111, 60, 272, 281); // imageAnimatorexhale_->SetImageAnimatorSrc(g_pv_animatorInfo2_, EXHALE_ANIMATOR_COUNT, 176); // // imageAnimatorexhale_->Start(); // imageAnimatorexhale_->SetVisible(false); // breathingAnotherUiView->Add(imageAnimatorexhale_); // breathingAnotherUiView->Add(lblLabel5_); // breathingAnotherUiView->SetVisible(false); return breathingAnotherUiView; } OHOS::UIScrollView *TjdUiAppBreathingView::InitBreathingTrainingFinishedView() { OHOS::UIScrollView *breathingTrainingFinishedUiView = new OHOS::UIScrollView(); breathingTrainingFinishedUiView->SetPosition(0, 0, 466, 466); breathingTrainingFinishedUiView->SetOnDragListener(TjdUiAppBreathingPresenter::GetInstance()); if (lblFinishhead_ == nullptr) { lblFinishhead_ = new UILabelExt(); } lblFinishhead_->SetFont(TJD_VECTOR_FONT_FILENAME, 36); // lblFinishhead_->SetText("完成训练"); lblFinishhead_->SetTextId(STR_ID_135); lblFinishhead_->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); lblFinishhead_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); lblFinishhead_->SetPosition(161, 28, 142, 47); if (redHeart_ == nullptr) { redHeart_ = new OHOS::UIImageView(); } redHeart_->SetPosition(126, 257, 35, 31); if (g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_HEART] != nullptr) { redHeart_->SetSrc(g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_HEART]); } if (lblAllTimes_ == nullptr) { lblAllTimes_ = new UILabel(); } lblAllTimes_->SetFont(TJD_VECTOR_FONT_FILENAME, 40); lblAllTimes_->SetText("01 : 00"); lblAllTimes_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); lblAllTimes_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); lblAllTimes_->SetStyle(STYLE_TEXT_OPA, OPA_OPAQUE * 0.3); lblAllTimes_->SetPosition(170, 117); if (lblHeart_ == nullptr) { lblHeart_ = new UILabel(); } lblHeart_->SetFont(TJD_VECTOR_FONT_FILENAME, 50); lblHeart_->SetText("100"); lblHeart_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); lblHeart_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); lblHeart_->SetPosition(172, 233); if (lblLabel6_ == nullptr) { lblLabel6_ = new UILabel(); } lblLabel6_->SetFont(TJD_VECTOR_FONT_FILENAME, 30); lblLabel6_->SetText("bpm"); lblLabel6_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); lblLabel6_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); lblLabel6_->SetPosition(272, 247); // enter if (finishBreathing_ == nullptr) { finishBreathing_ = new OHOS::UIImageView(); } finishBreathing_->SetPosition(187, 352, 92, 92); finishBreathing_->SetViewId(FINISHED_ID); finishBreathing_->SetTouchable(true); finishBreathing_->SetOnClickListener(TjdUiAppBreathingPresenter::GetInstance()); if (g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_START] != nullptr) { finishBreathing_->SetSrc(g_pv_breathingimageInfo[BreathingImageInfoIndex::BREATHING_INFO_START]); } if (labelButton7_ == nullptr) { labelButton7_ = new UIView(); } labelButton7_->SetPosition(8, 179); labelButton7_->Resize(450, 128); labelButton7_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff202020); labelButton7_->SetStyle(STYLE_BORDER_RADIUS, 64); // lbAverageHertrate_->SetText("平均心率"); // lbAverageHertrate_->SetTextId(STR_ID_111); // lbAverageHertrate_->SetAlign(TEXT_ALIGNMENT_LEFT); // lbAverageHertrate_->SetLabelPosition(149, -49); // lbAverageHertrate_->SetFont(TJD_VECTOR_FONT_FILENAME, 36); // lbAverageHertrate_->SetTextColor(OHOS::Color::GetColorFromRGB(0x80, 0x80, 0x80)); if (lbAverageHertrate_ == nullptr) { lbAverageHertrate_ = new UILabelExt(); } lbAverageHertrate_->SetFont(TJD_VECTOR_FONT_FILENAME, 36); lbAverageHertrate_->SetTextId(STR_ID_111); // lbAverageHertrate_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); lbAverageHertrate_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); lbAverageHertrate_->SetPosition(0, 191, 466, 47); lbAverageHertrate_->SetTextColor(OHOS::Color::GetColorFromRGB(0x80, 0x80, 0x80)); if (labelButton8_ == nullptr) { labelButton8_ = new UIView(); } labelButton8_->SetPosition(70, 79); labelButton8_->Resize(326, 92); labelButton8_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff202020); labelButton8_->SetStyle(STYLE_BORDER_RADIUS, 46); // labelButton8_->SetText("平均时间"); // labelButton8_->SetTextId(STR_ID_555); // labelButton8_->SetAlign(TEXT_ALIGNMENT_LEFT); // labelButton8_->SetLabelPosition(118, -37); // labelButton8_->SetFont(TJD_VECTOR_FONT_FILENAME, 24); // labelButton8_->SetTextColor(OHOS::Color::GetColorFromRGB(0x80, 0x80, 0x80)); // labelButton8_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff0b1928, UIButton::PRESSED); // labelButton8_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); if (lbAverageTime_ == nullptr) { lbAverageTime_ = new UILabelExt(); } lbAverageTime_->SetFont(TJD_VECTOR_FONT_FILENAME, 24); lbAverageTime_->SetTextId(STR_ID_555); lbAverageTime_->SetTextColor(OHOS::Color::GetColorFromRGB(0x80, 0x80, 0x80)); // lbAverageTime_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); lbAverageTime_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); lbAverageTime_->SetPosition(0, 86, 466, 31); breathingTrainingFinishedUiView->Add(lblFinishhead_); breathingTrainingFinishedUiView->Add(finishBreathing_); breathingTrainingFinishedUiView->Add(labelButton7_); breathingTrainingFinishedUiView->Add(labelButton8_); breathingTrainingFinishedUiView->Add(lblAllTimes_); breathingTrainingFinishedUiView->Add(lblHeart_); breathingTrainingFinishedUiView->Add(lblLabel6_); breathingTrainingFinishedUiView->Add(redHeart_); breathingTrainingFinishedUiView->Add(lbAverageHertrate_); breathingTrainingFinishedUiView->Add(lbAverageTime_); breathingTrainingFinishedUiView->SetVisible(false); return breathingTrainingFinishedUiView; } } // namespace TJD