From: Caisking <3449750381@qq.com> Date: Wed, 10 Jan 2024 02:11:49 +0000 (+0800) Subject: 添加Homepage X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=219ad088e86bff332f6d1f564ad16e282cf0dbfd;p=mirrors%2FFD230.git 添加Homepage --- diff --git a/code/sdk/application/wearable/nativeapp/CMakeLists.txt b/code/sdk/application/wearable/nativeapp/CMakeLists.txt index 677cb5e81..4f1e9c341 100755 --- a/code/sdk/application/wearable/nativeapp/CMakeLists.txt +++ b/code/sdk/application/wearable/nativeapp/CMakeLists.txt @@ -244,7 +244,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/dial/src/DialView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/dial/src/DialPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/dial/src/Digital_clockView.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/dial/src/Digital_clockPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/heartrate/src/HeartRemindView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/heartrate/src/HeartRemindPresenter.cpp diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h index 9d1fade17..af941251f 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h @@ -55,7 +55,7 @@ public: void InitBloodErrorSlice(void); void InitBloodNoteSlice(void); void InitDialSlice(void); - void InitDigitalSlice(void); + void InitHeartRemindSlice(void); void InitPhoneSlice(void); void InitPhoneCallSlice(void); diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp index 626b5075d..629e195fc 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp @@ -99,8 +99,7 @@ #include "blood/include/BloodNotePresenter.h" #include "dial/include/DialPresenter.h" #include "dial/include/DialView.h" -#include "dial/include/Digital_clockPresenter.h" -#include "dial/include/Digital_clockView.h" + #include "heartrate/include/HeartRemindPresenter.h" #include "heartrate/include/HeartRemindView.h" #include "traing/include/TraingPresenter.h" @@ -292,7 +291,7 @@ static const AppViewMapper SLICE_MAPPER[] = { {VIEW_BLOODERROR, &NativeLauncher::InitBloodErrorSlice}, {VIEW_BLOODNOTE, &NativeLauncher::InitBloodNoteSlice}, {VIEW_DIAL, &NativeLauncher::InitDialSlice}, //表盘 - {VIEW_DIGITAL,&NativeLauncher::InitDigitalSlice}, + {VIEW_HEARTRATEREMIND, &NativeLauncher::InitHeartRemindSlice}, {VIEW_TRAINING, &NativeLauncher::InitTraingSlice}, //训练 @@ -891,17 +890,7 @@ void NativeLauncher::InitDialSlice(void) } NativeAbility::GetInstance().AddSliceProxy(VIEW_DIAL, dialview); } -void NativeLauncher::InitDigitalSlice(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitBloodSlice"); - SliceProxy *digital_clockview = new AbilitySliceProxy; - if (digital_clockview == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "digital_clockview"); - return; - } - NativeAbility::GetInstance().AddSliceProxy(VIEW_DIGITAL, digital_clockview); -} + void NativeLauncher::InitHeartRemindSlice(void) { diff --git a/code/sdk/application/wearable/nativeapp/nativeui/clock/src/MainClockView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/clock/src/MainClockView.cpp index 73632dba5..c93c7eeb8 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/clock/src/MainClockView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/clock/src/MainClockView.cpp @@ -13,103 +13,106 @@ #include "common/image_cache_manager.h" #include -namespace OHOS { -static MainClockView *g_pMainClockView = nullptr; - -static constexpr uint16_t FONT_DEFAULT_SIZE = 25; -static constexpr uint16_t FONT_TEXT_SIZE = 24; -static constexpr uint16_t STEP_LABEL_X = 100; -static constexpr uint16_t STEP_LABEL_Y = 230; -static constexpr uint16_t BATTERYP_LABEL_X = 315; -static constexpr uint16_t BATTERYP_LABEL_Y = 230; -static constexpr uint16_t TEXT_WIDTH = 60; -static constexpr uint16_t TEXT_HEIGHT = 35; -static constexpr uint16_t POINT_POSITION_X = 202; -static constexpr uint16_t POINT_POSITION_Y = 16; -static constexpr uint16_t SECOND_POINT_POSITION_Y = 16; -static constexpr uint16_t POINT_CENTER_X = 25; -static constexpr uint16_t POINT_CENTER_Y = 211; -static constexpr uint16_t STEP_CHAR_NUM = 255; -static constexpr int16_t STEP_LABLE_WIDTH = 75; -static constexpr int16_t STEP_LABLE_SIZE = 35; -static constexpr uint16_t WEEKLABEL_POSITION_X = 247; -static constexpr uint16_t WEEKLABEL_POSITION_Y = 122; -static constexpr uint16_t HEARTRATELABEL_POSITION_X = 198; -static constexpr uint16_t HEARTRATELABEL_POSITION_Y = 330; -static constexpr uint16_t HEARTRATE_POSITION_X = 156; -static constexpr uint16_t HEARTRATE_POSITION_Y = 260; -static constexpr uint16_t PROGRESS_POSITION_X = 53; -static constexpr uint16_t PROGRESS_POSITION_Y = 54; -static constexpr uint16_t BIGCIRCLE_POSITION_X = 202; -static constexpr uint16_t BIGCIRCLE_POSITION_Y = 202; -static constexpr uint16_t MEDCIRCLE_POSITION_X = 202; -static constexpr uint16_t MEDCIRCLE_POSITION_Y = 202; -static constexpr uint16_t SMALLCIRCLE_POSITION_X = 202; -static constexpr uint16_t SMALLCIRCLE_POSITION_Y = 202; -static constexpr uint16_t WEEKDAY_POSITION_X = 193; -static constexpr uint16_t WEEKDAY_POSITION_Y = 127; - -MainClockView::MainClockView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainClockView::MainClockView"); - SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - g_pMainClockView = this; -} - -MainClockView::~MainClockView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainClockView::~MainClockView"); - if (clockAnimator != nullptr) { - clockAnimator->Stop(); - delete clockAnimator; - clockAnimator = nullptr; - } - mainSweepClock->RemoveAll(); - delete curFace; - curFace = nullptr; - delete stepLabel; - stepLabel = nullptr; - delete batteryLabel; - batteryLabel = nullptr; - delete callBack; - callBack = nullptr; - delete secondHand; - secondHand = nullptr; - delete minuteHand; - minuteHand = nullptr; - delete hourHand; - hourHand = nullptr; - delete weekLabel; - weekLabel = nullptr; - delete heartRateLabel; - heartRateLabel = nullptr; - delete heartRate; - heartRate = nullptr; - delete hand24Hour; - hand24Hour = nullptr; - delete weekDay; - weekDay = nullptr; - delete progress; - progress = nullptr; - delete bigCircle; - bigCircle = nullptr; - delete medCircle; - medCircle = nullptr; - delete smallCircle; - smallCircle = nullptr; - Remove(mainSweepClock); - delete mainSweepClock; - mainSweepClock = nullptr; - g_pMainClockView = nullptr; -} - -MainClockView *MainClockView::GetInstance(void) -{ - return g_pMainClockView; -} - -void MainClockView::InitStepValue() +namespace OHOS { + static MainClockView *g_pMainClockView = nullptr; + + static constexpr uint16_t FONT_DEFAULT_SIZE = 25; + static constexpr uint16_t FONT_TEXT_SIZE = 24; + static constexpr uint16_t STEP_LABEL_X = 100; + static constexpr uint16_t STEP_LABEL_Y = 230; + static constexpr uint16_t BATTERYP_LABEL_X = 315; + static constexpr uint16_t BATTERYP_LABEL_Y = 230; + static constexpr uint16_t TEXT_WIDTH = 60; + static constexpr uint16_t TEXT_HEIGHT = 35; + static constexpr uint16_t POINT_POSITION_X = 202; + static constexpr uint16_t POINT_POSITION_Y = 16; + static constexpr uint16_t SECOND_POINT_POSITION_Y = 16; + static constexpr uint16_t POINT_CENTER_X = 25; + static constexpr uint16_t POINT_CENTER_Y = 211; + static constexpr uint16_t STEP_CHAR_NUM = 255; + static constexpr int16_t STEP_LABLE_WIDTH = 75; + static constexpr int16_t STEP_LABLE_SIZE = 35; + static constexpr uint16_t WEEKLABEL_POSITION_X = 247; + static constexpr uint16_t WEEKLABEL_POSITION_Y = 122; + static constexpr uint16_t HEARTRATELABEL_POSITION_X = 198; + static constexpr uint16_t HEARTRATELABEL_POSITION_Y = 330; + static constexpr uint16_t HEARTRATE_POSITION_X = 156; + static constexpr uint16_t HEARTRATE_POSITION_Y = 260; + static constexpr uint16_t PROGRESS_POSITION_X = 53; + static constexpr uint16_t PROGRESS_POSITION_Y = 54; + static constexpr uint16_t BIGCIRCLE_POSITION_X = 202; + static constexpr uint16_t BIGCIRCLE_POSITION_Y = 202; + static constexpr uint16_t MEDCIRCLE_POSITION_X = 202; + static constexpr uint16_t MEDCIRCLE_POSITION_Y = 202; + static constexpr uint16_t SMALLCIRCLE_POSITION_X = 202; + static constexpr uint16_t SMALLCIRCLE_POSITION_Y = 202; + static constexpr uint16_t WEEKDAY_POSITION_X = 193; + static constexpr uint16_t WEEKDAY_POSITION_Y = 127; + + MainClockView::MainClockView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainClockView::MainClockView"); + SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + g_pMainClockView = this; + } + + MainClockView::~MainClockView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainClockView::~MainClockView"); + if (clockAnimator != nullptr) + { + clockAnimator->Stop(); + delete clockAnimator; + clockAnimator = nullptr; + } + mainSweepClock->RemoveAll(); + delete curFace; + curFace = nullptr; + delete stepLabel; + stepLabel = nullptr; + delete batteryLabel; + batteryLabel = nullptr; + delete callBack; + callBack = nullptr; + delete secondHand; + secondHand = nullptr; + delete minuteHand; + minuteHand = nullptr; + delete hourHand; + hourHand = nullptr; + delete weekLabel; + weekLabel = nullptr; + delete heartRateLabel; + heartRateLabel = nullptr; + delete heartRate; + heartRate = nullptr; + delete hand24Hour; + hand24Hour = nullptr; + delete weekDay; + weekDay = nullptr; + delete progress; + progress = nullptr; + delete bigCircle; + bigCircle = nullptr; + delete medCircle; + medCircle = nullptr; + delete smallCircle; + smallCircle = nullptr; + Remove(mainSweepClock); + delete mainSweepClock; + mainSweepClock = nullptr; + g_pMainClockView = nullptr; + } + + MainClockView *MainClockView::GetInstance(void) + { + return g_pMainClockView; + } + + void MainClockView::InitStepValue() + { +#if 0 WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainClockView::InitStepValue"); uint32_t stepValue; int weekToday = ActivityModel::GetInstance()->GetWeekToday(); @@ -127,356 +130,387 @@ void MainClockView::InitStepValue() stepLabel->SetStyleForState(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT, UIButton::RELEASED); stepLabel->SetStyleForState(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT, UIButton::PRESSED); stepLabel->SetStyleForState(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT, UIButton::INACTIVE); -} - -bool MainClockView::InitLabelView(void) -{ - //UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::MainPresenterSample::GetInstance(); - // 创建长按事件监听器对象 - //UIView::OnLongPressListener* longPressListener = (UIView::OnLongPressListener*)OHOS::MainPresenterSample::GetInstance(); - - - stepLabel = new UILabelButton(); - if (stepLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "stepLabel new fail"); - return false; - } - stepLabel->SetPosition(STEP_LABEL_X, STEP_LABEL_Y); - stepLabel->Resize(STEP_LABLE_WIDTH, STEP_LABLE_SIZE); - stepLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE); - stepLabel->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - stepLabel->SetViewId(MAIN_CLICK_ACTIVITY); - stepLabel->SetTouchable(true); - //stepLabel->SetOnClickListener(clickListener); - //stepLabel->SetOnLongPressListener(longPressListener); - InitStepValue(); - - batteryLabel = new UILabel(); - if (batteryLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "batteryLabel new fail"); - return false; - } - batteryLabel->SetPosition(BATTERYP_LABEL_X, BATTERYP_LABEL_Y, TEXT_WIDTH, TEXT_HEIGHT); - batteryLabel->SetText("90%"); - batteryLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - batteryLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE); - batteryLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - - heartRateLabel = new UILabel(); - if (heartRateLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "heartRateLabel new fail"); - return false; - } - heartRateLabel->SetPosition(HEARTRATELABEL_POSITION_X, HEARTRATELABEL_POSITION_Y, TEXT_WIDTH, TEXT_HEIGHT); - heartRateLabel->SetText("--"); - heartRateLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - heartRateLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE); - heartRateLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - - weekLabel = new UILabel(); - if (weekLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "weekLabel new fail"); - return false; - } - weekLabel->SetPosition(WEEKLABEL_POSITION_X, WEEKLABEL_POSITION_Y, TEXT_WIDTH, TEXT_HEIGHT); - weekLabel->SetText("2"); - weekLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_TEXT_SIZE); - weekLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - return true; -} - -bool MainClockView::InitCenterCircleView(void) -{ - bigCircle = new Image(); - if (bigCircle == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bigCircle new fail"); - return false; - } - if (LoadClockImage(bigCircle, CLOCK_BIGCIRCLE_IMAGE_PATH) == false) { - return false; - } - - medCircle = new Image(); - if (medCircle == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "medCircle new fail"); - return false; - } - if (LoadClockImage(medCircle, CLOCK_MEDCIRCLE_IMAGE_PATH) == false) { - return false; - } - - smallCircle = new Image(); - if (smallCircle == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "smallCircle new fail"); - return false; - } - if (LoadClockImage(smallCircle, CLOCK_CIRCLE_IMAGE_PATH) == false) { - return false; - } - return true; -} - -bool MainClockView::InitHandView(void) -{ - secondHand = new Image(); - if (secondHand == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "secondHand new fail"); - return false; - } - if (LoadClockImage(secondHand, CLOCK_SECONDHAND) == false) { - return false; - } - - minuteHand = new Image(); - if (minuteHand == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "minuteHand new fail"); - return false; - } - if (LoadClockImage(minuteHand, CLOCK_MINUTEHAND) == false) { - return false; - } - hourHand = new Image(); - if (hourHand == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "hourHand new fail"); - return false; - } - if (LoadClockImage(hourHand, CLOCK_HOURHAND) == false) { - return false; - } - - hand24Hour = new Image(); - if (hand24Hour == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "hand24Hour new fail"); - return false; - } - if (LoadClockImage(hand24Hour, CLOCK_HAND24HOUR_IMAGE_PATH) == false) { - return false; - } - return true; -} - -bool MainClockView::LoadClockImage(Image *view, uint32_t resId) -{ - std::string file = CLOCK_IAMGES; - ImageInfo* image = ImageCacheManager::GetInstance().LoadOneInMultiRes(resId, file); - if (image == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LoadClockImage %x fail", resId); - return false; - } - view->SetSrc(image); - return true; -} - -bool MainClockView::LoadClockImage(UIImageView *view, uint32_t resId) -{ - std::string file = CLOCK_IAMGES; - ImageInfo* image = ImageCacheManager::GetInstance().LoadOneInMultiRes(resId, file); - if (image == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LoadClockImage %x fail", resId); - return false; +#endif + } + + bool MainClockView::InitLabelView(void) + { + // UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::MainPresenterSample::GetInstance(); + // 创建长按事件监听器对象 + // UIView::OnLongPressListener* longPressListener = (UIView::OnLongPressListener*)OHOS::MainPresenterSample::GetInstance(); + + stepLabel = new UILabelButton(); + if (stepLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "stepLabel new fail"); + return false; + } + stepLabel->SetPosition(STEP_LABEL_X, STEP_LABEL_Y); + stepLabel->Resize(STEP_LABLE_WIDTH, STEP_LABLE_SIZE); + stepLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE); + stepLabel->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); + stepLabel->SetViewId(MAIN_CLICK_ACTIVITY); + stepLabel->SetTouchable(true); + // stepLabel->SetOnClickListener(clickListener); + // stepLabel->SetOnLongPressListener(longPressListener); + InitStepValue(); + + batteryLabel = new UILabel(); + if (batteryLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "batteryLabel new fail"); + return false; + } + batteryLabel->SetPosition(BATTERYP_LABEL_X, BATTERYP_LABEL_Y, TEXT_WIDTH, TEXT_HEIGHT); + batteryLabel->SetText("90%"); + batteryLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + batteryLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE); + batteryLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); + + heartRateLabel = new UILabel(); + if (heartRateLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "heartRateLabel new fail"); + return false; + } + heartRateLabel->SetPosition(HEARTRATELABEL_POSITION_X, HEARTRATELABEL_POSITION_Y, TEXT_WIDTH, TEXT_HEIGHT); + heartRateLabel->SetText("--"); + heartRateLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + heartRateLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE); + heartRateLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); + + weekLabel = new UILabel(); + if (weekLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "weekLabel new fail"); + return false; + } + weekLabel->SetPosition(WEEKLABEL_POSITION_X, WEEKLABEL_POSITION_Y, TEXT_WIDTH, TEXT_HEIGHT); + weekLabel->SetText("2"); + weekLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_TEXT_SIZE); + weekLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); + return true; + } + + bool MainClockView::InitCenterCircleView(void) + { +#if 0 + bigCircle = new Image(); + if (bigCircle == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bigCircle new fail"); + return false; + } + if (LoadClockImage(bigCircle, CLOCK_BIGCIRCLE_IMAGE_PATH) == false) + { + return false; + } + + medCircle = new Image(); + if (medCircle == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "medCircle new fail"); + return false; + } + if (LoadClockImage(medCircle, CLOCK_MEDCIRCLE_IMAGE_PATH) == false) + { + return false; + } + + smallCircle = new Image(); + if (smallCircle == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "smallCircle new fail"); + return false; + } + if (LoadClockImage(smallCircle, CLOCK_CIRCLE_IMAGE_PATH) == false) + { + return false; + } +#endif + return true; + } + + bool MainClockView::InitHandView(void) + { +#if 1 + secondHand = new Image(); + if (secondHand == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "secondHand new fail"); + return false; + } + if (LoadClockImage(secondHand, CLOCK_SECONDHAND) == false) + { + return false; + } + + minuteHand = new Image(); + if (minuteHand == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "minuteHand new fail"); + return false; + } + if (LoadClockImage(minuteHand, CLOCK_MINUTEHAND) == false) + { + return false; + } + hourHand = new Image(); + if (hourHand == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "hourHand new fail"); + return false; + } + if (LoadClockImage(hourHand, CLOCK_HOURHAND) == false) + { + return false; + } + + hand24Hour = new Image(); + if (hand24Hour == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "hand24Hour new fail"); + return false; + } + if (LoadClockImage(hand24Hour, CLOCK_HAND24HOUR_IMAGE_PATH) == false) + { + return false; + } +#endif + return true; + } + + bool MainClockView::LoadClockImage(Image *view, uint32_t resId) + { + std::string file = CLOCK_IAMGES; + ImageInfo *image = ImageCacheManager::GetInstance().LoadOneInMultiRes(resId, file); + if (image == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LoadClockImage %x fail", resId); + return false; + } + view->SetSrc(image); + return true; + } + + bool MainClockView::LoadClockImage(UIImageView *view, uint32_t resId) + { + std::string file = CLOCK_IAMGES; + ImageInfo *image = ImageCacheManager::GetInstance().LoadOneInMultiRes(resId, file); + if (image == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LoadClockImage %x fail", resId); + return false; + } + view->SetSrc(image); + return true; + } + + bool MainClockView::InitSweepClock(void) + { + curFace = new UIImageView(); + if (curFace == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "curFace new fail"); + return false; + } + curFace->SetPosition(0, 0); + + + if (LoadClockImage(curFace, CLOCK_MAIN_FACE_IMAGE) == false) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "curFace LoadClockImage CLOCK_MAIN_FACE_IMAGE fail"); + return false; + } + +#if 0 + if (InitLabelView() == false) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelView() fail"); + return false; + } + if (InitCenterCircleView() == false) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitCenterCircleView() fail"); + return false; + } + heartRate = new UIImageView(); + if (heartRate == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "heartRate new fail"); + return false; + } + heartRate->SetPosition(HEARTRATE_POSITION_X, HEARTRATE_POSITION_Y); + if (LoadClockImage(heartRate, CLOCK_HEARTRATE_IMAGE_PATH) == false) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "heartRate LoadClockImage CLOCK_HEARTRATE_IMAGE_PATH fail"); + return false; + } + + progress = new UIImageView(); + if (progress == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "progress new fail"); + return false; + } + progress->SetPosition(PROGRESS_POSITION_X, PROGRESS_POSITION_Y); + if (LoadClockImage(progress, CLOCK_PROGRESS_IMAGE_PATH) == false) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "progress LoadClockImage CLOCK_PROGRESS_IMAGE_PATH fail"); + return false; + } + weekDay = new UIImageView(); + if (weekDay == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "weekDay new fail"); + return false; + } + weekDay->SetPosition(WEEKDAY_POSITION_X, WEEKDAY_POSITION_Y); + if (LoadClockImage(weekDay, CLOCK_THURSDAY_IMAGE_PATH) == false) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "weekDay LoadClockImage CLOCK_THURSDAY_IMAGE_PATH fail"); + return false; + } +#endif + InitHandView(); + return true; + } + + void MainClockView::PreLoad(void) + { + if (!viewiInitStatus) + { + InitView(); + viewiInitStatus = true; + } + } + + void MainClockView::UnLoad(void) + { + // Main clock view is commonly used page, so we do not release it's resources inner slice. + } + + bool MainClockView::InitView(void) + { + + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainClockView::InitView"); + mainSweepClock = new UISweepClock(); + if (mainSweepClock == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainSweepClock new fail"); + return false; + } + + + // UIView::OnLongPressListener* longPressListener = (UIView::OnLongPressListener*)OHOS::MainPresenterSample::GetInstance(); + // mainSweepClock->SetOnLongPressListener(longPressListener); + + if (InitSweepClock() == false) + { + return false; + } + + mainSweepClock->Add(button1_); + mainSweepClock->Add(curFace); + /* + mainSweepClock->Add(stepLabel); + mainSweepClock->Add(heartRate); + mainSweepClock->Add(weekLabel); + mainSweepClock->Add(heartRateLabel); + mainSweepClock->Add(weekDay); + mainSweepClock->Add(progress); + mainSweepClock->Add(batteryLabel); + */ + + Add(mainSweepClock); + + mainSweepClock->SetDragParentInstead(true); + // mainSweepClock->SetOnLongPressListener(longPressListener); + mainSweepClock->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + + // {214, 3}: position x, y {14, 223}: center x, y + mainSweepClock->SetHandImage(UISweepClock::HandType::SECOND_HAND, *secondHand, + {POINT_POSITION_X, SECOND_POINT_POSITION_Y}, {POINT_CENTER_X, POINT_CENTER_Y}); + mainSweepClock->SetHandImage(UISweepClock::HandType::MINUTE_HAND, *minuteHand, + {POINT_POSITION_X, POINT_POSITION_Y}, {POINT_CENTER_X, POINT_CENTER_Y}); + mainSweepClock->SetHandImage(UISweepClock::HandType::HOUR_HAND, *hourHand, {POINT_POSITION_X, POINT_POSITION_Y}, + {POINT_CENTER_X, POINT_CENTER_Y}); + mainSweepClock->SetHandCircleImage(UISweepClock::HandType::SECOND_HAND, *smallCircle, + {SMALLCIRCLE_POSITION_X, SMALLCIRCLE_POSITION_Y}); + mainSweepClock->SetHandCircleImage(UISweepClock::HandType::MINUTE_HAND, *medCircle, + {MEDCIRCLE_POSITION_X, MEDCIRCLE_POSITION_Y}); + mainSweepClock->SetHandCircleImage(UISweepClock::HandType::HOUR_HAND, *bigCircle, + {BIGCIRCLE_POSITION_X, BIGCIRCLE_POSITION_Y}); + + mainSweepClock->SetInitTime24Hour(0, 0, 0); + mainSweepClock->SetWorkMode(UISweepClock::WorkMode::NORMAL); + InitDateTime(); + + callBack = new ClockAnimatorCallback(mainSweepClock); + if (callBack == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "callBack new fail"); + return false; + } + clockAnimator = new Animator(callBack, mainSweepClock, 0, true); + if (clockAnimator == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clockAnimator new fail"); + return false; + } + clockAnimator->Start(); + SetCoverable(true); + return true; } - view->SetSrc(image); - return true; -} -bool MainClockView::InitSweepClock(void) -{ - curFace = new UIImageView(); - if (curFace == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "curFace new fail"); - return false; - } - curFace->SetPosition(0, 0); + void MainClockView::RefreshStep(int step) + { +#if 0 + char stepChar[STEP_CHAR_NUM] = {0}; - if (LoadClockImage(curFace, CLOCK_MAIN_FACE_IMAGE) == false) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "curFace LoadClockImage CLOCK_MAIN_FACE_IMAGE fail"); - return false; + (void)sprintf_s(stepChar, STEP_CHAR_NUM, "%d", step); + stepLabel->SetText(stepChar); +#endif } - if (InitLabelView() == false) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelView() fail"); - return false; - } - if (InitCenterCircleView() == false) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitCenterCircleView() fail"); - return false; - } - heartRate = new UIImageView(); - if (heartRate == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "heartRate new fail"); - return false; - } - heartRate->SetPosition(HEARTRATE_POSITION_X, HEARTRATE_POSITION_Y); - if (LoadClockImage(heartRate, CLOCK_HEARTRATE_IMAGE_PATH) == false) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "heartRate LoadClockImage CLOCK_HEARTRATE_IMAGE_PATH fail"); - return false; - } + void MainClockView::RefreshHeartRate(int value) + { +#if 0 + if (value == 0) + { + heartRateLabel->SetText("--"); + return; + } + char heartRateChar[STEP_CHAR_NUM] = {0}; - progress = new UIImageView(); - if (progress == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "progress new fail"); - return false; - } - progress->SetPosition(PROGRESS_POSITION_X, PROGRESS_POSITION_Y); - if (LoadClockImage(progress, CLOCK_PROGRESS_IMAGE_PATH) == false) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "progress LoadClockImage CLOCK_PROGRESS_IMAGE_PATH fail"); - return false; + (void)sprintf_s(heartRateChar, STEP_CHAR_NUM, "%d", value); + heartRateLabel->SetText(heartRateChar); +#endif } - InitHandView(); - weekDay = new UIImageView(); - if (weekDay == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "weekDay new fail"); - return false; - } - weekDay->SetPosition(WEEKDAY_POSITION_X, WEEKDAY_POSITION_Y); - if (LoadClockImage(weekDay, CLOCK_THURSDAY_IMAGE_PATH) == false) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "weekDay LoadClockImage CLOCK_THURSDAY_IMAGE_PATH fail"); - return false; + void MainClockView::InitDateTime(void) + { + struct tm pTM; + time_t seconds; + time(&seconds); + localtime_r(&seconds, &pTM); + mainSweepClock->SetTime24Hour(pTM.tm_hour, pTM.tm_min, pTM.tm_sec); } - return true; -} -void MainClockView::PreLoad(void) -{ - if (!viewiInitStatus) { - InitView(); - viewiInitStatus = true; - } -} - -void MainClockView::UnLoad(void) -{ - // Main clock view is commonly used page, so we do not release it's resources inner slice. -} - -bool MainClockView::InitView(void) -{ - - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainClockView::InitView"); - mainSweepClock = new UISweepClock(); - if (mainSweepClock == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainSweepClock new fail"); - return false; - } - - // Add Button to App - if (button1_ == nullptr) { - button1_ = new UIButton(); - } - button1_->SetPosition(0, 0); // widget's left position and top position - button1_->Resize(466, 466); // widget's width and height - button1_->SetViewId("button1");// Set style - button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); - button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); - - // Set additional property - button1_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); - button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - - // Add the CallBack about events - UIView::OnLongPressListener* button3LongPress = static_cast(MainPresenterSample::GetInstance()); - button1_->SetOnLongPressListener(button3LongPress); - // Add to rootView - //container_->Add(button1_); - button1_->SetVisible(true); - - //UIView::OnLongPressListener* longPressListener = (UIView::OnLongPressListener*)OHOS::MainPresenterSample::GetInstance(); - //mainSweepClock->SetOnLongPressListener(longPressListener); - - if (InitSweepClock() == false) { - return false; + void MainClockView::ClockAnimatorStart(void) + { + if (clockAnimator != nullptr) + { + clockAnimator->Start(); + } } - mainSweepClock->Add(button1_); - mainSweepClock->Add(curFace); - mainSweepClock->Add(stepLabel); - mainSweepClock->Add(heartRate); - mainSweepClock->Add(weekLabel); - mainSweepClock->Add(heartRateLabel); - mainSweepClock->Add(weekDay); - mainSweepClock->Add(progress); - mainSweepClock->Add(batteryLabel); - Add(mainSweepClock); - - mainSweepClock->SetDragParentInstead(true); - //mainSweepClock->SetOnLongPressListener(longPressListener); - mainSweepClock->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - - // {214, 3}: position x, y {14, 223}: center x, y - mainSweepClock->SetHandImage(UISweepClock::HandType::SECOND_HAND, *secondHand, - { POINT_POSITION_X, SECOND_POINT_POSITION_Y }, { POINT_CENTER_X, POINT_CENTER_Y }); - mainSweepClock->SetHandImage(UISweepClock::HandType::MINUTE_HAND, *minuteHand, - { POINT_POSITION_X, POINT_POSITION_Y }, { POINT_CENTER_X, POINT_CENTER_Y }); - mainSweepClock->SetHandImage(UISweepClock::HandType::HOUR_HAND, *hourHand, { POINT_POSITION_X, POINT_POSITION_Y }, - { POINT_CENTER_X, POINT_CENTER_Y }); - mainSweepClock->SetHandCircleImage(UISweepClock::HandType::SECOND_HAND, *smallCircle, - { SMALLCIRCLE_POSITION_X, SMALLCIRCLE_POSITION_Y }); - mainSweepClock->SetHandCircleImage(UISweepClock::HandType::MINUTE_HAND, *medCircle, - { MEDCIRCLE_POSITION_X, MEDCIRCLE_POSITION_Y }); - mainSweepClock->SetHandCircleImage(UISweepClock::HandType::HOUR_HAND, *bigCircle, - { BIGCIRCLE_POSITION_X, BIGCIRCLE_POSITION_Y }); - - mainSweepClock->SetInitTime24Hour(0, 0, 0); - mainSweepClock->SetWorkMode(UISweepClock::WorkMode::NORMAL); - InitDateTime(); - - callBack = new ClockAnimatorCallback(mainSweepClock); - if (callBack == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "callBack new fail"); - return false; + void MainClockView::ClockAnimatorStop(void) + { + if (clockAnimator != nullptr) + { + clockAnimator->Stop(); + } } - clockAnimator = new Animator(callBack, mainSweepClock, 0, true); - if (clockAnimator == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clockAnimator new fail"); - return false; - } - clockAnimator->Start(); - SetCoverable(true); - return true; -} - -void MainClockView::RefreshStep(int step) -{ - char stepChar[STEP_CHAR_NUM] = {0}; - - (void)sprintf_s(stepChar, STEP_CHAR_NUM, "%d", step); - stepLabel->SetText(stepChar); -} - -void MainClockView::RefreshHeartRate(int value) -{ - if (value == 0) { - heartRateLabel->SetText("--"); - return; - } - char heartRateChar[STEP_CHAR_NUM] = {0}; - - (void)sprintf_s(heartRateChar, STEP_CHAR_NUM, "%d", value); - heartRateLabel->SetText(heartRateChar); -} - -void MainClockView::InitDateTime(void) -{ - struct tm pTM; - time_t seconds; - time(&seconds); - localtime_r(&seconds, &pTM); - mainSweepClock->SetTime24Hour(pTM.tm_hour, pTM.tm_min, pTM.tm_sec); -} - -void MainClockView::ClockAnimatorStart(void) -{ - if (clockAnimator != nullptr) { - clockAnimator->Start(); - } -} - -void MainClockView::ClockAnimatorStop(void) -{ - if (clockAnimator != nullptr) { - clockAnimator->Stop(); - } -} } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/dial/include/Digital_clockPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/dial/include/Digital_clockPresenter.h deleted file mode 100644 index 3b55bfccc..000000000 --- a/code/sdk/application/wearable/nativeapp/nativeui/dial/include/Digital_clockPresenter.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _Digital_clock_PRESENTER_H -#define _Digital_clock_PRESENTER_H - -#include "Presenter.h" -#include "Digital_clockView.h" - -namespace OHOS -{ - class Digital_clockView; - - class Digital_clockPresenter : public Presenter, - public UIView::OnClickListener, - public UIView::OnDragListener - { - public: - Digital_clockPresenter(); - virtual ~Digital_clockPresenter(); - - void OnStart() override; - void OnPause() override; - void OnResume() override; - void OnStop() override; - - static Digital_clockPresenter *GetInstance(); - - private: - // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; - bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView &view, const DragEvent &event) override; - }; -} // namespace OHOS - -#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file 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 c594dd0f6..06ab15cd2 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 @@ -25,7 +25,6 @@ #include #include #include "battery.h" -#include "Digital_clockPresenter.h" #include "cJSON.h" #include "sys/time.h" extern uint8_t battery_get_voltage(float *voltage); @@ -201,8 +200,8 @@ namespace OHOS return file.good(); } }; - class Digital_clockPresenter; - class Digital_clockView : public View + + class Digital_clockView : public UICardPage { public: @@ -210,11 +209,7 @@ namespace OHOS virtual ~Digital_clockView(); static Digital_clockView *GetInstance(void); - void OnStart() override; - void OnSetUpView() override; - void OnTearDownView() override; - void OnStop() override; - void InitView(); + bool InitView(); void DeInit(); void setJsonFilePath(const std::string &filePath); void updateClockTime(const std::string &stringtime); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/dial/src/Digital_clockPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/dial/src/Digital_clockPresenter.cpp deleted file mode 100644 index 2530854b4..000000000 --- a/code/sdk/application/wearable/nativeapp/nativeui/dial/src/Digital_clockPresenter.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#include "AppViewIDs.h" -#include "NativeAbility.h" - -#include -#include -#include -#include "components/ui_sweep_clock.h" -#include "dial/include/Digital_clockPresenter.h" -#include "dial/include/Digital_clockView.h" -// #include "Digital_clockView.h" - -namespace OHOS -{ - - // 当前Presenter属性实例化的内存指针 - static Digital_clockPresenter *g_pDigital_clockPresenter = nullptr; - - Digital_clockPresenter::Digital_clockPresenter() - { - - g_pDigital_clockPresenter = this; - } - - Digital_clockPresenter::~Digital_clockPresenter() - { - - g_pDigital_clockPresenter = nullptr; - } - - Digital_clockPresenter *Digital_clockPresenter::GetInstance() - { - - return g_pDigital_clockPresenter; - } - - void Digital_clockPresenter::OnStart() - { - Presenter::OnStart(); - } - - void Digital_clockPresenter::OnPause(void) - { - Presenter::OnPause(); - } - - void Digital_clockPresenter::OnResume(void) - { - Presenter::OnResume(); - } - - void Digital_clockPresenter::OnStop(void) - { - Presenter::OnStop(); - } - - bool Digital_clockPresenter::OnDrag(UIView &view, const DragEvent &event) - { - Digital_clockView *g_pDigital_clockView = new Digital_clockView; - if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && - (event.GetDeltaX() > 40) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) - { - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); - } - // g_pDigital_clockView->InitView(); - UNUSED(view); - return true; - } - - bool Digital_clockPresenter::OnClick(UIView &view, const ClickEvent &event) - { - // // 根据控件id查找是哪个控件触发了点击回调 - // if (strcmp(view.GetViewId(), BUTTONOK) == 0) - // { - // NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCONTROL); - // } - return true; - } -} 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 415f17c8c..f9e4e7fa5 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 @@ -48,6 +48,7 @@ namespace OHOS static Digital_clockView *g_pDigital_clockView{nullptr}; Digital_clockView::Digital_clockView() { + SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); g_pDigital_clockView = this; } @@ -472,13 +473,14 @@ namespace OHOS progress1animator_->Start(); }; /* InitView:初始化界面*/ - void Digital_clockView ::InitView() + bool Digital_clockView ::InitView() { if (container_ == nullptr) { container_ = new UIViewGroup(); - container_->SetPosition(0, 0, 466, 466); - container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); } if (loadJsonData(JosnfilePath)) { @@ -493,15 +495,14 @@ namespace OHOS { Initdigit(); } - PRINT_DEBUG_INFO - Initdata(); - PRINT_DEBUG_INFO - Initweek(); - PRINT_DEBUG_INFO + + Initdata(); + Initweek(); Initbattery(); - PRINT_DEBUG_INFO cJSON_Delete(cjson_json); } + SetCoverable(true); + return true; } /* DeInit:删除组件*/ void Digital_clockView::DeInit() @@ -580,58 +581,10 @@ namespace OHOS void Digital_clockView::PreLoad(void) { - - if (!viewiInitStatus) + if (InitView()) { - InitView(); viewiInitStatus = true; } } - void Digital_clockView::OnStart() - { - PRINT_DEBUG_INFO - container_ = new UIViewGroup(); - if (container_ == nullptr) - { - return; - } - container_->SetPosition(0, 0); - container_->SetWidth(Screen::GetInstance().GetWidth()); - container_->SetHeight(Screen::GetInstance().GetHeight()); - // 创建 draglistener 实例并设置为拖动监听器 - UIView::OnDragListener *draglistener = static_cast(Digital_clockPresenter::GetInstance()); - - if (draglistener == nullptr) - { - return; - } - container_->SetOnDragListener(draglistener); - container_->SetTouchable(true); - container_->SetDraggable(true); - BaseView::RootView(Color::Black().full); - PreLoad(); - RootView::GetInstance()->Add(container_); - } - - void Digital_clockView::OnSetUpView() - { - - View::OnSetUpView(); - Draw(); - } - void Digital_clockView::OnTearDownView() - { - - View::OnTearDownView(); - return; - } - - void Digital_clockView::OnStop() - { - View::OnStop(); - RootView::GetInstance()->RemoveAll(); - // RootView::GetInstance()->Invalidate(); - return; - } } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h index cff99d5b3..02862a95c 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h @@ -28,7 +28,7 @@ #include "components/ui_card_page.h" #include "PullUpDownView.h" #include "components/ui_cross_view.h" - +#include "dial/include/Digital_clockView.h" namespace OHOS { class MainPresenterSample; class MainViewSample : public View { @@ -45,6 +45,7 @@ public: UICardPage *InitActivityPage(void); UICardPage *InitCompassPage(void); UICardPage *InitMusicPlayerPage(void); + UICardPage *InitNewDialPage(void); void AnimatorStart(int pageIndex); void AnimatorStop(void); uint16_t GetHorCurrentPage() const @@ -60,8 +61,9 @@ public: bool IsMainView(void); void SetDragFg(bool continFg); bool GetDragFg(void); - + private: + int16_t maxPage{0}; bool continuDragFg{false}; PullUpDownView *dropDownView{nullptr}; @@ -72,6 +74,7 @@ private: PlayersView *playersView{nullptr}; CompassControlView *compassControlView{nullptr}; HeartRateView *heartRateView{nullptr}; + Digital_clockView*dialView{nullptr}; UICardPage *recordCard[MAX_CARD]{nullptr}; bool pageStatus[MAX_CARD]{false}; UICrossView *mainSwipeGroup{nullptr}; 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 8b243a059..f0164a656 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp @@ -29,6 +29,7 @@ static const MainViewMapper PageMapper[] = { {COMPASS, &MainViewSample::InitCompassPage}, {ACTIVITY, &MainViewSample::InitActivityPage}, {MUSIC_PLAYER, &MainViewSample::InitMusicPlayerPage}, + {NEW_DAIL,&MainViewSample::InitNewDialPage}, }; MainViewSample::MainViewSample() @@ -93,9 +94,16 @@ MainViewSample::~MainViewSample() compassControlView = nullptr; } + if (dialView != nullptr) { + delete dialView; + dialView = nullptr; + } + g_pMainView = nullptr; } + + MainViewSample *MainViewSample::GetInstance(void) { return g_pMainView; @@ -133,6 +141,7 @@ void MainViewSample::OnStart() mainSwipeGroup->EnableScreenCap(true); mainSwipeGroup->RegisterSwipeCallback(callback); mainSwipeGroup->SetHorCurrentPage(mainClockView->GetViewIndex()); + mainSwipeGroup->SetHorCurrentPage(dialView->GetViewIndex()); SetContainerView(mainSwipeGroup); } @@ -295,6 +304,16 @@ UICardPage *MainViewSample::InitMusicPlayerPage(void) return playersView; } +UICardPage *MainViewSample::InitNewDialPage(void) +{ + dialView = new Digital_clockView(); + if (dialView == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dialView new fail"); + return nullptr; + } + return dialView; +} + UICardPage *MainViewSample::CreatePage(int32_t StreamId) { uint16_t i; @@ -322,7 +341,9 @@ void MainViewSample::AnimatorStart(int pageIndex) mainSwipeGroup->GetCurrentPageId(UISwipeView::VERTICAL) == 1) { mainClockView->ClockAnimatorStart(); } - + if (dialView != nullptr && pageIndex == ScreenModels::GetInstance()->GetCardPage(NEW_DAIL)) { + dialView->PreLoad(); + } } void MainViewSample::AnimatorStop(void) diff --git a/code/sdk/application/wearable/nativeapp/nativeui/screensetting/include/ScreenModels.h b/code/sdk/application/wearable/nativeapp/nativeui/screensetting/include/ScreenModels.h index bf5d0c813..16dbd20ed 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/screensetting/include/ScreenModels.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/screensetting/include/ScreenModels.h @@ -17,7 +17,8 @@ typedef enum { HEART_RATE, COMPASS, ACTIVITY, - MUSIC_PLAYER , + MUSIC_PLAYER, + NEW_DAIL, MAX_CARD, } CardId;