From: Caisking <3449750381@qq.com> Date: Wed, 10 Jan 2024 09:21:19 +0000 (+0800) Subject: 显示更新表盘 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=7859b76c4bd9c355b65ff8cd330cc8298c08b083;p=mirrors%2FFD230.git 显示更新表盘 --- diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/ui_resource_image.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/ui_resource_image.h index fd0516026..20e72a401 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/ui_resource_image.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/ui_resource_image.h @@ -54,6 +54,7 @@ namespace OHOS static const int CLOCK_THURSDAY_IMAGE_PATH = 0x300011; static const int CLOCK_SECONDHAND = 0x300012; static const int CLOCK_TUESDAY_IMAGE_PATH = 0x300013; + /* -------------------------------------------------------------------------- */ static const int DROPDOWN_DROPDOWN_BLUETOOTH = 0x400001; static const int DROPDOWN_DROPDOWN_DN_DISTURB = 0x400002; static const int DROPDOWN_DROPDOWN_BLUETOOTH_B = 0x400003; diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp index 629e195fc..3afa01ac5 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp @@ -455,6 +455,7 @@ void NativeLauncher::InitNativeLauncher() { // 初始化默认首页 ScreenModels::GetInstance()->PreLoadAppimages(); NativeAbility::GetInstance().SetDefaultSliceId(VIEW_MAIN_SAMPLE); + //Digital_clockView::GetInstance()->InitView(); } void NativeLauncher::InitAllNativeSlices(void) diff --git a/code/sdk/application/wearable/nativeapp/nativeui/dial/include/Digital_clockView.h b/code/sdk/application/wearable/nativeapp/nativeui/dial/include/Digital_clockView.h index 06ab15cd2..25e534741 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/dial/include/Digital_clockView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/dial/include/Digital_clockView.h @@ -165,7 +165,7 @@ namespace OHOS // 将小时和分钟转换为字符串,并更新 stringtime stringtime = (hour < 10 ? "0" : "") + std::to_string(hour) + ":" + (minute < 10 ? "0" : "") + std::to_string(minute); printf("Before updating images\n"); - //printf("--%s:%s--\n", imageFolderPath.c_str(), stringtime.c_str()); + // printf("--%s:%s--\n", imageFolderPath.c_str(), stringtime.c_str()); updateImage(hour1, imageFolderPath.c_str(), stringtime.substr(0, 1)); updateImage(hour2, imageFolderPath.c_str(), stringtime.substr(1, 1)); updateImage(minute1, imageFolderPath.c_str(), stringtime.substr(3, 1)); @@ -223,8 +223,8 @@ namespace OHOS void Initdata(); // 初始化日期 void Initweek(); // 初始化星期 void Initbattery(); // 初始化电量 - void PreLoad(void); - + void PreLoad(void) override; + void UnLoad(void) override; private: TraingWinView *p_TraingWinView{nullptr}; UIView::OnDragListener *draglistener{nullptr}; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/dial/src/Digital_clockView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/dial/src/Digital_clockView.cpp index f9e4e7fa5..dd0c5aa11 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/dial/src/Digital_clockView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/dial/src/Digital_clockView.cpp @@ -18,6 +18,8 @@ #include // 用于格式化输出 #include //异常处理 +#include "MainViewSample.h" + #define PRINT_DEBUG_INFO printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__); namespace OHOS @@ -400,6 +402,7 @@ namespace OHOS // Add to rootView container_->Add(weekLable); weekLable->SetVisible(true); + PRINT_DEBUG_INFO }; void Digital_clockView ::Initbattery() { @@ -471,17 +474,15 @@ namespace OHOS progress1callback_ = new myProgressCallback(progress, batteryLable); progress1animator_ = new Animator(progress1callback_, progress, 10000, true); progress1animator_->Start(); + PRINT_DEBUG_INFO }; /* InitView:初始化界面*/ bool Digital_clockView ::InitView() { - if (container_ == nullptr) - { - container_ = new UIViewGroup(); - container_->SetPosition(0, 0); - container_->SetWidth(Screen::GetInstance().GetWidth()); - container_->SetHeight(Screen::GetInstance().GetHeight()); - } + container_ = new UIViewGroup(); + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); if (loadJsonData(JosnfilePath)) { std::string Dialtype = cJSON_GetObjectItem(cjson_json, "Dialtype")->valuestring; @@ -495,13 +496,17 @@ namespace OHOS { Initdigit(); } - - Initdata(); - Initweek(); + Initdata(); + Initweek(); Initbattery(); cJSON_Delete(cjson_json); } + PRINT_DEBUG_INFO + + Add(container_); + PRINT_DEBUG_INFO SetCoverable(true); + PRINT_DEBUG_INFO return true; } /* DeInit:删除组件*/ @@ -587,4 +592,8 @@ namespace OHOS } } + void Digital_clockView::UnLoad(void) + { + + } } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp index f0164a656..155b04c88 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp @@ -140,9 +140,7 @@ void MainViewSample::OnStart() mainSwipeGroup->SetLoopState(true); mainSwipeGroup->EnableScreenCap(true); mainSwipeGroup->RegisterSwipeCallback(callback); - mainSwipeGroup->SetHorCurrentPage(mainClockView->GetViewIndex()); mainSwipeGroup->SetHorCurrentPage(dialView->GetViewIndex()); - SetContainerView(mainSwipeGroup); } @@ -255,7 +253,7 @@ void MainViewSample::OnStop() UICardPage *MainViewSample::InitWatchFacePage(void) { - +printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__); mainClockView = new MainClockView(); if (mainClockView == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainClockView new fail"); @@ -266,6 +264,7 @@ UICardPage *MainViewSample::InitWatchFacePage(void) UICardPage *MainViewSample::InitHeartRatePage(void) { + printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__); heartRateView = new HeartRateView(); if (heartRateView == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "heartRateView new fail"); @@ -276,6 +275,7 @@ UICardPage *MainViewSample::InitHeartRatePage(void) UICardPage *MainViewSample::InitActivityPage(void) { + printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__); activityWeekView = new ActivityWeekView(); if (activityWeekView == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "activityWeekView new fail"); @@ -286,6 +286,7 @@ UICardPage *MainViewSample::InitActivityPage(void) UICardPage *MainViewSample::InitCompassPage(void) { + printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__); compassControlView = new CompassControlView(); if (compassControlView == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "compassControlView new fail"); @@ -296,6 +297,7 @@ UICardPage *MainViewSample::InitCompassPage(void) UICardPage *MainViewSample::InitMusicPlayerPage(void) { + printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__); playersView = new PlayersView(); if (playersView == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "playersView new fail"); @@ -306,6 +308,7 @@ UICardPage *MainViewSample::InitMusicPlayerPage(void) UICardPage *MainViewSample::InitNewDialPage(void) { + printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__); dialView = new Digital_clockView(); if (dialView == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dialView new fail"); @@ -316,34 +319,41 @@ UICardPage *MainViewSample::InitNewDialPage(void) UICardPage *MainViewSample::CreatePage(int32_t StreamId) { + printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__); uint16_t i; UICardPage *view = nullptr; int32_t cardId = ScreenModels::GetInstance()->GetCardPage(StreamId); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CreatePage cardId:%d", cardId); for (i = 0; i < sizeof(PageMapper) / sizeof(PageMapper[0]); i++) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::CreatePage PageMapper[i].id=%d, cardId=%d, StreamId=%d", PageMapper[i].id, cardId, StreamId); + printf("MainViewSample::CreatePage PageMapper[i].id=%d, cardId=%d, StreamId=%d\n", PageMapper[i].id, cardId, StreamId); if (PageMapper[i].id == cardId) { + printf("--%d--\n",PageMapper[i].id); view = (this->*(PageMapper[i].func))(); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CreatePage view:%p", view); return view; } } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreatePage view error!"); return nullptr; } void MainViewSample::AnimatorStart(int pageIndex) { + printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__); if (heartRateView != nullptr && pageIndex == ScreenModels::GetInstance()->GetCardPage(HEART_RATE)) { heartRateView->HeartbeatImageAnimatorStart(); } if ((mainClockView != nullptr && pageIndex == ScreenModels::GetInstance()->GetCardPage(WATCH_FACE)) && mainSwipeGroup->GetCurrentPageId(UISwipeView::VERTICAL) == 1) { + printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__); mainClockView->ClockAnimatorStart(); } - if (dialView != nullptr && pageIndex == ScreenModels::GetInstance()->GetCardPage(NEW_DAIL)) { - dialView->PreLoad(); - } + // if (dialView != nullptr && pageIndex == ScreenModels::GetInstance()->GetCardPage(NEW_DAIL)) { + // printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__); + // dialView->PreLoad(); + // } } void MainViewSample::AnimatorStop(void) @@ -358,6 +368,7 @@ void MainViewSample::AnimatorStop(void) bool MainViewSample::IsMainView(void) { + printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__); if (mainSwipeGroup->GetCurrentPageId(0) == ScreenModels::GetInstance()->GetCardPage(WATCH_FACE) && mainSwipeGroup->GetCurrentPageId(1) == 1) { // 0: horizontal; 1: vertical return true; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/screensetting/src/ScreenModels.cpp b/code/sdk/application/wearable/nativeapp/nativeui/screensetting/src/ScreenModels.cpp index eb7185bf1..0b0bbb306 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/screensetting/src/ScreenModels.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/screensetting/src/ScreenModels.cpp @@ -45,6 +45,7 @@ bool ScreenModels::SetUpListCase(void) bool ScreenModels::InitCardConfig(void) { + printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__); if (SetUpListCase() == false) { return false; } @@ -54,6 +55,7 @@ bool ScreenModels::InitCardConfig(void) WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "InitCardConfig2"); struct CardInfo cardInfoData; if (fd < 0) { + printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "InitCardConfig open fail"); fd = open(CARD_CONFIG_PATH, O_RDWR | O_CREAT, S_IRWXU); if (fd < 0) { @@ -79,6 +81,7 @@ bool ScreenModels::InitCardConfig(void) WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Init Read GlobalHealthToFile fail"); } listMainView->PushBack(cardInfoData); + printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__); } close(fd); return true; @@ -88,6 +91,7 @@ bool ScreenModels::InitCardConfig(void) bool ScreenModels::SaveCardConfig(void) { + printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__); int32_t fd = open(CARD_CONFIG_PATH, O_RDWR | O_CREAT, S_IRWXU); if (fd < 0) { close(fd); @@ -103,17 +107,20 @@ bool ScreenModels::SaveCardConfig(void) void ScreenModels::SetCardConfigDefault(void) { + printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__); int16_t i; struct CardInfo cardInfoData; WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardConfigDefault"); for (i = 0; i < MAX_CARD; i++) { cardInfoData.cardId = i; + printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__); listMainView->PushBack(cardInfoData); } } int16_t ScreenModels::GetCardPage(uint16_t page) { + printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__); ListNode *node = listMainView->Begin(); for (uint8_t i = 0; i < page; i++) { if (node->next_ != NULL) {