1.增加血氧显示数据和血氧结果区分;2.增加血氧检测时间同步更新;3.增加主页面血氧数据和时间同步信息;4.增加applist的圆形滑动条同步;
authorCaisking <3449750381@qq.com>
Sun, 3 Mar 2024 08:03:00 +0000 (16:03 +0800)
committerCaisking <3449750381@qq.com>
Sun, 3 Mar 2024 08:03:00 +0000 (16:03 +0800)
code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistView.cpp
code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenModel.h
code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenPresenter.h
code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodCheckView.cpp
code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenModel.cpp
code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenView.cpp
code/sdk/application/wearable/fd230app/nativeui/heart_blood/src/BloodCardView.cpp
code/sdk/application/wearable/fd230app/nativeui/message/src/MessageCardView.cpp
code/sdk/application/wearable/fd230app/nativeui/message/src/MessageView.cpp

index e2954a8..695e06d 100644 (file)
 #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_;
+    }
 
 }
index 9ee3afe..c2dee48 100644 (file)
@@ -11,7 +11,7 @@
 #include "stdio.h"
 #include "gfx_utils/list.h"
 #include "los_mux.h"
-
+#include <string>
 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;   
     };
 }
 
index 3decd68..4ea4da9 100644 (file)
@@ -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);
index 66cd263..10c3051 100644 (file)
@@ -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());
index 8cd73be..148a07a 100644 (file)
@@ -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;
index f55e482..4aa92f6 100644 (file)
@@ -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();
index b076755..22f8c95 100644 (file)
@@ -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);
index 0551547..4c4103c 100644 (file)
@@ -10,6 +10,8 @@
 #include "components/ui_view_group.h"\r
 #include "DialModelSPO2.h"\r
 #include "DialModelHeartRate.h"\r
+#include "BloodOxygenModel.h"\r
+#include "BloodOxygenPresenter.h"\r
 namespace OHOS\r
 {\r
     static BloodCardView *g_pBloodCardView{nullptr};\r
@@ -88,9 +90,8 @@ namespace OHOS
         bloodLabel->SetStyle(STYLE_TEXT_FONT, 150);\r
 \r
         // Set additional property\r
-        // bloodoxygen =DialModelHeartRate::GetInstance()->GetHeartData();\r
-        bloodoxygen = 97;\r
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetSPO2Data %d", bloodoxygen);\r
+        bloodoxygen = BloodOxygenModel::GetInstance()->GetSPO2data();\r
+        // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetSPO2Data %d", bloodoxygen);\r
         std::string bloodoxygenStr = std::to_string(bloodoxygen);\r
         bloodLabel->SetText(bloodoxygenStr.c_str());\r
         bloodLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);\r
@@ -101,19 +102,25 @@ namespace OHOS
         // Add to rootView\r
         Add(bloodLabel);\r
 \r
-        // Add Label to App\r
+      /* -------------------------------------------------------------------------- */\r
+        timeLabel = new UILabel();\r
         if (timeLabel == nullptr)\r
         {\r
-            timeLabel = new UILabel();\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::new timeLabel fail");\r
+            return false;\r
         }\r
-        timeLabel->SetPosition(140, 370); // widget's left position and top position\r
-        timeLabel->Resize(185, 35);       // widget's width and height\r
-        timeLabel->SetViewId("label1");   // Set style\r
+        timeLabel->SetPosition(90, 300); // widget's left position and top position\r
+        timeLabel->Resize(280, 100);                      // widget's width and height\r
+        timeLabel->SetViewId("label1");                   // Set style\r
         timeLabel->SetStyle(STYLE_TEXT_FONT, 30);\r
-\r
-        // Set additional property\r
-        timeLabel->SetText("20分钟前检测");\r
-        timeLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
+        /* -------------------------------------------------------------------------- */\r
+        // 更新时间\r
+        uint16_t time = BloodOxygenPresenter::GetInstance()->GetCurrentTime();\r
+        uint16_t check_time = BloodOxygenModel::GetInstance()->GetCheckTime();\r
+        std::string TimeStr = BloodOxygenPresenter::GetInstance()->GetTDOA(time, check_time) +"检测";\r
+        timeLabel->SetText(TimeStr.c_str());\r
+        /* -------------------------------------------------------------------------- */\r
+        timeLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);\r
         timeLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
         timeLabel->SetRollSpeed(0);\r
         timeLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
index e439cb2..134e1cb 100644 (file)
@@ -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()
index 0e0c194..2155af5 100644 (file)
@@ -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<UIView::OnDragListener *>(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;
     }