From: Caisking <3449750381@qq.com> Date: Sun, 3 Mar 2024 08:03:00 +0000 (+0800) Subject: 1.增加血氧显示数据和血氧结果区分;2.增加血氧检测时间同步更新;3.增加主页面血氧数据和时间同步信息;4.增加applist的圆形滑动条同步; X-Git-Tag: release_V1.2.70_20241020_135402~1274^2~39 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=08848fb4350d51e1e3d5bf1c2237de7d3183585e;p=mirrors%2FFD230.git 1.增加血氧显示数据和血氧结果区分;2.增加血氧检测时间同步更新;3.增加主页面血氧数据和时间同步信息;4.增加applist的圆形滑动条同步; --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistView.cpp b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistView.cpp index e2954a8d5..695e06de5 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistView.cpp @@ -10,210 +10,230 @@ #include "ApplistPresenter.h" #include "AppItemView.h" -namespace OHOS { -static constexpr int16 NUM_2 = 2; -static constexpr int16 MAX_SCROLL_DIS = 1000; - -ApplistView::ApplistView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::ApplistView "); - UIViewGroup::SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); -} - -ApplistView::~ApplistView() +namespace OHOS { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::~ApplistView "); - delete listAdapter_; - listAdapter_ = nullptr; - delete contentList_; - contentList_ = nullptr; - delete dragListener; - dragListener = nullptr; -} + static constexpr int16 NUM_2 = 2; + static constexpr int16 MAX_SCROLL_DIS = 1000; -//初始化页面 -bool ApplistView::InitPage() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " ApplistView::InitPage"); - g_ApplistPresenter = new ApplistPresenter(); - g_ApplistPresenter->GetApplistModelPtr()->initApplist(); - //BaseView::RootView(Color::Black().full); - listAdapter_ = new ApplistAdapter(); - if (listAdapter_ == nullptr) { - return false; + ApplistView::ApplistView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::ApplistView "); + UIViewGroup::SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); } - listAdapter_->SetItemClickListener(g_ApplistPresenter); - contentList_ = new UIList(UIList::VERTICAL); - if (contentList_ == nullptr) { - return false; + ApplistView::~ApplistView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::~ApplistView "); + delete listAdapter_; + listAdapter_ = nullptr; + delete contentList_; + contentList_ = nullptr; + delete dragListener; + dragListener = nullptr; } - contentList_->SetPosition(0, 0); - contentList_->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - contentList_->SetScrollBlankSize(VERTICAL_RESOLUTION / NUM_2); - contentList_->SetSelectPosition(VERTICAL_RESOLUTION / NUM_2); // middle position - contentList_->SetDraggable(true); - contentList_->SetThrowDrag(true); - contentList_->EnableAutoAlign(true); - contentList_->SetScrollStateListener(this); - contentList_->SetMaxScrollDistance(MAX_SCROLL_DIS); - contentList_->SetVisible(true); - Add(contentList_); - dragListener = new AppListOnDragListener(); - if (dragListener == nullptr) { - return false; + + // 初始化页面 + bool ApplistView::InitPage() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " ApplistView::InitPage"); + g_ApplistPresenter = new ApplistPresenter(); + g_ApplistPresenter->GetApplistModelPtr()->initApplist(); + // BaseView::RootView(Color::Black().full); + listAdapter_ = new ApplistAdapter(); + if (listAdapter_ == nullptr) + { + return false; + } + listAdapter_->SetItemClickListener(g_ApplistPresenter); + + contentList_ = new UIList(UIList::VERTICAL); + if (contentList_ == nullptr) + { + return false; + } + contentList_->SetPosition(0, 0); + contentList_->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + contentList_->SetScrollBlankSize(VERTICAL_RESOLUTION / NUM_2); + contentList_->SetSelectPosition(VERTICAL_RESOLUTION / NUM_2); // middle position + contentList_->SetDraggable(true); + contentList_->SetThrowDrag(true); + contentList_->EnableAutoAlign(true); + contentList_->SetScrollStateListener(this); + contentList_->SetMaxScrollDistance(MAX_SCROLL_DIS); + contentList_->SetVisible(true); + Add(contentList_); + dragListener = new AppListOnDragListener(); + if (dragListener == nullptr) + { + return false; + } + contentList_->SetOnDragListener(dragListener); + + return true; } - contentList_->SetOnDragListener(dragListener); - - return true; -} -//设置页面视图 -bool ApplistView::SetupViewPage(ApplistView *applistView) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " ApplistView::SetupViewPage"); - const AppItem *itemInfo = g_ApplistPresenter->GetApplistModelPtr()->GetApplistItems(); - for (uint8 i = 0; i < g_ApplistPresenter->GetApplistModelPtr()->GetAppListNum(); i++) { + // 设置页面视图 + bool ApplistView::SetupViewPage(ApplistView *applistView) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " ApplistView::SetupViewPage"); + const AppItem *itemInfo = g_ApplistPresenter->GetApplistModelPtr()->GetApplistItems(); + for (uint8 i = 0; i < g_ApplistPresenter->GetApplistModelPtr()->GetAppListNum(); i++) + { applistView->AddAppItemToList(itemInfo[i]); - } - /* -------------------------------------------------------------------------- */ - if (contentList_ == nullptr || listAdapter_ == nullptr) { - return false; - } - uint16_t startIndex = 0; - int16_t headY = 0; - if (g_ApplistPresenter->GetStartIndex() >= g_ApplistPresenter->GetListItemNum()) { - startIndex = g_ApplistPresenter->GetListItemNum() - 1; - headY = VERTICAL_RESOLUTION / NUM_2; - } else { - startIndex = g_ApplistPresenter->GetStartIndex(); - headY = g_ApplistPresenter->GetHeadItemY(); - if (headY == 0) { + } + /* -------------------------------------------------------------------------- */ + if (contentList_ == nullptr || listAdapter_ == nullptr) + { + return false; + } + uint16_t startIndex = 0; + int16_t headY = 0; + if (g_ApplistPresenter->GetStartIndex() >= g_ApplistPresenter->GetListItemNum()) + { + startIndex = g_ApplistPresenter->GetListItemNum() - 1; headY = VERTICAL_RESOLUTION / NUM_2; } + else + { + startIndex = g_ApplistPresenter->GetStartIndex(); + headY = g_ApplistPresenter->GetHeadItemY(); + if (headY == 0) + { + headY = VERTICAL_RESOLUTION / NUM_2; + } + } + contentList_->SetStartIndex(startIndex); + contentList_->SetAdapter(listAdapter_); + contentList_->ScrollBy(headY); + return true; } - contentList_->SetStartIndex(startIndex); - contentList_->SetAdapter(listAdapter_); - contentList_->ScrollBy(headY); - return true; -} -void ApplistView::OnStart() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::OnStart "); - View::OnStart(); + void ApplistView::OnStart() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::OnStart "); + View::OnStart(); - BaseView::RootView(Color::Black().full); + BaseView::RootView(Color::Black().full); - listAdapter_ = new ApplistAdapter(); - if (listAdapter_ == nullptr) { - return; - } - listAdapter_->SetItemClickListener(presenter_); + listAdapter_ = new ApplistAdapter(); + if (listAdapter_ == nullptr) + { + return; + } + listAdapter_->SetItemClickListener(presenter_); - contentList_ = new UIList(UIList::VERTICAL); - if (contentList_ == nullptr) { - return; - } - contentList_->SetPosition(0, 0); - contentList_->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - contentList_->SetScrollBlankSize(VERTICAL_RESOLUTION / NUM_2); - contentList_->SetSelectPosition(VERTICAL_RESOLUTION / NUM_2); // middle position - contentList_->SetDraggable(true); - contentList_->SetThrowDrag(true); - contentList_->EnableAutoAlign(true); - contentList_->SetScrollStateListener(this); - contentList_->SetMaxScrollDistance(MAX_SCROLL_DIS); - //SetXScrollBarVisible(true); - SetContainerView(contentList_); - - dragListener = new AppListOnDragListener(); - if (dragListener == nullptr) { - return; + contentList_ = new UIList(UIList::VERTICAL); + if (contentList_ == nullptr) + { + return; + } + contentList_->SetPosition(0, 0); + contentList_->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + contentList_->SetScrollBlankSize(VERTICAL_RESOLUTION / NUM_2); + contentList_->SetSelectPosition(VERTICAL_RESOLUTION / NUM_2); // middle position + contentList_->SetDraggable(true); + contentList_->SetThrowDrag(true); + contentList_->EnableAutoAlign(true); + contentList_->SetScrollStateListener(this); + contentList_->SetMaxScrollDistance(MAX_SCROLL_DIS); + contentList_->SetYScrollBarVisible(true); // 启动列表滚动条 + SetContainerView(contentList_); + + dragListener = new AppListOnDragListener(); + if (dragListener == nullptr) + { + return; + } + contentList_->SetOnDragListener(dragListener); } - contentList_->SetOnDragListener(dragListener); -} -void ApplistView::OnSetUpView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::OnSetUpView"); - View::OnSetUpView(); + void ApplistView::OnSetUpView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::OnSetUpView"); + View::OnSetUpView(); - if (contentList_ == nullptr || listAdapter_ == nullptr) { - return; - } + if (contentList_ == nullptr || listAdapter_ == nullptr) + { + return; + } - uint16_t startIndex = 0; - int16_t headY = 0; - if (presenter_->GetStartIndex() >= presenter_->GetListItemNum()) { - startIndex = presenter_->GetListItemNum() - 1; - headY = VERTICAL_RESOLUTION / NUM_2; - } else { - startIndex = presenter_->GetStartIndex(); - headY = presenter_->GetHeadItemY(); - if (headY == 0) { + uint16_t startIndex = 0; + int16_t headY = 0; + if (presenter_->GetStartIndex() >= presenter_->GetListItemNum()) + { + startIndex = presenter_->GetListItemNum() - 1; headY = VERTICAL_RESOLUTION / NUM_2; } + else + { + startIndex = presenter_->GetStartIndex(); + headY = presenter_->GetHeadItemY(); + if (headY == 0) + { + headY = VERTICAL_RESOLUTION / NUM_2; + } + } + contentList_->SetStartIndex(startIndex); + contentList_->SetAdapter(listAdapter_); + contentList_->ScrollBy(headY); + Draw(); + return; } - contentList_->SetStartIndex(startIndex); - contentList_->SetAdapter(listAdapter_); - contentList_->ScrollBy(headY); - Draw(); - return; -} - -void ApplistView::OnTearDownView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::OnTearDownView"); - View::OnTearDownView(); - return; -} -void ApplistView::OnStop() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::OnStop"); - int16_t listHeadY = contentList_->GetChildrenHead()->GetY(); - int16_t listHeadIndex = contentList_->GetChildrenHead()->GetViewIndex(); + void ApplistView::OnTearDownView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::OnTearDownView"); + View::OnTearDownView(); + return; + } - presenter_->SetHeadItemY(listHeadY); - presenter_->SetStartIndex(listHeadIndex); + void ApplistView::OnStop() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::OnStop"); + int16_t listHeadY = contentList_->GetChildrenHead()->GetY(); + int16_t listHeadIndex = contentList_->GetChildrenHead()->GetViewIndex(); - View::OnStop(); - container_ = nullptr; + presenter_->SetHeadItemY(listHeadY); + presenter_->SetStartIndex(listHeadIndex); - RootView::GetInstance()->ClearOnKeyActListener(); - RootView::GetInstance()->RemoveAll(); - return; -} + View::OnStop(); + container_ = nullptr; -void ApplistView::AddAppItemToList(const AppItem &item) -{ - listAdapter_->AddListItem(item); -} + RootView::GetInstance()->ClearOnKeyActListener(); + RootView::GetInstance()->RemoveAll(); + return; + } -void ApplistView::ClearAppItemToList() -{ - listAdapter_->ClearItem(); -} + void ApplistView::AddAppItemToList(const AppItem &item) + { + listAdapter_->AddListItem(item); + } -void ApplistView::OnItemSelected(int16 index, UIView *view) -{ - UNUSED(index); - if (view != nullptr) { - itemViewSele = static_cast(view); - itemViewSele->SelectedChange(); + void ApplistView::ClearAppItemToList() + { + listAdapter_->ClearItem(); + } - if (preItemViewSele != nullptr && preItemViewSele != itemViewSele) { - preItemViewSele->Reset(); + void ApplistView::OnItemSelected(int16 index, UIView *view) + { + UNUSED(index); + if (view != nullptr) + { + itemViewSele = static_cast(view); + itemViewSele->SelectedChange(); + + if (preItemViewSele != nullptr && preItemViewSele != itemViewSele) + { + preItemViewSele->Reset(); + } + preItemViewSele = itemViewSele; } - preItemViewSele = itemViewSele; } -} -UIList* ApplistView::GetAppUIList(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::GetAppUIList"); - return contentList_; -} + UIList *ApplistView::GetAppUIList(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::GetAppUIList"); + return contentList_; + } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenModel.h b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenModel.h index 9ee3afe35..c2dee4806 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenModel.h @@ -11,7 +11,7 @@ #include "stdio.h" #include "gfx_utils/list.h" #include "los_mux.h" - +#include namespace OHOS { class BloodOxygenModel @@ -30,6 +30,9 @@ namespace OHOS void SetCheckStatus(bool checkstatus); void UpSPO2data(uint16_t spo2); uint16_t GetSPO2data(); + uint16_t GetShowSPO2data(); + uint16_t GetCheckTime(); // 获取距离上传测试时间 + void SetCheckTime(uint16_t time); // 设置本次测试完的时间 private: BloodOxygenModel(); @@ -37,8 +40,11 @@ namespace OHOS bool BandoffView; bool CheckView; bool ResultView; - bool CheckStatus; // 检测状态标志 - uint16_t SPO2_; // 血氧 + bool CheckStatus; // 检测状态标志 + uint16_t Show_SPO2_; // 显示血氧 + uint16_t SPO2_; // 保存血氧 + uint16_t TIME_; // 检测时间(存(时、分),大于24小时,改为1天前,小于1分钟为刚刚) + bool initstatus = true; }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenPresenter.h index 3decd6847..4ea4da9bd 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenPresenter.h @@ -49,6 +49,9 @@ namespace OHOS bool OnClick(UIView &view, const ClickEvent &event) override; bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 + uint16_t GetCurrentTime(); + std::string GetTDOA(uint16_t new_time, uint16_t old_time); + private: bool CheckPointersValue(void); void ReturnInterface(void); diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodCheckView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodCheckView.cpp index 66cd263f2..10c3051e9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodCheckView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodCheckView.cpp @@ -77,7 +77,7 @@ namespace OHOS } void BloodCheckView::UpSpo2Text() { - uint16_t spo2_ = BloodOxygenModel::GetInstance()->GetSPO2data(); + uint16_t spo2_ = BloodOxygenModel::GetInstance()->GetShowSPO2data(); //WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetSPO2Data %d", spo2_); std::string bloodoxygenStr = std::to_string(spo2_); Spo2Text->SetText(bloodoxygenStr.c_str()); diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenModel.cpp index 8cd73beff..148a07a12 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenModel.cpp @@ -8,6 +8,7 @@ #include "BloodOxygenModel.h" #include "DialModelSPO2.h" #include "wearable_log.h" +#include "BloodOxygenPresenter.h" namespace OHOS { BloodOxygenModel::BloodOxygenModel() @@ -66,13 +67,35 @@ namespace OHOS { return SPO2_; } + uint16_t BloodOxygenModel::GetShowSPO2data() + { + return Show_SPO2_; + } void BloodOxygenModel::UpSPO2data(uint16_t spo2) { - //WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpSPO2data SPO2:%d->%d", SPO2_, spo2); - SPO2_ = spo2; + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpSPO2data SPO2:%d->%d", SPO2_, spo2); + Show_SPO2_ = spo2; + // 筛选有效信息 + if (Show_SPO2_ != 0) + { + SPO2_ = spo2; + } + } + uint16_t BloodOxygenModel::GetCheckTime() + { + // 第一次进入,默认刚刚测试 + if (initstatus) + { + TIME_ = BloodOxygenPresenter::GetInstance()->GetCurrentTime(); + initstatus = false; + } + return TIME_; + } + void BloodOxygenModel::SetCheckTime(uint16_t time) + { + TIME_ = time; } /* -------------------------------------------------------------------------- */ - BloodOxygenModel *BloodOxygenModel::GetInstance(void) { static BloodOxygenModel instance; diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp index f55e4826e..4aa92f61b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp @@ -39,7 +39,45 @@ namespace OHOS static constexpr uint16_t PROGRESS_VALUE_MIN = 0; static constexpr uint16_t PROGRESS_VALUE_MAX = 10; + /* -------------------------------------------------------------------------- */ + // 获取当前的"时间分" + uint16_t BloodOxygenPresenter::GetCurrentTime() + { + time_t now = time(0); + struct tm *tblock = localtime(&now); + uint16_t current_time = tblock->tm_hour * 60 + tblock->tm_min; + return current_time; + } + // 获取时间差 + std::string BloodOxygenPresenter::GetTDOA(uint16_t new_time, uint16_t old_time) + { + if (new_time == old_time) + { + return "刚刚"; + } + + int time_diff = new_time - old_time; + if (time_diff > 60) + { + int hours = time_diff / 60; + int minutes = time_diff % 60; + std::stringstream ss; + ss << hours << "小时"; + if (minutes > 0) + { + ss << minutes << "分钟"; + } + return ss.str() + "前"; + } + else + { + std::stringstream ss; + ss << time_diff << "分钟前"; + return ss.str(); + } + } + /* -------------------------------------------------------------------------- */ BloodOxygenPresenter::BloodOxygenPresenter() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodOxygenPresenter::new BloodOxygenPresenter"); @@ -236,9 +274,10 @@ namespace OHOS BloodOxygenModel::GetInstance()->SetCheckStatus(false); // 关闭检测 BloodOxygenModel::GetInstance()->SetBloodCheckViewStatus(false); } + uint16_t time = GetCurrentTime(); + BloodOxygenModel::GetInstance()->SetCheckTime(time); // 更新时间 } } - void BloodOxygenPresenter::Notify(void) { ProgressNotify(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenView.cpp index b07675576..22f8c9576 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenView.cpp @@ -23,8 +23,8 @@ namespace OHOS static constexpr uint16_t PERCENT_X = 133; static constexpr uint16_t PERCENT_Y = 103; static constexpr uint16_t PERCENT_FONT_SIZE = 140; - static constexpr uint16_t TIMELABEL_X = 141; - static constexpr uint16_t TIMELABEL_Y = 270; + static constexpr uint16_t TIMELABEL_X = 90; + static constexpr uint16_t TIMELABEL_Y = 260; static constexpr uint16_t TIMELABEL_FONT_SIZE = 30; static constexpr uint16_t TITLE_X = 161; static constexpr uint16_t TITLE_Y = 55; @@ -74,10 +74,18 @@ namespace OHOS } void BloodOxygenView::Upspo2data() { + // 更新血氧数据 uint16_t spo2_ = BloodOxygenModel::GetInstance()->GetSPO2data(); - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetSPO2Data %d", spo2_); - std::string bloodoxygenStr = std::to_string(spo2_); - percent->SetText(bloodoxygenStr.c_str()); + if (spo2_ != 97) // 判断是否为默认数据 + { + std::string bloodoxygenStr = std::to_string(spo2_); + percent->SetText(bloodoxygenStr.c_str()); + } + // 更新时间 + uint16_t time = BloodOxygenPresenter::GetInstance()->GetCurrentTime(); + uint16_t check_time = BloodOxygenModel::GetInstance()->GetCheckTime(); + std::string TimeStr = BloodOxygenPresenter::GetInstance()->GetTDOA(time, check_time) + "检测"; + timeLabel->SetText(TimeStr.c_str()); } // 初始化标签 @@ -94,8 +102,7 @@ namespace OHOS percent->Resize(200, 200); // widget's width and height percent->SetViewId("label2"); // Set style percent->SetStyle(STYLE_TEXT_FONT, PERCENT_FONT_SIZE); - spo2_ = BloodOxygenModel::GetInstance()->GetSPO2data(); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetSPO2Data %d", spo2_); + uint16_t spo2_ = BloodOxygenModel::GetInstance()->GetSPO2data(); std::string bloodoxygenStr = std::to_string(spo2_); percent->SetText(bloodoxygenStr.c_str()); percent->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); @@ -110,11 +117,17 @@ namespace OHOS return false; } timeLabel->SetPosition(TIMELABEL_X, TIMELABEL_Y); // widget's left position and top position - timeLabel->Resize(185, 35); // widget's width and height + timeLabel->Resize(280, 100); // widget's width and height timeLabel->SetViewId("label1"); // Set style timeLabel->SetStyle(STYLE_TEXT_FONT, TIMELABEL_FONT_SIZE); - timeLabel->SetText("20分钟前检测"); - timeLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + /* -------------------------------------------------------------------------- */ + // 更新时间 + uint16_t time = BloodOxygenPresenter::GetInstance()->GetCurrentTime(); + uint16_t check_time = BloodOxygenModel::GetInstance()->GetCheckTime(); + std::string TimeStr = BloodOxygenPresenter::GetInstance()->GetTDOA(time, check_time); + timeLabel->SetText(TimeStr.c_str()); + /* -------------------------------------------------------------------------- */ + timeLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); timeLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); timeLabel->SetRollSpeed(0); timeLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TIMELABEL_FONT_SIZE); diff --git a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/src/BloodCardView.cpp b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/src/BloodCardView.cpp index 0551547a8..4c4103c97 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/src/BloodCardView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/src/BloodCardView.cpp @@ -10,6 +10,8 @@ #include "components/ui_view_group.h" #include "DialModelSPO2.h" #include "DialModelHeartRate.h" +#include "BloodOxygenModel.h" +#include "BloodOxygenPresenter.h" namespace OHOS { static BloodCardView *g_pBloodCardView{nullptr}; @@ -88,9 +90,8 @@ namespace OHOS bloodLabel->SetStyle(STYLE_TEXT_FONT, 150); // Set additional property - // bloodoxygen =DialModelHeartRate::GetInstance()->GetHeartData(); - bloodoxygen = 97; - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetSPO2Data %d", bloodoxygen); + bloodoxygen = BloodOxygenModel::GetInstance()->GetSPO2data(); + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetSPO2Data %d", bloodoxygen); std::string bloodoxygenStr = std::to_string(bloodoxygen); bloodLabel->SetText(bloodoxygenStr.c_str()); bloodLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); @@ -101,19 +102,25 @@ namespace OHOS // Add to rootView Add(bloodLabel); - // Add Label to App + /* -------------------------------------------------------------------------- */ + timeLabel = new UILabel(); if (timeLabel == nullptr) { - timeLabel = new UILabel(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::new timeLabel fail"); + return false; } - timeLabel->SetPosition(140, 370); // widget's left position and top position - timeLabel->Resize(185, 35); // widget's width and height - timeLabel->SetViewId("label1"); // Set style + timeLabel->SetPosition(90, 300); // widget's left position and top position + timeLabel->Resize(280, 100); // widget's width and height + timeLabel->SetViewId("label1"); // Set style timeLabel->SetStyle(STYLE_TEXT_FONT, 30); - - // Set additional property - timeLabel->SetText("20分钟前检测"); - timeLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + /* -------------------------------------------------------------------------- */ + // 更新时间 + uint16_t time = BloodOxygenPresenter::GetInstance()->GetCurrentTime(); + uint16_t check_time = BloodOxygenModel::GetInstance()->GetCheckTime(); + std::string TimeStr = BloodOxygenPresenter::GetInstance()->GetTDOA(time, check_time) +"检测"; + timeLabel->SetText(TimeStr.c_str()); + /* -------------------------------------------------------------------------- */ + timeLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); timeLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); timeLabel->SetRollSpeed(0); timeLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageCardView.cpp b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageCardView.cpp index e439cb2ff..134e1cb03 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageCardView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageCardView.cpp @@ -7,7 +7,7 @@ namespace OHOS MessageCardView::MessageCardView() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MessageCardView::MessageCardView()"); - SetPosition(43, 120, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); } MessageCardView::~MessageCardView() diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageView.cpp b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageView.cpp index 0e0c194f1..2155af506 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageView.cpp @@ -116,6 +116,7 @@ namespace OHOS scrollView->Add(MessageList); RootView::GetInstance()->Add(scrollView); MessageList->SetAdapter(p_MessageListAdapter); + MessageList->RefreshList(); // 刷新列表 Draw(); } @@ -150,8 +151,6 @@ namespace OHOS scrollView->SetDraggable(false); draglistener = static_cast(MessagePresenter::GetInstance()); scrollView->SetOnDragListener(draglistener); - //Add(scrollView); - /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ #endif // UIList 的适配器 @@ -166,6 +165,7 @@ namespace OHOS Add(MessageList); MessageList->SetAdapter(p_MessageListAdapter); MessageList->SetLoopState(true); + MessageList->RefreshList(); // 刷新列表 MessageList->SetVisible(true); return true; }