#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<ApplistPresenter>::OnStart();
+ void ApplistView::OnStart()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::OnStart ");
+ View<ApplistPresenter>::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<ApplistPresenter>::OnSetUpView();
+ void ApplistView::OnSetUpView()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::OnSetUpView");
+ View<ApplistPresenter>::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<ApplistPresenter>::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<ApplistPresenter>::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<ApplistPresenter>::OnStop();
- container_ = nullptr;
+ presenter_->SetHeadItemY(listHeadY);
+ presenter_->SetStartIndex(listHeadIndex);
- RootView::GetInstance()->ClearOnKeyActListener();
- RootView::GetInstance()->RemoveAll();
- return;
-}
+ View<ApplistPresenter>::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<AppItemView *>(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<AppItemView *>(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_;
+ }
}
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;
}
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());
}
// 初始化标签
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);
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);