#include "TjdUiAppStopwatchView.h" #include "TjdUiImageIds.h" #include "TjdUiMultiLanguageExt.h" #include "TjdUiUtils.h" #include "common/image_cache_manager.h" #include "gfx_utils/mem_check.h" #include "sys_config.h" #include "ui_screennotify.h" #include "ui_view.h" #include #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 using namespace OHOS; namespace TJD { enum StopwatchImageInfoIndex { STOPWATCH_INFO_START, STOPWATCH_INFO_PAUSE, STOPWATCH_INFO_RESUME, STOPWATCH_INFO_CLEAR, STOPWATCH_INFO_LIST, STOPWATCH_INFO_MIN_STOPWATCH, STOPWATCH_INFO_START_AGAIN, STOPWATCH_INFO_COUNT }; #define STOPWATCH_IMAGE_BIN_PATH TJD_IMAGE_PATH "img_stopwatch.bin" #define IF_MEM_CHECK 0 // const Vector2 VIEW_CENTER = { 232, 151 }; // const Vector2 VIEW_CENTER = { 118, 96 }; // const Vector2 VIEW_CENTER = { 93, 67 }; const Vector2 VIEW_CENTER = {-135, -60}; bool StopwatchUIScrollView::OnDragStartEvent(const OHOS::DragEvent &event) { if (TjdUiAppStopwatchView::GetInstance()->GetCurrentView() != StopwatchViewIndex::STOPWATCH_START_VIEW) { return true; } isOnStart_ = true; return OHOS::UIScrollViewNested::OnDragStartEvent(event); } bool StopwatchUIScrollView::OnDragEvent(const OHOS::DragEvent &event) { if (!isOnStart_) { return true; } if (TjdUiAppStopwatchView::GetInstance()->GetCurrentView() != StopwatchViewIndex::STOPWATCH_START_VIEW) { return true; } return OHOS::UIScrollViewNested::OnDragEvent(event); } bool StopwatchUIScrollView::OnDragEndEvent(const OHOS::DragEvent &event) { if (!isOnStart_) { return true; } isOnStart_ = false; if (TjdUiAppStopwatchView::GetInstance()->GetCurrentView() != StopwatchViewIndex::STOPWATCH_START_VIEW) { return true; } return OHOS::UIScrollViewNested::OnDragEndEvent(event); } static OHOS::ImageInfo *g_pv_stopwatchimageInfo[StopwatchImageInfoIndex::STOPWATCH_INFO_COUNT]{nullptr}; static TjdUiAppStopwatchView *g_pv_AppStopwatchView = nullptr; TjdUiAppStopwatchView::TjdUiAppStopwatchView() { if (IF_MEM_CHECK) OHOS::MemCheck::GetInstance()->EnableLeakCheck(true); g_pv_AppStopwatchView = this; } TjdUiAppStopwatchView::~TjdUiAppStopwatchView() { g_pv_AppStopwatchView = nullptr; if (IF_MEM_CHECK) OHOS::MemCheck::GetInstance()->EnableLeakCheck(false); } TjdUiAppStopwatchView *TjdUiAppStopwatchView::GetInstance(void) { return g_pv_AppStopwatchView; } void TjdUiAppStopwatchView::OnStart() { set_back_to_home_interval(0xFFFFFFFF); View::OnStart(); InitStopwatchImage(); if (containerAll_ == nullptr) { containerAll_ = new StopwatchUIScrollView(); } containerAll_->SetPosition(0, 0, OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION); stopwatchView[StopwatchViewIndex::STOPWATCH_START_VIEW] = InitStopwatchStartView(); stopwatchView[StopwatchViewIndex::STOPWATCH_CARRY_VIEW] = InitStopwatchCarryView(); containerAll_->Add(stopwatchView[StopwatchViewIndex::STOPWATCH_START_VIEW]); containerAll_->Add(stopwatchView[StopwatchViewIndex::STOPWATCH_CARRY_VIEW]); AddViewToRootContainer(containerAll_); } void TjdUiAppStopwatchView::OnStop() { FocusManager::GetInstance()->ClearFocus(); set_back_to_home_interval(5); if (moveAnimator_ != nullptr) { moveAnimator_->Stop(); delete moveAnimator_; moveAnimator_ = nullptr; } if (callBack_ != nullptr) { delete callBack_; callBack_ = nullptr; } if (timerMoveLabel_ != nullptr) { delete timerMoveLabel_; timerMoveLabel_ = nullptr; } if (stopwatchListAdapter_ != nullptr) { delete stopwatchListAdapter_; stopwatchListAdapter_ = nullptr; } if (stopwatchInfoList_ != nullptr) { stopwatchInfoList_->Clear(); delete stopwatchInfoList_; stopwatchInfoList_ = nullptr; } ImageCacheManager::GetInstance().UnloadAllInMultiRes(STOPWATCH_IMAGE_BIN_PATH); TjdUiMemManage::DeleteChildren(containerAll_); } void TjdUiAppStopwatchView::ShowView(StopwatchViewIndex hideView, StopwatchViewIndex showView) { if (stopwatchView[hideView] != nullptr) { stopwatchView[hideView]->SetVisible(false); } if (stopwatchView[showView] != nullptr) { stopwatchView[showView]->SetVisible(true); currentView_ = showView; } } void TjdUiAppStopwatchView::InitStopwatchImage() { OHOS::ImageCacheManager::GetInstance().LoadAllInMultiRes(STOPWATCH_IMAGE_BIN_PATH); g_pv_stopwatchimageInfo[StopwatchImageInfoIndex::STOPWATCH_INFO_START] = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_STOPWATCH_STOPWATCH_01, STOPWATCH_IMAGE_BIN_PATH); g_pv_stopwatchimageInfo[StopwatchImageInfoIndex::STOPWATCH_INFO_PAUSE] = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_STOPWATCH_PAUSE, STOPWATCH_IMAGE_BIN_PATH); g_pv_stopwatchimageInfo[StopwatchImageInfoIndex::STOPWATCH_INFO_RESUME] = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_STOPWATCH_START_RESUME, STOPWATCH_IMAGE_BIN_PATH); g_pv_stopwatchimageInfo[StopwatchImageInfoIndex::STOPWATCH_INFO_CLEAR] = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_STOPWATCH_RESET, STOPWATCH_IMAGE_BIN_PATH); g_pv_stopwatchimageInfo[StopwatchImageInfoIndex::STOPWATCH_INFO_LIST] = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_STOPWATCH_LIST, STOPWATCH_IMAGE_BIN_PATH); g_pv_stopwatchimageInfo[StopwatchImageInfoIndex::STOPWATCH_INFO_MIN_STOPWATCH] = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_STOPWATCH_STOPWATCH_02, STOPWATCH_IMAGE_BIN_PATH); g_pv_stopwatchimageInfo[StopwatchImageInfoIndex::STOPWATCH_INFO_START_AGAIN] = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_STOPWATCH_START_RESUME, STOPWATCH_IMAGE_BIN_PATH); } StopwatchCaseInfo g_pv_Stopwatch[] = {nullptr}; void TjdUiAppStopwatchView::ChangestatusPause() { stopwatchList1_->SetVisible(false); stopwatchPause1_->SetVisible(false); stopwatchResume_->SetVisible(true); stopwatchClear_->SetVisible(true); } void TjdUiAppStopwatchView::ChangestatusPause_() { stopwatchList1_->SetVisible(false); stopwatchPause2_->SetVisible(false); stopwatchResume_->SetVisible(true); stopwatchClear_->SetVisible(true); } void TjdUiAppStopwatchView::ChangeAnimator() { if (timerMoveLabel_ != nullptr) { delete timerMoveLabel_; timerMoveLabel_ = nullptr; } if (moveAnimator_ != nullptr) { moveAnimator_->Stop(); delete moveAnimator_; moveAnimator_ = nullptr; } if (callBack_ != nullptr) { delete callBack_; callBack_ = nullptr; } } void TjdUiAppStopwatchView::ChangestatusResume() { stopwatchList1_->SetVisible(true); stopwatchPause1_->SetVisible(true); stopwatchResume_->SetVisible(false); stopwatchClear_->SetVisible(false); } void TjdUiAppStopwatchView::ChangestatusClear() { lblStopWatchCarryTime_->SetFont(TJD_DIN_MEDIUM_FONT_FILENAME, 72); lblStopWatchCarryTime_->SetPosition(107, 230); lblStopWatchCarryTime_->SetText("00:00:00"); moveX = 107; moveY = 230; changeSize = 72; stopwatchImageScale_->SetVisible(false); stopwatchImageScaleTwo->SetVisible(true); // stopwatchImageScaleTwo->SetVisible(true); // stopwatchImageScaleTwo->SetPosition(174, 83, 117, 136); // stopwatchImageScaleTwo->SetResizeMode(UIImageView::ImageResizeMode::CENTER); // stopwatchImageScaleTwo->SetSrc(g_pv_stopwatchimageInfo[StopwatchImageInfoIndex::STOPWATCH_INFO_START]); // callBack_ = new StopwatchAnimatorCallback(stopwatchImageScaleTwo); // moveAnimator_ = new Animator(callBack_, stopwatchImageScaleTwo, 1500, false); stopwatchList1_->SetVisible(true); stopwatchPause1_->SetVisible(true); stopwatchPause2_->SetVisible(false); stopwatchResume_->SetVisible(false); stopwatchClear_->SetVisible(false); stopwatchList_->SetVisible(false); TjdUiAppStopwatchView::GetInstance()->listBg1.SetVisible(false); TjdUiAppStopwatchView::GetInstance()->listBg2.SetVisible(false); stopwatchList_->SetDraggable(false); time1_ = 0; time6_ = 0; timestamp = 0; timeinterval = 0; boolFlagAgain_ = false; stopwatchInfoList_->Clear(); } // void StopwatchAnimatorCallback::ChangeClear() // { // stopwatchImageScale_->SetVisible(true); // stopwatchImageScale_->SetPosition(174, 83, 117, 136); // stopwatchImageScale_->SetResizeMode(UIImageView::ImageResizeMode::CENTER); // stopwatchImageScale_->SetSrc(g_pv_stopwatchimageInfo[StopwatchImageInfoIndex::STOPWATCH_INFO_START]); // } void TjdUiAppStopwatchView::StopTimer() { timerMoveLabel_->Stop(); static_print_info("TjdUiAppStopwatchView::%s", __func__); } void TjdUiAppStopwatchView::StartAnimator() { if (!animateStart_) { moveAnimator_->Start(); // timerMoveLabel_->Start(); animateStart_ = false; callBack_->startTimestamp = HALTick::GetInstance().GetTime(); } else { static_print_info("TjdUiAppStopwatchView::%s", __func__); } } void TjdUiAppStopwatchView::CoumtNumInit() { countNum_ = 0; // 初始化计次次数 } void TjdUiAppStopwatchView::StopAiainAnimator(int8_t boolnum) { if (boolnum == 0) { animateStart_ = true; } if (boolnum == 1) { animateStart_ = false; // 播放动画的初始条件 } } void TjdUiAppStopwatchView::ShowList() { countNum_++; if (countNum_ < 10) { if (countNum_ == 3) { stopwatchList_->SetDraggable(true); } textStopwatch2_ = textStopwatch2_ + " " + std::to_string(countNum_); } else if (countNum_ >= 10 && countNum_ <= 20) { textStopwatch2_ = textStopwatch2_ + " " + std::to_string(countNum_); } else { countNum_ = 0; } g_pv_Stopwatch[0].timeNum = textStopwatch2_; stopwatchInfoList_->PushFront(g_pv_Stopwatch[0]); stopwatchList_->RefreshList(); // stopwatchImageScale_->SetVisible(true); stopwatchList_->SetVisible(true); stopwatchList_->RequestFocus(); TjdUiAppStopwatchView::GetInstance()->listBg1.SetVisible(true); TjdUiAppStopwatchView::GetInstance()->listBg2.SetVisible(true); // lblStopWatchCarryTime_->SetFont(TJD_VECTOR_FONT_FILENAME, 50); // lblStopWatchCarryTime_->SetPosition(170, 60); stopwatchPause1_->SetVisible(false); stopwatchPause2_->SetVisible(true); stopwatchImageScale_->SetVisible(true); stopwatchImageScaleTwo->SetVisible(false); } void TjdUiAppStopwatchView::SetStopWatchListOpa(uint8_t opa) { stopwatchList1_->SetStyle(OHOS::STYLE_IMAGE_OPA, opa); stopwatchList1_->Invalidate(); } void TjdUiAppStopwatchView::UpdateStopwatchTime() { if (!boolFlagAgain_) { struct rtc_class_ops *rtc_api = tjd_driver_rtc_get_ops(); rtc_api->get_ms_timestamp(×tamp); time1_ = timestamp - timeinterval + time6_; if (time1_ < 3600000) { time1_ = time1_ / 10; if (time1_ < 6000 && time2_ < 1) { if (time1_ < 100) { std::string textStopwatch1_ = "00:00:" + std::to_string((time1_ / 10) % 10) + std::to_string(time1_ % 10); lblStopWatchCarryTime_->SetText(textStopwatch1_.c_str()); textStopwatch2_ = textStopwatch1_; } else if (time1_ < 1000 && time1_ >= 100) { std::string textStopwatch1_ = "00:0" + std::to_string(time1_ / 100) + ":" + std::to_string((time1_ / 10) % 10) + std::to_string(time1_ % 10); lblStopWatchCarryTime_->SetText(textStopwatch1_.c_str()); textStopwatch2_ = textStopwatch1_; } else { std::string textStopwatch1_ = "00:" + std::to_string(time1_ / 1000) + std::to_string((time1_ / 100) % 10) + ":" + std::to_string((time1_ / 10) % 10) + std::to_string(time1_ % 10); lblStopWatchCarryTime_->SetText(textStopwatch1_.c_str()); textStopwatch2_ = textStopwatch1_; } } else { time2_ = time1_ / 6000; time3_ = time1_ - 6000 * time2_; if (time2_ >= 10) { time4_ = (time2_ / 10) % 10; time5_ = time2_ % 10; } else { time5_ = time2_; } if (time3_ < 100) { std::string textStopwatch1_ = std::to_string(time4_) + std::to_string(time5_) + ":00:" + std::to_string((time3_ / 10) % 10) + std::to_string(time3_ % 10); lblStopWatchCarryTime_->SetText(textStopwatch1_.c_str()); textStopwatch2_ = textStopwatch1_; } else if (time3_ < 1000 && time3_ >= 100) { std::string textStopwatch1_ = std::to_string(time4_) + std::to_string(time5_) + ":0" + std::to_string(time3_ / 100) + ":" + std::to_string((time3_ / 10) % 10) + std::to_string(time3_ % 10); lblStopWatchCarryTime_->SetText(textStopwatch1_.c_str()); textStopwatch2_ = textStopwatch1_; } else { std::string textStopwatch1_ = std::to_string(time4_) + std::to_string(time5_) + ":" + std::to_string(time3_ / 1000) + std::to_string((time3_ / 100) % 10) + ":" + std::to_string((time3_ / 10) % 10) + std::to_string(time3_ % 10); lblStopWatchCarryTime_->SetText(textStopwatch1_.c_str()); textStopwatch2_ = textStopwatch1_; } } } else { timeinterval = timestamp; } } else { struct rtc_class_ops *rtc_api_ = tjd_driver_rtc_get_ops(); rtc_api_->get_ms_timestamp(&timeinterval); boolFlagAgain_ = false; } } void TjdUiAppStopwatchView::SaveStopwatchTime() { boolFlagAgain_ = true; time6_ = time1_ * 10; } OHOS::UIScrollView *TjdUiAppStopwatchView::InitStopwatchStartView() { OHOS::UIScrollView *stopWatchStartView = new OHOS::UIScrollView(); stopWatchStartView->SetPosition(0, 0, 466, 466); if (OHOS::PageTransitionMgr::GetInstance().GetTopSlideBackImage() == nullptr) { stopWatchStartView->SetOnDragListener(TjdUiAppStopwatchPresenter::GetInstance()); } if (lblTopStopWatch1_ == nullptr) { lblTopStopWatch1_ = new UILabelExt(); } lblTopStopWatch1_->SetFont(TJD_VECTOR_FONT_FILENAME, 36); // lblTopStopWatch1_->SetText("秒表"); lblTopStopWatch1_->SetTextId(STR_ID_13); lblTopStopWatch1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); lblTopStopWatch1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); lblTopStopWatch1_->SetPosition(199, 28); TjdUiUtils::AutoAlignHorizontalCenter(*lblTopStopWatch1_); if (lblStopWatchStartTime_ == nullptr) { lblStopWatchStartTime_ = new UILabel(); } lblStopWatchStartTime_->SetFont(TJD_DIN_MEDIUM_FONT_FILENAME, 72); lblStopWatchStartTime_->SetText("00:00:00"); lblStopWatchStartTime_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); lblStopWatchStartTime_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); lblStopWatchStartTime_->SetPosition(107, 230); if (stopwatchImage1_ == nullptr) { stopwatchImage1_ = new OHOS::UIImageView(); } stopwatchImage1_->SetPosition(179, 92, 113, 126); if (g_pv_stopwatchimageInfo[StopwatchImageInfoIndex::STOPWATCH_INFO_START] != nullptr) { stopwatchImage1_->SetSrc(g_pv_stopwatchimageInfo[StopwatchImageInfoIndex::STOPWATCH_INFO_START]); } if (stopwatchStart1_ == nullptr) { stopwatchStart1_ = new OHOS::UIImageView(); } stopwatchStart1_->SetPosition(187, 330, 92, 92); stopwatchStart1_->SetTouchable(true); stopwatchStart1_->SetOnClickListener(TjdUiAppStopwatchPresenter::GetInstance()); stopwatchStart1_->SetViewId(STOPWATCH_START_ID); if (g_pv_stopwatchimageInfo[StopwatchImageInfoIndex::STOPWATCH_INFO_START_AGAIN] != nullptr) { stopwatchStart1_->SetSrc(g_pv_stopwatchimageInfo[StopwatchImageInfoIndex::STOPWATCH_INFO_START_AGAIN]); } stopWatchStartView->Add(lblTopStopWatch1_); stopWatchStartView->Add(lblStopWatchStartTime_); stopWatchStartView->Add(stopwatchImage1_); stopWatchStartView->Add(stopwatchStart1_); stopWatchStartView->SetVisible(true); return stopWatchStartView; } void TjdUiAppStopwatchView::MoveLabel() { if (changeSize <= 72 && changeSize >= 52) { changeSize--; } if (moveX <= 161 && moveX >= 107) { moveX += 3; } if (moveY <= 230 && moveY >= 76) { moveY -= 7; } lblStopWatchCarryTime_->SetFont(TJD_DIN_MEDIUM_FONT_FILENAME, changeSize); lblStopWatchCarryTime_->SetPosition(moveX, moveY); } void MoveTimeCallback(void *param) { TjdUiAppStopwatchView::GetInstance()->MoveLabel(); } OHOS::UIScrollView *TjdUiAppStopwatchView::InitStopwatchCarryView() { OHOS::UIScrollView *stopWatchCarryView = new OHOS::UIScrollView(); stopWatchCarryView->SetPosition(0, 0, 466, 466); stopWatchCarryView->SetOnDragListener(TjdUiAppStopwatchPresenter::GetInstance()); if (lblTopStopWatch2_ == nullptr) { lblTopStopWatch2_ = new UILabel(); } lblTopStopWatch2_->SetFont(TJD_VECTOR_FONT_FILENAME, 36); lblTopStopWatch2_->SetText("秒表"); lblTopStopWatch2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); lblTopStopWatch2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); lblTopStopWatch2_->SetPosition(199, 28); if (lblStopWatchCarryTime_ == nullptr) { lblStopWatchCarryTime_ = new UILabel(); } lblStopWatchCarryTime_->SetFont(TJD_DIN_MEDIUM_FONT_FILENAME, 72); lblStopWatchCarryTime_->SetText("00:00:00"); lblStopWatchCarryTime_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); lblStopWatchCarryTime_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); lblStopWatchCarryTime_->SetPosition(107, 230); if (stopwatchImageScale_ == nullptr) { stopwatchImageScale_ = new OHOS::UIImageView(); } stopwatchImageScale_->SetPosition(179, 92); // stopwatchImageScale_->SetResizeMode(UIImageView::ImageResizeMode::CENTER); if (g_pv_stopwatchimageInfo[StopwatchImageInfoIndex::STOPWATCH_INFO_START] != nullptr) { stopwatchImageScale_->SetSrc(g_pv_stopwatchimageInfo[StopwatchImageInfoIndex::STOPWATCH_INFO_START]); } if (stopwatchImageScaleTwo == nullptr) { stopwatchImageScaleTwo = new OHOS::UIImageView(); } stopwatchImageScaleTwo->SetPosition(179, 92); // stopwatchImageScaleTwo->SetResizeMode(UIImageView::ImageResizeMode::CENTER); stopwatchImageScaleTwo->SetVisible(false); if (g_pv_stopwatchimageInfo[StopwatchImageInfoIndex::STOPWATCH_INFO_START] != nullptr) { stopwatchImageScaleTwo->SetSrc(g_pv_stopwatchimageInfo[StopwatchImageInfoIndex::STOPWATCH_INFO_START]); } if (callBack_ == nullptr) { callBack_ = new StopwatchAnimatorCallback(stopwatchImageScale_); } if (moveAnimator_ == nullptr) { moveAnimator_ = new Animator(callBack_, stopwatchImageScale_, 1500, true); } callBack_->SetAnimator(moveAnimator_); callBack_->SetLabel(lblStopWatchCarryTime_); animateStart_ = false; if (timerMoveLabel_ == nullptr) { timerMoveLabel_ = new OHOS::GraphicTimer(100, MoveTimeCallback, nullptr, true); } if (stopwatchStart2_ == nullptr) { stopwatchStart2_ = new OHOS::UIImageView(); } stopwatchStart2_->SetPosition(92, 68, 52, 57); stopwatchStart2_->SetOnClickListener(TjdUiAppStopwatchPresenter::GetInstance()); stopwatchStart2_->SetVisible(false); if (g_pv_stopwatchimageInfo[StopwatchImageInfoIndex::STOPWATCH_INFO_MIN_STOPWATCH] != nullptr) { stopwatchStart2_->SetSrc(g_pv_stopwatchimageInfo[StopwatchImageInfoIndex::STOPWATCH_INFO_MIN_STOPWATCH]); } if (stopwatchPause1_ == nullptr) { stopwatchPause1_ = new OHOS::UIImageView(); } stopwatchPause1_->SetTouchable(true); stopwatchPause1_->SetOnClickListener(TjdUiAppStopwatchPresenter::GetInstance()); stopwatchPause1_->SetViewId(STOPWATCH_PAUSE_ID_1); stopwatchPause1_->SetPosition(103, 326, 92, 92); stopwatchPause1_->SetVisible(true); if (g_pv_stopwatchimageInfo[StopwatchImageInfoIndex::STOPWATCH_INFO_PAUSE] != nullptr) { stopwatchPause1_->SetSrc(g_pv_stopwatchimageInfo[StopwatchImageInfoIndex::STOPWATCH_INFO_PAUSE]); } if (stopwatchPause2_ == nullptr) { stopwatchPause2_ = new OHOS::UIImageView(); } stopwatchPause2_->SetTouchable(true); stopwatchPause2_->SetOnClickListener(TjdUiAppStopwatchPresenter::GetInstance()); stopwatchPause2_->SetViewId(STOPWATCH_PAUSE_ID_2); stopwatchPause2_->SetPosition(103, 326, 92, 92); stopwatchPause2_->SetVisible(false); if (g_pv_stopwatchimageInfo[StopwatchImageInfoIndex::STOPWATCH_INFO_PAUSE] != nullptr) { stopwatchPause2_->SetSrc(g_pv_stopwatchimageInfo[StopwatchImageInfoIndex::STOPWATCH_INFO_PAUSE]); } if (stopwatchList1_ == nullptr) { stopwatchList1_ = new OHOS::UIImageView(); } stopwatchList1_->SetTouchable(true); stopwatchList1_->SetOnClickListener(TjdUiAppStopwatchPresenter::GetInstance()); stopwatchList1_->SetViewId(STOPWATCH_LIST_ID); stopwatchList1_->SetPosition(271, 326, 92, 92); stopwatchList1_->SetVisible(true); if (g_pv_stopwatchimageInfo[StopwatchImageInfoIndex::STOPWATCH_INFO_LIST] != nullptr) { stopwatchList1_->SetSrc(g_pv_stopwatchimageInfo[StopwatchImageInfoIndex::STOPWATCH_INFO_LIST]); } if (stopwatchResume_ == nullptr) { stopwatchResume_ = new OHOS::UIImageView(); } stopwatchResume_->SetTouchable(true); stopwatchResume_->SetOnClickListener(TjdUiAppStopwatchPresenter::GetInstance()); stopwatchResume_->SetViewId(STOPWATCH_RESUME_ID); stopwatchResume_->SetPosition(103, 326, 92, 92); stopwatchResume_->SetVisible(false); if (g_pv_stopwatchimageInfo[StopwatchImageInfoIndex::STOPWATCH_INFO_RESUME] != nullptr) { stopwatchResume_->SetSrc(g_pv_stopwatchimageInfo[StopwatchImageInfoIndex::STOPWATCH_INFO_RESUME]); } if (stopwatchClear_ == nullptr) { stopwatchClear_ = new OHOS::UIImageView(); } stopwatchClear_->SetTouchable(true); stopwatchClear_->SetOnClickListener(TjdUiAppStopwatchPresenter::GetInstance()); stopwatchClear_->SetViewId(STOPWATCH_CLEAR_ID); stopwatchClear_->SetPosition(271, 326, 92, 92); stopwatchClear_->SetVisible(false); if (g_pv_stopwatchimageInfo[StopwatchImageInfoIndex::STOPWATCH_INFO_CLEAR] != nullptr) { stopwatchClear_->SetSrc(g_pv_stopwatchimageInfo[StopwatchImageInfoIndex::STOPWATCH_INFO_CLEAR]); } if (stopwatchInfoList_ == nullptr) { stopwatchInfoList_ = new OHOS::List(); } stopwatchInfoList_->Clear(); if (stopwatchListAdapter_ == nullptr) { stopwatchListAdapter_ = new TjdUiAppStopwatchAdapter(); } if (stopwatchList_ == nullptr) { stopwatchList_ = new OHOS::UIList(); } stopwatchList_->SetPosition(33, 154, 400, 186); stopwatchList_->SetAdapter(stopwatchListAdapter_); // stopwatchList_->SetYScrollBarVisible(true); stopwatchList_->SetVisible(false); stopwatchList_->SetDraggable(false); stopwatchList_->SetStartIndex(0); stopwatchList_->SetThrowDrag(true); stopwatchList_->SetSwipeACCLevel(15); stopwatchList_->SetDragACCLevel(10); stopwatchList_->EnableAutoAlign(true); stopwatchList_->SetAutoAlignTime(200); stopwatchList_->SetSelectPosition(247); listBg1.SetPosition(33, 225, 400, 59); listBg1.SetStyle(STYLE_BACKGROUND_OPA, 0xff * 0.7); listBg1.SetVisible(false); listBg2.SetPosition(33, 284, 400, 59); listBg2.SetStyle(STYLE_BACKGROUND_OPA, 0xff * 0.9); listBg2.SetVisible(false); stopWatchCarryView->Add(stopwatchList_); stopWatchCarryView->Add(&listBg1); stopWatchCarryView->Add(&listBg2); stopWatchCarryView->Add(lblTopStopWatch2_); stopWatchCarryView->Add(lblStopWatchCarryTime_); stopWatchCarryView->Add(stopwatchStart2_); stopWatchCarryView->Add(stopwatchImageScale_); stopWatchCarryView->Add(stopwatchImageScaleTwo); stopWatchCarryView->Add(stopwatchPause1_); stopWatchCarryView->Add(stopwatchPause2_); stopWatchCarryView->Add(stopwatchList1_); stopWatchCarryView->Add(stopwatchResume_); stopWatchCarryView->Add(stopwatchClear_); stopWatchCarryView->SetVisible(false); return stopWatchCarryView; } void StopwatchAnimatorCallback::Callback(UIView *view) { curTime += 25; int16_t fontSize = EasingEquation::LinearEaseNone(72, 60, curTime, durationTime); int16_t lbCurX = EasingEquation::LinearEaseNone(labelStartPos_.x, labelEndPos_.x, curTime, durationTime); int16_t lbCurY = EasingEquation::LinearEaseNone(labelStartPos_.y, labelEndPos_.y, curTime, durationTime); label_->SetPosition(lbCurX, lbCurY); label_->SetFont(TJD_DIN_MEDIUM_FONT_FILENAME, fontSize); int16_t scales = EasingEquation::LinearEaseNone(100, 42, curTime, durationTime); int16_t imgCurX = EasingEquation::LinearEaseNone(imageStartPos_.x, imageEndPos_.x, curTime, durationTime); int16_t imgCurY = EasingEquation::LinearEaseNone(imageStartPos_.y, imageEndPos_.y, curTime, durationTime); stopwatchImageScale_->SetPosition(imgCurX, imgCurY); stopwatchImageScale_->Scale({(float)scales / 100.0, (float)scales / 100.0}, {0, 0}); stopwatchImageScale_->Invalidate(); if (curTime >= durationTime) { animator_->Stop(); printf("stop animator = %d | %f\n", scales, (float)scales / 100.0); } } } // namespace TJD