1126 lines
40 KiB
C++
1126 lines
40 KiB
C++
/*----------------------------------------------------------------------------
|
||
* Copyright (c) TJD Technologies Co., Ltd. 2024. All rights reserved.
|
||
*
|
||
* Description:
|
||
*
|
||
* Author: wuchangxin
|
||
*
|
||
* Create: 2024-6-23
|
||
*--------------------------------------------------------------------------*/
|
||
|
||
#include "TjdUiAppBloodOxygenView.h"
|
||
#include "TjdUiImageIds.h"
|
||
#include "TjdUiMemManage.h"
|
||
#include "TjdUiMultiLanguageExt.h"
|
||
#include "TjdUiUtils.h"
|
||
#include "common/image_cache_manager.h"
|
||
#include "font/ui_font_header.h"
|
||
#include "graphic_service.h"
|
||
#include "hal_tick.h"
|
||
#include "rtc_api.h"
|
||
#include "sql_fit.h"
|
||
#include "sys_config.h"
|
||
#include "wearable_log.h"
|
||
#include <stdio.h>
|
||
|
||
using namespace OHOS;
|
||
|
||
#define ENABLE_PRINT_INFO 1
|
||
#define DEBUG_ENABLE 0
|
||
#if ENABLE_PRINT_INFO
|
||
#define static_print_info(...) sys_ui_log_i(__VA_ARGS__) // 一般信息打印宏控制
|
||
#define static_print_warn(...) sys_ui_log_w(__VA_ARGS__) // 警告信息打印一般常开
|
||
#define static_print_error(...) sys_ui_log_e(__VA_ARGS__) // 错误信息打印一般常开
|
||
#if DEBUG_ENABLE
|
||
#define static_print_debug(...) sys_ui_log_d(__VA_ARGS__)
|
||
#else
|
||
#define static_print_debug(...)
|
||
#endif
|
||
#else
|
||
#define static_print_info(...)
|
||
#define static_print_warn(...)
|
||
#define static_print_error(...)
|
||
#endif
|
||
|
||
namespace TJD {
|
||
|
||
#define IMAGE_RETURN_BIN_PATH TJD_IMAGE_PATH "img_return.bin"
|
||
#define SPO2_IMAGE_BIN_PATH TJD_IMAGE_PATH "img_spo2.bin"
|
||
#define HR_IMAGE_BIN_PATH TJD_IMAGE_PATH "img_heartrate.bin"
|
||
#define ANIM_IMAGE_MAX_NUM 8
|
||
#define IMAGE_ABOUT_ID "imageAbout"
|
||
#define REMIND_IMAGE_RETURN_ID "remindImgReturn"
|
||
#define UNWEAR_IMAGE_RETURN_ID "unwearImgReturn"
|
||
uint8_t TjdUiAppSpO2View::spo2WaitTime_ = 0;
|
||
|
||
static ImageAnimatorInfo g_imageAnimatorInfo[ANIM_IMAGE_MAX_NUM] = {
|
||
{nullptr, {154, 30}, 51, 79, IMG_SRC_IMAGE_INFO}, {nullptr, {154, 30}, 51, 79, IMG_SRC_IMAGE_INFO},
|
||
{nullptr, {154, 30}, 51, 79, IMG_SRC_IMAGE_INFO}, {nullptr, {154, 30}, 51, 79, IMG_SRC_IMAGE_INFO},
|
||
{nullptr, {154, 30}, 51, 79, IMG_SRC_IMAGE_INFO}, {nullptr, {154, 30}, 51, 79, IMG_SRC_IMAGE_INFO},
|
||
{nullptr, {154, 30}, 51, 79, IMG_SRC_IMAGE_INFO}, {nullptr, {154, 30}, 51, 79, IMG_SRC_IMAGE_INFO},
|
||
};
|
||
|
||
static int g_imageAnimatorId[] = {
|
||
IMG_SPO2_DT_01_03, IMG_SPO2_DT_02_03, IMG_SPO2_DT_03_03, IMG_SPO2_DT_04_03,
|
||
IMG_SPO2_DT_05_03, IMG_SPO2_DT_06_03, IMG_SPO2_DT_07_03, IMG_SPO2_DT_08_03,
|
||
};
|
||
|
||
static void FlickerTimerCallback(void *arg)
|
||
{
|
||
GraphicService::GetInstance()->PostGraphicEvent([arg]() {
|
||
UILabel *label = static_cast<UILabel *>(arg);
|
||
if (label == nullptr) {
|
||
return;
|
||
}
|
||
static_print_debug("label->GetText: %s", label->GetText());
|
||
if (TjdUiAppSpO2View::spo2WaitTime_ < 10) { //等待5s待出值稳定
|
||
TjdUiAppSpO2View::spo2WaitTime_ += 1;
|
||
label->SetText("---");
|
||
label->IsVisible() ? label->SetVisible(false) : label->SetVisible(true);
|
||
return;
|
||
}
|
||
|
||
auto spo2View = TjdUiAppSpO2View::GetInstance();
|
||
if (label->GetText() == std::string("---")) {
|
||
label->IsVisible() ? label->SetVisible(false) : label->SetVisible(true);
|
||
} else {
|
||
spo2View->flickerTimer_->Stop();
|
||
spo2View->Invalidate();
|
||
}
|
||
});
|
||
}
|
||
|
||
void SpO2FlickerTimer::Start()
|
||
{
|
||
if (!label_)
|
||
return;
|
||
label_->SetText("---");
|
||
auto spo2View = TjdUiAppSpO2View::GetInstance();
|
||
OHOS::GraphicTimer::Start();
|
||
TjdUiAppSpO2View::GetInstance()->SetScrollPickerVisible(false);
|
||
uint8_t value = TjdUiAppSpO2Presenter::GetInstance()->GetSpO2Value();
|
||
spo2View->ScrollPickerDataInit(value);
|
||
}
|
||
void SpO2FlickerTimer::Stop()
|
||
{
|
||
if (!label_)
|
||
return;
|
||
if (label_->IsVisible())
|
||
label_->SetVisible(false);
|
||
OHOS::GraphicTimer::Stop();
|
||
}
|
||
|
||
bool Spo2ScrollPicker::CheckValueChanges(uint8_t value)
|
||
{
|
||
|
||
if (value != spo2Values_) {
|
||
needsUpdate_ = true;
|
||
directions_ = (value < spo2Values_);
|
||
|
||
label[1 + (directions_ ? -1 : 1)].SetText(std::to_string(value).c_str());
|
||
spo2Values_ = value;
|
||
return true;
|
||
} else {
|
||
needsUpdate_ = false;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
void Spo2ScrollPickerCallback::Callback(OHOS::UIView *view)
|
||
{
|
||
auto scrollPicker = dynamic_cast<Spo2ScrollPicker *>(view);
|
||
if (!scrollPicker)
|
||
return;
|
||
|
||
if (!scrollPicker->needsUpdate_) {
|
||
return;
|
||
}
|
||
state_ = true;
|
||
int16_t x;
|
||
int16_t y;
|
||
|
||
UIView *childView = scrollPicker->GetChildrenHead();
|
||
while (childView != nullptr) {
|
||
bool dir = scrollPicker->directions_;
|
||
int16_t y = childView->GetY() + (dir ? 2 : -2);
|
||
childView->SetY(y);
|
||
childView = childView->GetNextSibling();
|
||
|
||
if (++cnt >= 90) {
|
||
if (animator_)
|
||
animator_->Stop();
|
||
cnt = 0;
|
||
scrollPicker->needsUpdate_ = false;
|
||
dir ? CycleLabelsUp(view) : CycleLabelsDown(view);
|
||
scrollPicker->ResetLabelPositions();
|
||
state_ = false;
|
||
}
|
||
|
||
scrollPicker->Invalidate();
|
||
}
|
||
}
|
||
|
||
void Spo2ScrollPickerCallback::CycleLabelsUp(OHOS::UIView *view)
|
||
{
|
||
auto scrollPicker = dynamic_cast<Spo2ScrollPicker *>(view);
|
||
if (!scrollPicker)
|
||
return;
|
||
|
||
scrollPicker->UpdateLabels();
|
||
}
|
||
|
||
void Spo2ScrollPickerCallback::CycleLabelsDown(OHOS::UIView *view)
|
||
{
|
||
auto scrollPicker = dynamic_cast<Spo2ScrollPicker *>(view);
|
||
if (!scrollPicker)
|
||
return;
|
||
|
||
scrollPicker->UpdateLabels();
|
||
}
|
||
|
||
#define FONT_SIZE 56
|
||
|
||
Spo2ScrollPicker::Spo2ScrollPicker()
|
||
{
|
||
SetPosition(0, 0, 30, 60);
|
||
// SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
|
||
SetStyle(STYLE_BACKGROUND_OPA, 0x00);
|
||
SetDraggable(false);
|
||
|
||
for (size_t i = 0; i < 3; i++) {
|
||
label[i].SetFont(TJD_DIN_MEDIUM_FONT_FILENAME, FONT_SIZE);
|
||
label[i].SetText("0");
|
||
// label[i].SetLineBreakMode(OHOS::UILabel::LINE_BREAK_ADAPT);
|
||
label[i].SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
||
label[i].SetPosition(0, -60 + 60 * i, 30, 60);
|
||
Add(&label[i]);
|
||
}
|
||
}
|
||
|
||
Spo2ScrollPicker::~Spo2ScrollPicker() { RemoveAll(); }
|
||
|
||
void Spo2ScrollPicker::DateInit(uint8_t value)
|
||
{
|
||
label[1].SetText(std::to_string(value).c_str());
|
||
spo2Values_ = value;
|
||
preValues_ = value;
|
||
}
|
||
|
||
void Spo2ScrollPicker::UpdateLabels()
|
||
{
|
||
label[0].SetText(std::to_string(spo2Values_).c_str());
|
||
label[1].SetText(std::to_string(spo2Values_).c_str());
|
||
label[2].SetText(std::to_string(spo2Values_).c_str()); // 可预加载下一值
|
||
}
|
||
|
||
void Spo2ScrollPicker::ResetLabelPositions()
|
||
{
|
||
label[0].SetY(-60);
|
||
label[1].SetY(0);
|
||
label[2].SetY(60);
|
||
}
|
||
|
||
static void DeleteViewChilden(UIViewGroup *viewGroup)
|
||
{
|
||
if (viewGroup == nullptr) {
|
||
return;
|
||
}
|
||
UIView *view = viewGroup->GetChildrenHead();
|
||
while (view != nullptr) {
|
||
UIView *tempView = view;
|
||
view = view->GetNextSibling();
|
||
if (tempView->GetParent()) {
|
||
static_cast<UIViewGroup *>(tempView->GetParent())->Remove(tempView);
|
||
}
|
||
delete tempView;
|
||
tempView = nullptr;
|
||
}
|
||
}
|
||
|
||
|
||
static TjdUiAppSpO2View *g_pv_AppSpO2View = nullptr;
|
||
|
||
TjdUiAppSpO2View::TjdUiAppSpO2View() { g_pv_AppSpO2View = this; }
|
||
|
||
TjdUiAppSpO2View::~TjdUiAppSpO2View()
|
||
{
|
||
g_pv_AppSpO2View = nullptr;
|
||
|
||
if (imgAboutListener_) {
|
||
delete imgAboutListener_;
|
||
imgAboutListener_ = nullptr;
|
||
}
|
||
if (imgRemindListener_) {
|
||
delete imgRemindListener_;
|
||
imgRemindListener_ = nullptr;
|
||
}
|
||
if (imgUnwearListener_) {
|
||
delete imgUnwearListener_;
|
||
imgUnwearListener_ = nullptr;
|
||
}
|
||
|
||
if (flickerTimer_) {
|
||
flickerTimer_->Stop();
|
||
delete flickerTimer_;
|
||
flickerTimer_ = nullptr;
|
||
}
|
||
|
||
if (leftCallback_ != nullptr) {
|
||
delete leftCallback_;
|
||
leftCallback_ = nullptr;
|
||
}
|
||
|
||
if (leftAnimator_ != nullptr) {
|
||
leftAnimator_->Stop();
|
||
delete leftAnimator_;
|
||
leftAnimator_ = nullptr;
|
||
}
|
||
|
||
if (rightCallback_ != nullptr) {
|
||
delete rightCallback_;
|
||
rightCallback_ = nullptr;
|
||
}
|
||
|
||
if (rightAnimator_ != nullptr) {
|
||
rightAnimator_->Stop();
|
||
delete rightAnimator_;
|
||
rightAnimator_ = nullptr;
|
||
}
|
||
|
||
if (dataSerial_ != nullptr) {
|
||
uiChart1_->DeleteDataSerial(dataSerial_);
|
||
delete dataSerial_;
|
||
dataSerial_ = nullptr;
|
||
}
|
||
|
||
if (uiChart1_ != nullptr) {
|
||
SpO2_container_->Remove(uiChart1_);
|
||
delete uiChart1_;
|
||
uiChart1_ = nullptr;
|
||
}
|
||
|
||
if (containerAll_) {
|
||
containerAll_->RemoveAll();
|
||
delete containerAll_;
|
||
containerAll_ = nullptr;
|
||
}
|
||
if (swipeContainer_) {
|
||
swipeContainer_->ClearFocus();
|
||
swipeContainer_->RemoveAll();
|
||
delete swipeContainer_;
|
||
swipeContainer_ = nullptr;
|
||
}
|
||
if (SpO2_container_) {
|
||
DeleteViewChilden(SpO2_container_);
|
||
delete SpO2_container_;
|
||
SpO2_container_ = nullptr;
|
||
}
|
||
if (Average_container_) {
|
||
DeleteViewChilden(Average_container_);
|
||
delete Average_container_;
|
||
Average_container_ = nullptr;
|
||
}
|
||
if (RemindView_) {
|
||
DeleteViewChilden(RemindView_);
|
||
delete RemindView_;
|
||
RemindView_ = nullptr;
|
||
}
|
||
if (UnwearView_) {
|
||
DeleteViewChilden(UnwearView_);
|
||
delete UnwearView_;
|
||
UnwearView_ = nullptr;
|
||
}
|
||
|
||
ImageCacheManager::GetInstance().UnloadAllInMultiRes(HR_IMAGE_BIN_PATH);
|
||
ImageCacheManager::GetInstance().UnloadAllInMultiRes(SPO2_IMAGE_BIN_PATH);
|
||
ImageCacheManager::GetInstance().UnloadAllInMultiRes(IMAGE_RETURN_BIN_PATH);
|
||
|
||
// TjdUiMemManage::DeleteChildren(containerAll_);
|
||
}
|
||
|
||
TjdUiAppSpO2View *TjdUiAppSpO2View::GetInstance(void) { return g_pv_AppSpO2View; }
|
||
|
||
void TjdUiAppSpO2View::OnStart()
|
||
{
|
||
WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "_%n\n", __LINE__);
|
||
OHOS::FocusManager::GetInstance()->ClearFocus();
|
||
TjdUiAppSpO2Presenter::GetInstance()->SpO2PointArrayInit();
|
||
|
||
if (onSwipeListener_ == nullptr) {
|
||
onSwipeListener_ = static_cast<UISwipeView::OnSwipeListener *>(TjdUiAppSpO2Presenter::GetInstance());
|
||
}
|
||
|
||
ImageInfoInit();
|
||
InitRodViewInfo();
|
||
|
||
if (swipeContainer_ == nullptr) {
|
||
swipeContainer_ = new UISwipeViewNested(UISwipeView::VERTICAL);
|
||
swipeContainer_->SetPosition(0, 0, OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
||
swipeContainer_->SetViewId("swipeContainer_");
|
||
swipeContainer_->SetStyle(STYLE_BACKGROUND_OPA, 0);
|
||
swipeContainer_->SetOnSwipeListener(onSwipeListener_);
|
||
if (OHOS::PageTransitionMgr::GetInstance().GetTopSlideBackImage() == nullptr) {
|
||
swipeContainer_->SetOnDragListener(TjdUiAppSpO2Presenter::GetInstance());
|
||
}
|
||
|
||
swipeContainer_->RequestFocus();
|
||
}
|
||
|
||
if (containerAll_ == nullptr) {
|
||
containerAll_ = new UIViewGroup();
|
||
containerAll_->SetPosition(0, 0, OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
||
}
|
||
SpO2MainViewInit();
|
||
SpO2AverageViewInit();
|
||
SpO2RemindViewInit();
|
||
SpO2UnwearViewInit();
|
||
|
||
groupList_[SpO2View::SPO2SWIPE_VIEW] = swipeContainer_;
|
||
groupList_[SpO2View::SPO2REMIND_VIEW] = RemindView_;
|
||
groupList_[SpO2View::SPO2UNWEAR_VIEW] = UnwearView_;
|
||
|
||
for (int i = 0; i < SPO2MAX_VIEW; i++) {
|
||
if (groupList_[i] != nullptr) {
|
||
containerAll_->Add(groupList_[i]);
|
||
}
|
||
}
|
||
|
||
AddViewToRootContainer(containerAll_);
|
||
|
||
flickerTimer_ = new SpO2FlickerTimer(200, FlickerTimerCallback, (void *)SpO2_Cur_, true);
|
||
|
||
TjdUiAppSpO2Presenter::GetInstance()->TimeTaskStart();
|
||
curView = SPO2SWIPE_VIEW;
|
||
}
|
||
|
||
void TjdUiAppSpO2View::OnStop()
|
||
{
|
||
WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "_%n\n", __LINE__);
|
||
TjdUiAppSpO2Presenter::GetInstance()->TimeTaskStop();
|
||
}
|
||
|
||
bool TjdUiAppSpO2OnClickedListener::OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event)
|
||
{
|
||
// printf("cxin is clicked\n");
|
||
if (view.GetViewId() == IMAGE_ABOUT_ID) {
|
||
TjdUiAppSpO2View::GetInstance()->ChangedView(SPO2REMIND_VIEW, SPO2SWIPE_VIEW);
|
||
TjdUiAppSpO2Presenter::GetInstance()->TimeTaskStop();
|
||
|
||
} else if (view.GetViewId() == REMIND_IMAGE_RETURN_ID) {
|
||
TjdUiAppSpO2View::GetInstance()->ChangedView(SPO2SWIPE_VIEW, SPO2REMIND_VIEW);
|
||
TjdUiAppSpO2Presenter::GetInstance()->TimeTaskStart();
|
||
|
||
} else if (view.GetViewId() == UNWEAR_IMAGE_RETURN_ID) {
|
||
TjdUiAppSpO2View::GetInstance()->ChangedView(SPO2SWIPE_VIEW, SPO2UNWEAR_VIEW);
|
||
TjdUiAppSpO2Presenter::GetInstance()->TimeTaskStart();
|
||
}
|
||
return true;
|
||
}
|
||
|
||
void TjdUiAppSpO2View::ImageInfoInit(void)
|
||
{
|
||
WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "_%n\n", __LINE__);
|
||
ImageInfo *imgInfo;
|
||
for (uint8_t i = 0; i < ANIM_IMAGE_MAX_NUM; i++) {
|
||
imgInfo = ImageCacheManager::GetInstance().LoadOneInMultiRes(g_imageAnimatorId[i], SPO2_IMAGE_BIN_PATH);
|
||
g_imageAnimatorInfo[i].imageInfo = imgInfo;
|
||
}
|
||
}
|
||
|
||
void TjdUiAppSpO2View::SpO2MainViewInit(void)
|
||
{
|
||
WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "_%n\n", __LINE__);
|
||
struct rtc_time localTime;
|
||
tjd_driver_rtc_get_ops()->get_rtc_time(&localTime);
|
||
uint8_t max = sql_fit_get_spo2_max(localTime.tm_wday);
|
||
uint8_t min = sql_fit_get_spo2_min(localTime.tm_wday);
|
||
char temp_str[10];
|
||
|
||
if (SpO2_container_ == nullptr) {
|
||
SpO2_container_ = new UIViewGroup();
|
||
SpO2_container_->SetPosition(0, 0, OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
||
SpO2_container_->SetViewId("MainPageBloodOxygen");
|
||
SpO2_container_->SetStyle(STYLE_BACKGROUND_OPA, 0);
|
||
}
|
||
|
||
/*-----------------------------Add image_chart_time to App------------------------------*/
|
||
image_chart_time = new UIImageView();
|
||
image_chart_time->SetPosition(30, 132);
|
||
image_chart_time->Resize(410, 194);
|
||
image_chart_time->SetViewId("image_chart_time"); // Set style
|
||
|
||
// Set additional property
|
||
ImageInfo *imgInfo = ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_SPO2_CHART_TIME, SPO2_IMAGE_BIN_PATH);
|
||
if (imgInfo == nullptr) {
|
||
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "load image error\n");
|
||
}
|
||
image_chart_time->SetSrc(imgInfo);
|
||
// Add to rootView
|
||
SpO2_container_->Add(image_chart_time);
|
||
image_chart_time->SetVisible(true);
|
||
|
||
/*-----------------------------Add image_high to App------------------------------*/
|
||
image_high = new UIImageView();
|
||
image_high->SetPosition(108, 380);
|
||
image_high->SetViewId("image_high");
|
||
imgInfo = ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_SPO2_HIGH, SPO2_IMAGE_BIN_PATH);
|
||
if (imgInfo != nullptr) {
|
||
image_high->SetSrc(imgInfo);
|
||
}
|
||
SpO2_container_->Add(image_high);
|
||
image_high->SetVisible(true);
|
||
|
||
/*-----------------------------Add image_low to App------------------------------*/
|
||
image_low = new UIImageView();
|
||
image_low->SetPosition(264, 380);
|
||
image_low->SetViewId("image_low");
|
||
imgInfo = ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_SPO2_LOW, SPO2_IMAGE_BIN_PATH);
|
||
if (imgInfo != nullptr) {
|
||
image_low->SetSrc(imgInfo);
|
||
}
|
||
SpO2_container_->Add(image_low);
|
||
image_low->SetVisible(true);
|
||
|
||
/*-----------------------------Add image_pull_up to App------------------------------*/
|
||
image_pull_up = new UIImageView();
|
||
image_pull_up->SetPosition(214, 430);
|
||
image_pull_up->SetViewId("image_pull_up");
|
||
imgInfo = ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_SPO2_PULL_UP, SPO2_IMAGE_BIN_PATH);
|
||
if (imgInfo != nullptr) {
|
||
image_pull_up->SetSrc(imgInfo);
|
||
}
|
||
SpO2_container_->Add(image_pull_up);
|
||
image_pull_up->SetVisible(true);
|
||
|
||
/*-----------------------------Add image_about to App------------------------------*/
|
||
image_about = new UIImageView();
|
||
image_about->SetPosition(213, 12);
|
||
image_about->SetViewId(IMAGE_ABOUT_ID);
|
||
imgInfo = ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_SPO2_ABOUT, SPO2_IMAGE_BIN_PATH);
|
||
if (imgInfo != nullptr) {
|
||
image_about->SetSrc(imgInfo);
|
||
}
|
||
image_about->SetTouchable(true);
|
||
imgAboutListener_ = new TjdUiAppSpO2OnClickedListener();
|
||
image_about->SetOnClickListener(imgAboutListener_);
|
||
SpO2_container_->Add(image_about);
|
||
image_about->SetVisible(true);
|
||
/*-----------------------------Add labelNum100_ to App------------------------------*/
|
||
labelNum100_ = new UILabel();
|
||
labelNum100_->SetPosition(405, 130);
|
||
labelNum100_->Resize(35, 17);
|
||
labelNum100_->SetViewId("labelNum200");
|
||
labelNum100_->SetStyle(STYLE_TEXT_FONT, TJD_FONT_SIZE_24);
|
||
labelNum100_->SetText("100");
|
||
labelNum100_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
|
||
labelNum100_->SetTextColor(Color::GetColorFromRGBA(0x6B, 0x6B, 0x6B, 0xff));
|
||
labelNum100_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
|
||
labelNum100_->SetRollSpeed(0);
|
||
labelNum100_->SetFont(TJD_VECTOR_FONT_FILENAME, TJD_FONT_SIZE_24);
|
||
SpO2_container_->Add(labelNum100_);
|
||
labelNum100_->SetVisible(true);
|
||
|
||
/*-----------------------------Add labelNum90_ to App------------------------------*/
|
||
labelNum90_ = new UILabel();
|
||
labelNum90_->SetPosition(405, 132 + 35);
|
||
labelNum90_->Resize(35, 17);
|
||
labelNum90_->SetViewId("labelNum150");
|
||
labelNum90_->SetStyle(STYLE_TEXT_FONT, TJD_FONT_SIZE_24);
|
||
labelNum90_->SetText("90");
|
||
labelNum90_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
|
||
labelNum90_->SetTextColor(Color::GetColorFromRGBA(0x6B, 0x6B, 0x6B, 0xff));
|
||
labelNum90_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
|
||
labelNum90_->SetRollSpeed(0);
|
||
labelNum90_->SetFont(TJD_VECTOR_FONT_FILENAME, TJD_FONT_SIZE_24);
|
||
SpO2_container_->Add(labelNum90_);
|
||
labelNum90_->SetVisible(true);
|
||
|
||
/*-----------------------------Add labelNum80_ to App------------------------------*/
|
||
labelNum80_ = new UILabel();
|
||
labelNum80_->SetPosition(405, 132 + 70);
|
||
labelNum80_->Resize(35, 17);
|
||
labelNum80_->SetViewId("labelNum100");
|
||
labelNum80_->SetStyle(STYLE_TEXT_FONT, TJD_FONT_SIZE_24);
|
||
labelNum80_->SetText("80");
|
||
labelNum80_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
|
||
labelNum80_->SetTextColor(Color::GetColorFromRGBA(0x6B, 0x6B, 0x6B, 0xff));
|
||
labelNum80_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
|
||
labelNum80_->SetRollSpeed(0);
|
||
labelNum80_->SetFont(TJD_VECTOR_FONT_FILENAME, TJD_FONT_SIZE_24);
|
||
SpO2_container_->Add(labelNum80_);
|
||
labelNum80_->SetVisible(true);
|
||
|
||
/*-----------------------------Add labelNum70_ to App------------------------------*/
|
||
labelNum70_ = new UILabel();
|
||
labelNum70_->SetPosition(405, 132 + 115);
|
||
labelNum70_->Resize(35, 17);
|
||
labelNum70_->SetViewId("labelNum50");
|
||
labelNum70_->SetStyle(STYLE_TEXT_FONT, TJD_FONT_SIZE_24);
|
||
labelNum70_->SetText("70");
|
||
labelNum70_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
|
||
labelNum70_->SetTextColor(Color::GetColorFromRGBA(0x6B, 0x6B, 0x6B, 0xff));
|
||
labelNum70_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
|
||
labelNum70_->SetRollSpeed(0);
|
||
labelNum70_->SetFont(TJD_VECTOR_FONT_FILENAME, TJD_FONT_SIZE_24);
|
||
SpO2_container_->Add(labelNum70_);
|
||
labelNum70_->SetVisible(true);
|
||
|
||
/*-----------------------------Add imageAnimator_ to App------------------------------*/
|
||
imageAnimator_ = new UIImageAnimatorView();
|
||
imageAnimator_->SetPosition(g_imageAnimatorInfo->pos.x, g_imageAnimatorInfo->pos.y);
|
||
imageAnimator_->Resize(g_imageAnimatorInfo->width, g_imageAnimatorInfo->height);
|
||
imageAnimator_->SetViewId("imageAnimator");
|
||
imageAnimator_->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
|
||
imageAnimator_->SetStyle(STYLE_BACKGROUND_OPA, 0);
|
||
|
||
imageAnimator_->SetImageAnimatorSrc(g_imageAnimatorInfo, ANIM_IMAGE_MAX_NUM, 200);
|
||
imageAnimator_->SetTimeOfPause(200);
|
||
imageAnimator_->SetReverse(false);
|
||
imageAnimator_->SetTouchable(true);
|
||
imageAnimator_->SetOnClickListener(TjdUiAppSpO2Presenter::GetInstance());
|
||
imageAnimator_->Start();
|
||
|
||
SpO2_container_->Add(imageAnimator_);
|
||
imageAnimator_->SetVisible(true);
|
||
|
||
/*-----------------------------Add SpO2_Cur_ to App------------------------------*/
|
||
SpO2_Cur_ = new UILabel();
|
||
SpO2_Cur_->SetPosition(217, 48);
|
||
SpO2_Cur_->Resize(55, 40);
|
||
SpO2_Cur_->SetViewId("SpO2_Cur_");
|
||
SpO2_Cur_->SetStyle(STYLE_TEXT_FONT, 56);
|
||
SpO2_Cur_->SetText("---");
|
||
SpO2_Cur_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
|
||
SpO2_Cur_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
|
||
SpO2_Cur_->SetRollSpeed(0);
|
||
SpO2_Cur_->SetFont(TJD_VECTOR_FONT_FILENAME, TJD_FONT_SIZE_56);
|
||
SpO2_container_->Add(SpO2_Cur_);
|
||
SpO2_Cur_->SetVisible(true);
|
||
|
||
leftScrollPicker = new Spo2ScrollPicker();
|
||
leftScrollPicker->SetPosition(217, 48);
|
||
leftScrollPicker->SetVisible(false);
|
||
SpO2_container_->Add(leftScrollPicker);
|
||
leftCallback_ = new Spo2ScrollPickerCallback();
|
||
leftAnimator_ = new OHOS::Animator(leftCallback_, leftScrollPicker, 1000, true);
|
||
leftCallback_->SetAnimator(leftAnimator_);
|
||
|
||
rightScrollPicker = new Spo2ScrollPicker();
|
||
rightScrollPicker->SetPosition(247, 50);
|
||
rightScrollPicker->SetVisible(false);
|
||
SpO2_container_->Add(rightScrollPicker);
|
||
rightCallback_ = new Spo2ScrollPickerCallback();
|
||
rightAnimator_ = new OHOS::Animator(rightCallback_, rightScrollPicker, 1000, true);
|
||
rightCallback_->SetAnimator(rightAnimator_);
|
||
|
||
unit_ = new UILabel();
|
||
unit_->SetPosition(277, 48);
|
||
unit_->Resize(60, 60);
|
||
unit_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
|
||
unit_->SetText("%");
|
||
unit_->SetFont(TJD_VECTOR_FONT_FILENAME, TJD_FONT_SIZE_48);
|
||
SpO2_container_->Add(unit_);
|
||
unit_->SetVisible(false);
|
||
|
||
/*-----------------------------Add SpO2_Max_ to App------------------------------*/
|
||
SpO2_Max_ = new UILabel();
|
||
SpO2_Max_->SetPosition(144, 358);
|
||
SpO2_Max_->Resize(73, 29);
|
||
SpO2_Max_->SetViewId("SpO2_Max_");
|
||
SpO2_Max_->SetStyle(STYLE_TEXT_FONT, 40);
|
||
if (max == 0) {
|
||
SpO2_Max_->SetText("---");
|
||
} else {
|
||
memset(temp_str, 0, sizeof(temp_str));
|
||
sprintf(temp_str, "%d%%", max);
|
||
SpO2_Max_->SetText(temp_str);
|
||
}
|
||
SpO2_Max_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
|
||
SpO2_Max_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
|
||
SpO2_Max_->SetRollSpeed(0);
|
||
SpO2_Max_->SetFont(TJD_VECTOR_FONT_FILENAME, 40);
|
||
SpO2_container_->Add(SpO2_Max_);
|
||
SpO2_Max_->SetVisible(true);
|
||
|
||
/*-----------------------------Add SpO2_Min_ to App------------------------------*/
|
||
SpO2_Min_ = new UILabel();
|
||
SpO2_Min_->SetPosition(300, 358);
|
||
SpO2_Min_->Resize(72, 29);
|
||
SpO2_Min_->SetViewId("SpO2_Min_");
|
||
SpO2_Min_->SetStyle(STYLE_TEXT_FONT, 40);
|
||
if (min == 0 || min == 100) {
|
||
SpO2_Min_->SetText("---");
|
||
} else {
|
||
memset(temp_str, 0, sizeof(temp_str));
|
||
sprintf(temp_str, "%d%%", min);
|
||
SpO2_Min_->SetText(temp_str);
|
||
}
|
||
SpO2_Min_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
|
||
SpO2_Min_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
|
||
SpO2_Min_->SetRollSpeed(0);
|
||
SpO2_Min_->SetFont(TJD_VECTOR_FONT_FILENAME, 40);
|
||
SpO2_container_->Add(SpO2_Min_);
|
||
SpO2_Min_->SetVisible(true);
|
||
|
||
/*-----------------------------Add dataSerial_ to App------------------------------*/
|
||
dataSerial_ = new UIChartDataSerial();
|
||
dataSerial_->SetMaxDataCount(24);
|
||
|
||
dataSerial_->AddPoints(TjdUiAppSpO2Presenter::GetInstance()->GetSpO2PointArray(), 24);
|
||
dataSerial_->SetLineColor(Color::Red());
|
||
dataSerial_->SetFillColor(Color::Red());
|
||
dataSerial_->EnableGradient(true);
|
||
dataSerial_->EnableSmooth(true);
|
||
|
||
/*-----------------------------Add uiChart1_ to App------------------------------*/
|
||
uiChart1_ = new UIChartPolyline();
|
||
uiChart1_->SetPosition(33, 142);
|
||
uiChart1_->Resize(365, 155);
|
||
uiChart1_->SetViewId("uiChart1");
|
||
uiChart1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
|
||
UIXAxis &xAxis = uiChart1_->GetXAxis();
|
||
UIYAxis &yAxis = uiChart1_->GetYAxis();
|
||
xAxis.SetMarkNum(5); // 5: number of scales
|
||
xAxis.SetDataRange(0, 24); // 0: minimum value, 288: maximum value
|
||
yAxis.SetDataRange(0, 40); // 0: minimum value, 200: maximum value
|
||
yAxis.SetMarkNum(5); // 5: number of scales
|
||
xAxis.SetVisible(false);
|
||
yAxis.SetVisible(false);
|
||
uiChart1_->SetGradientOpacity(25, 127); // 25: min opacity, 127: max opacity
|
||
uiChart1_->AddDataSerial(dataSerial_);
|
||
SpO2_container_->Add(uiChart1_);
|
||
uiChart1_->SetVisible(true);
|
||
/*-----------------------------Add SpO2_container_ to App------------------------------*/
|
||
swipeContainer_->Add(SpO2_container_);
|
||
}
|
||
|
||
void TjdUiAppSpO2View::SpO2AverageViewInit(void)
|
||
{
|
||
WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "_%n\n", __LINE__);
|
||
if (Average_container_ == nullptr) {
|
||
Average_container_ = new UIViewGroup();
|
||
Average_container_->SetPosition(0, 0, OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
||
Average_container_->SetViewId("Average_container_");
|
||
Average_container_->SetStyle(STYLE_BACKGROUND_OPA, 0);
|
||
}
|
||
|
||
/*-----------------------------Add image5_ to Average_container_------------------------------*/
|
||
if (image5_ == nullptr) {
|
||
image5_ = new UIImageView();
|
||
}
|
||
image5_->SetPosition(214, 22);
|
||
image5_->SetViewId("image5");
|
||
ImageInfo *imgInfo = ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_HEARTRATE_PULL_DOWN, HR_IMAGE_BIN_PATH);
|
||
image5_->SetSrc(imgInfo);
|
||
Average_container_->Add(image5_);
|
||
|
||
/*-----------------------------Add image6_ to Average_container_------------------------------*/
|
||
if (image6_ == nullptr) {
|
||
image6_ = new UIImageView();
|
||
}
|
||
image6_->SetPosition(30, 137);
|
||
image6_->SetViewId("image6");
|
||
imgInfo = ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_HEARTRATE_CHART_WEEK, HR_IMAGE_BIN_PATH);
|
||
image6_->SetSrc(imgInfo);
|
||
Average_container_->Add(image6_);
|
||
|
||
/*-----------------------------Add hrText1_ to Average_container_------------------------------*/
|
||
if (SpO2_Text1_ == nullptr) {
|
||
SpO2_Text1_ = new UILabelExt();
|
||
}
|
||
SpO2_Text1_->SetPosition(165, 70);
|
||
SpO2_Text1_->SetViewId("Average_SpO2");
|
||
// SpO2_Text1_->SetText("平均血氧");
|
||
SpO2_Text1_->SetTextId(STR_ID_116);
|
||
SpO2_Text1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
|
||
SpO2_Text1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
|
||
SpO2_Text1_->SetFont(TJD_VECTOR_FONT_FILENAME, 34);
|
||
Average_container_->Add(SpO2_Text1_);
|
||
SpO2_Text1_->SetVisible(true);
|
||
TjdUiUtils::AutoAlignHorizontalCenter(*SpO2_Text1_);
|
||
|
||
/*-----------------------------Add SpO2_Text2_ to Average_container_------------------------------*/
|
||
if (SpO2_Text2_ == nullptr) {
|
||
SpO2_Text2_ = new UILabelExt();
|
||
}
|
||
SpO2_Text2_->SetPosition(0, 375, 466, 37);
|
||
SpO2_Text2_->SetViewId("SpO2_Text2");
|
||
SpO2_Text2_->SetTextId(STR_ID_112);
|
||
// SpO2_Text2_->SetText("近7天数据显示");
|
||
// SpO2_Text2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
|
||
SpO2_Text2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
|
||
SpO2_Text2_->SetFont(TJD_VECTOR_FONT_FILENAME, 28);
|
||
Average_container_->Add(SpO2_Text2_);
|
||
SpO2_Text2_->SetVisible(true);
|
||
|
||
/*-----------------------------Add label2Num100_ to Average_container_------------------------------*/
|
||
if (label2Num100_ == nullptr) {
|
||
label2Num100_ = new UILabel();
|
||
}
|
||
label2Num100_->SetPosition(405, 137);
|
||
label2Num100_->SetViewId("label2Num100");
|
||
label2Num100_->SetText("100");
|
||
label2Num100_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
|
||
label2Num100_->SetTextColor(Color::GetColorFromRGBA(0x6B, 0x6B, 0x6B, 0xff));
|
||
label2Num100_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
|
||
label2Num100_->SetFont(TJD_VECTOR_FONT_FILENAME, TJD_FONT_SIZE_24);
|
||
Average_container_->Add(label2Num100_);
|
||
label2Num100_->SetVisible(true);
|
||
|
||
/*-----------------------------Add label2Num90_ to Average_container_------------------------------*/
|
||
if (label2Num90_ == nullptr) {
|
||
label2Num90_ = new UILabel();
|
||
}
|
||
label2Num90_->SetPosition(405, 177);
|
||
label2Num90_->SetViewId("label2Num90");
|
||
label2Num90_->SetText("90");
|
||
label2Num90_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
|
||
label2Num90_->SetTextColor(Color::GetColorFromRGBA(0x6B, 0x6B, 0x6B, 0xff));
|
||
label2Num90_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
|
||
label2Num90_->SetFont(TJD_VECTOR_FONT_FILENAME, TJD_FONT_SIZE_24);
|
||
Average_container_->Add(label2Num90_);
|
||
label2Num90_->SetVisible(true);
|
||
|
||
/*-----------------------------Add label2Num80_ to Average_container_------------------------------*/
|
||
if (label2Num80_ == nullptr) {
|
||
label2Num80_ = new UILabel();
|
||
}
|
||
label2Num80_->SetPosition(405, 216);
|
||
label2Num80_->SetViewId("label2Num80");
|
||
label2Num80_->SetText("80");
|
||
label2Num80_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
|
||
label2Num80_->SetTextColor(Color::GetColorFromRGBA(0x6B, 0x6B, 0x6B, 0xff));
|
||
label2Num80_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
|
||
label2Num80_->SetFont(TJD_VECTOR_FONT_FILENAME, TJD_FONT_SIZE_24);
|
||
Average_container_->Add(label2Num80_);
|
||
label2Num80_->SetVisible(true);
|
||
|
||
/*-----------------------------Add label2Num70_ to Average_container_------------------------------*/
|
||
if (label2Num70_ == nullptr) {
|
||
label2Num70_ = new UILabel();
|
||
}
|
||
label2Num70_->SetPosition(405, 256);
|
||
label2Num70_->SetViewId("label2Num70");
|
||
label2Num70_->SetText("70");
|
||
label2Num70_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
|
||
label2Num70_->SetTextColor(Color::GetColorFromRGBA(0x6B, 0x6B, 0x6B, 0xff));
|
||
label2Num70_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
|
||
label2Num70_->SetFont(TJD_VECTOR_FONT_FILENAME, TJD_FONT_SIZE_24);
|
||
Average_container_->Add(label2Num70_);
|
||
label2Num70_->SetVisible(true);
|
||
|
||
/*-----------------------------Add rodViewGroup[7] to Average_container_------------------------------*/
|
||
for (int i = 0; i < 7; i++) {
|
||
rodViewGroup[i] = new UIView();
|
||
if (i == 0) {
|
||
rodViewGroup[i]->SetPosition(47 + (6 * 54), rodViewY[i]);
|
||
} else {
|
||
rodViewGroup[i]->SetPosition(47 + ((i - 1) * 54), rodViewY[i]);
|
||
}
|
||
rodViewGroup[i]->Resize(15, rodViewHeight[i]);
|
||
rodViewGroup[i]->SetStyle(STYLE_BORDER_RADIUS, 30);
|
||
rodViewGroup[i]->SetStyle(STYLE_BACKGROUND_COLOR, 0xffff0000);
|
||
Average_container_->Add(rodViewGroup[i]);
|
||
}
|
||
|
||
swipeContainer_->Add(Average_container_);
|
||
}
|
||
|
||
uint8_t TjdUiAppSpO2View::SpO2ValueRodValue(uint8_t SpO2Value)
|
||
{
|
||
if (SpO2Value == 0 || SpO2Value == 100) {
|
||
return 0;
|
||
}
|
||
|
||
return 145 + ((40 - (SpO2Value * 40 / 100)) * 4); // 4 = 160(总长度)/40(范围)
|
||
}
|
||
|
||
void TjdUiAppSpO2View::InitRodViewInfo(void)
|
||
{
|
||
uint8_t SpO2MaxArray[7] = {};
|
||
uint8_t SpO2MinArray[7] = {};
|
||
|
||
for (int i = 0; i < 7; i++) {
|
||
SpO2MaxArray[i] = sql_fit_get_spo2_max(i);
|
||
SpO2MinArray[i] = sql_fit_get_spo2_min(i);
|
||
};
|
||
|
||
for (int j = 0; j < 7; j++) {
|
||
rodViewY[j] = SpO2ValueRodValue(SpO2MaxArray[j]);
|
||
if (SpO2MinArray[j] == SpO2MaxArray[j] && SpO2MinArray[j] != 0)
|
||
rodViewHeight[j] = 1; //当最大最小值相等时,显示一条线
|
||
else
|
||
rodViewHeight[j] = SpO2ValueRodValue(SpO2MinArray[j]) - rodViewY[j];
|
||
printf("%d:%d:%d\n", j, rodViewY[j], rodViewHeight[j]);
|
||
}
|
||
}
|
||
|
||
void TjdUiAppSpO2View::UpdateRodViewGroup(void)
|
||
{
|
||
for (int i = 0; i < 7; i++) {
|
||
if (i == 0) {
|
||
rodViewGroup[i]->SetPosition(47 + (6 * 54), rodViewY[i]);
|
||
rodViewGroup[i]->Resize(15, rodViewHeight[i]);
|
||
} else {
|
||
rodViewGroup[i]->SetPosition(47 + ((i - 1) * 54), rodViewY[i]);
|
||
rodViewGroup[i]->Resize(15, rodViewHeight[i]);
|
||
}
|
||
|
||
rodViewGroup[i]->Invalidate();
|
||
}
|
||
}
|
||
|
||
void TjdUiAppSpO2View::SpO2RemindViewInit(void)
|
||
{
|
||
WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "_%n\n", __LINE__);
|
||
if (RemindView_ == nullptr) {
|
||
RemindView_ = new UIViewGroup();
|
||
RemindView_->SetPosition(0, 0, OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
||
RemindView_->SetVisible(false);
|
||
RemindView_->SetStyle(STYLE_BACKGROUND_OPA, 0);
|
||
}
|
||
|
||
/*-----------------------------Add aboutText to RemindView------------------------------*/
|
||
if (remindText == nullptr) {
|
||
remindText = new UILabelExt();
|
||
}
|
||
remindText->SetViewId("remindText");
|
||
// remindText->SetText("手表仅显示5分钟内最新的血氧数据,更多数据请前往APP连接后查看");
|
||
remindText->SetTextId(STR_ID_115);
|
||
remindText->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
|
||
remindText->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
|
||
remindText->SetFont(TJD_VECTOR_FONT_FILENAME, 34);
|
||
if (TjdUiMultiLanguageExt::GetCurrentLanguage() == LANGUAGE_ID_CHS)
|
||
remindText->SetPosition(31, 152, 405, 128);
|
||
else
|
||
remindText->SetPosition(31, 86, 405, 128);
|
||
|
||
/*-----------------------------Add remindImg to RemindView------------------------------*/
|
||
if (remindImg == nullptr) {
|
||
remindImg = new UIImageView();
|
||
}
|
||
remindImg->SetPosition(187, 352);
|
||
remindImg->SetViewId(REMIND_IMAGE_RETURN_ID);
|
||
ImageInfo *imgInfo =
|
||
ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_RETURN_IMG_RETURN, IMAGE_RETURN_BIN_PATH);
|
||
if (imgInfo != nullptr) {
|
||
remindImg->SetSrc(imgInfo);
|
||
}
|
||
remindImg->SetTouchable(true);
|
||
imgRemindListener_ = new TjdUiAppSpO2OnClickedListener();
|
||
remindImg->SetOnClickListener(imgRemindListener_);
|
||
|
||
RemindView_->Add(remindText);
|
||
RemindView_->Add(remindImg);
|
||
}
|
||
|
||
void TjdUiAppSpO2View::SpO2UnwearViewInit(void)
|
||
{
|
||
WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "_%n\n", __LINE__);
|
||
if (UnwearView_ == nullptr) {
|
||
UnwearView_ = new UIViewGroup();
|
||
UnwearView_->SetPosition(0, 0, OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
||
UnwearView_->SetVisible(false);
|
||
UnwearView_->SetStyle(STYLE_BACKGROUND_OPA, 0);
|
||
}
|
||
|
||
/*-----------------------------Add unwearText1 to UnwearView_------------------------------*/
|
||
if (unwearText1 == nullptr) {
|
||
unwearText1 = new UILabelExt();
|
||
}
|
||
unwearText1->SetPosition(155, 224);
|
||
unwearText1->SetViewId("unwearText1");
|
||
// unwearText1->SetText("监测到脱腕");
|
||
unwearText1->SetTextId(STR_ID_113);
|
||
unwearText1->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
|
||
unwearText1->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
|
||
unwearText1->SetFont(TJD_VECTOR_FONT_FILENAME, 36);
|
||
TjdUiUtils::AutoAlignHorizontalCenter(*unwearText1);
|
||
|
||
/*-----------------------------Add unwearText2 to UnwearView_------------------------------*/
|
||
if (unwearText2 == nullptr) {
|
||
unwearText2 = new UILabelExt();
|
||
}
|
||
unwearText2->SetPosition(0, 272, 466, 47);
|
||
unwearText2->SetViewId("unwearText2");
|
||
unwearText2->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
|
||
unwearText2->SetStyle(STYLE_TEXT_OPA, 0xff * 0.3);
|
||
unwearText2->SetFont(TJD_VECTOR_FONT_FILENAME, 36);
|
||
unwearText2->SetTextId(STR_ID_114);
|
||
// unwearText2->SetText("请偏紧佩戴手表测量!");
|
||
unwearText2->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
|
||
unwearText2->SetRollSpeed(30);
|
||
|
||
/*-----------------------------Add unwearImg1 to UnwearView_------------------------------*/
|
||
if (unwearImg1 == nullptr) {
|
||
unwearImg1 = new UIImageView();
|
||
}
|
||
unwearImg1->SetPosition(187, 352);
|
||
unwearImg1->SetViewId(UNWEAR_IMAGE_RETURN_ID);
|
||
ImageInfo *imgInfo =
|
||
ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_RETURN_IMG_RETURN, IMAGE_RETURN_BIN_PATH);
|
||
if (imgInfo != nullptr) {
|
||
unwearImg1->SetSrc(imgInfo);
|
||
}
|
||
unwearImg1->SetTouchable(true);
|
||
imgUnwearListener_ = new TjdUiAppSpO2OnClickedListener();
|
||
unwearImg1->SetOnClickListener(imgUnwearListener_);
|
||
|
||
/*-----------------------------Add unwearImg2 to UnwearView_------------------------------*/
|
||
if (unwearImg2 == nullptr) {
|
||
unwearImg2 = new UIImageView();
|
||
}
|
||
unwearImg2->SetPosition(155, 119);
|
||
unwearImg2->SetViewId("unwearImg2");
|
||
imgInfo = ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_HEARTRATE_REMIND, HR_IMAGE_BIN_PATH);
|
||
if (imgInfo != nullptr) {
|
||
unwearImg2->SetSrc(imgInfo);
|
||
}
|
||
|
||
UnwearView_->Add(unwearText1);
|
||
UnwearView_->Add(unwearText2);
|
||
UnwearView_->Add(unwearImg1);
|
||
UnwearView_->Add(unwearImg2);
|
||
}
|
||
|
||
void TjdUiAppSpO2View::ChangedView(SpO2View view, SpO2View hideView)
|
||
{
|
||
if (view >= SPO2MAX_VIEW) {
|
||
return;
|
||
}
|
||
if (viewMapper_[view] == nullptr) {
|
||
return;
|
||
}
|
||
|
||
(GetInstance()->*viewMapper_[view])(hideView);
|
||
}
|
||
|
||
bool TjdUiAppSpO2View::ShowSwipeView(SpO2View hideView)
|
||
{
|
||
if (groupList_[hideView] == nullptr) {
|
||
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "groupList_ is nullptr");
|
||
return false;
|
||
}
|
||
groupList_[hideView]->SetVisible(false);
|
||
|
||
if (groupList_[SpO2View::SPO2SWIPE_VIEW] == nullptr) {
|
||
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "groupList_ is nullptr");
|
||
return false;
|
||
}
|
||
groupList_[SpO2View::SPO2SWIPE_VIEW]->SetVisible(true);
|
||
groupList_[SpO2View::SPO2SWIPE_VIEW]->Invalidate();
|
||
|
||
curView = SPO2SWIPE_VIEW;
|
||
return true;
|
||
}
|
||
|
||
bool TjdUiAppSpO2View::ShowRemindView(SpO2View hideView)
|
||
{
|
||
if (groupList_[hideView] == nullptr) {
|
||
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "groupList_ is nullptr");
|
||
return false;
|
||
}
|
||
groupList_[hideView]->SetVisible(false);
|
||
|
||
if (groupList_[SpO2View::SPO2REMIND_VIEW] == nullptr) {
|
||
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "groupList_ is nullptr");
|
||
return false;
|
||
}
|
||
groupList_[SpO2View::SPO2REMIND_VIEW]->SetVisible(true);
|
||
groupList_[SpO2View::SPO2REMIND_VIEW]->Invalidate();
|
||
|
||
curView = SPO2REMIND_VIEW;
|
||
return true;
|
||
}
|
||
|
||
bool TjdUiAppSpO2View::ShowUnwearView(SpO2View hideView)
|
||
{
|
||
if (groupList_[hideView] == nullptr) {
|
||
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "groupList_ is nullptr");
|
||
return false;
|
||
}
|
||
groupList_[hideView]->SetVisible(false);
|
||
|
||
if (groupList_[SpO2View::SPO2UNWEAR_VIEW] == nullptr) {
|
||
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "groupList_ is nullptr");
|
||
return false;
|
||
}
|
||
groupList_[SpO2View::SPO2UNWEAR_VIEW]->SetVisible(true);
|
||
groupList_[SpO2View::SPO2UNWEAR_VIEW]->Invalidate();
|
||
|
||
curView = SPO2UNWEAR_VIEW;
|
||
return true;
|
||
}
|
||
|
||
void TjdUiAppSpO2View::UpdateSpO2ViewData(uint32_t index, uint8_t SpO2Value)
|
||
{
|
||
char tempSpO2Value[10] = {0};
|
||
if (SpO2Value == 0) {
|
||
SetScrollPickerVisible(false);
|
||
SpO2_Cur_->SetText("---");
|
||
} else {
|
||
memset(tempSpO2Value, 0, sizeof(tempSpO2Value));
|
||
sprintf(tempSpO2Value, "%d%%", SpO2Value);
|
||
if (tempSpO2Value != SpO2_Cur_->GetText()) {
|
||
SpO2_Cur_->SetVisible(false);
|
||
SpO2_Cur_->SetText(tempSpO2Value);
|
||
SetScrollPickerVisible(true);
|
||
|
||
if (!leftCallback_->GetState()) {
|
||
uint8_t leftValue = SpO2Value / 10;
|
||
if (leftScrollPicker->CheckValueChanges(leftValue)) {
|
||
leftAnimator_->Start();
|
||
}
|
||
}
|
||
|
||
if (!rightCallback_->GetState()) {
|
||
uint8_t rightValue = SpO2Value % 10;
|
||
if (rightScrollPicker->CheckValueChanges(rightValue)) {
|
||
rightAnimator_->Start();
|
||
}
|
||
|
||
rightAnimator_->Start();
|
||
}
|
||
|
||
Point curPoint = {index, SpO2Value * 39 / 100};
|
||
dataSerial_->ModifyPoint(index, curPoint);
|
||
uiChart1_->RefreshChart();
|
||
}
|
||
}
|
||
|
||
if (SpO2Value != 0) {
|
||
char temp_str[10] = {0};
|
||
memset(tempSpO2Value, 0, sizeof(tempSpO2Value));
|
||
sprintf(tempSpO2Value, "%d%%", SpO2Value);
|
||
memcpy(temp_str, SpO2_Max_->GetText(), 2);
|
||
if (SpO2_Max_->GetText() != std::string("---")) {
|
||
if (SpO2Value > std::stoi(temp_str)) {
|
||
SpO2_Max_->SetText(tempSpO2Value);
|
||
SpO2_Max_->Invalidate();
|
||
}
|
||
} else {
|
||
SpO2_Max_->SetText(tempSpO2Value);
|
||
SpO2_Max_->Invalidate();
|
||
}
|
||
|
||
if (SpO2_Min_->GetText() != std::string("---")) {
|
||
memset(tempSpO2Value, 0, sizeof(tempSpO2Value));
|
||
memset(temp_str, 0, sizeof(temp_str));
|
||
sprintf(tempSpO2Value, "%d%%", SpO2Value);
|
||
memcpy(temp_str, SpO2_Min_->GetText(), 2);
|
||
if (SpO2Value < std::stoi(temp_str)) {
|
||
SpO2_Min_->SetText(tempSpO2Value);
|
||
SpO2_Min_->Invalidate();
|
||
}
|
||
} else {
|
||
SpO2_Min_->SetText(tempSpO2Value);
|
||
SpO2_Min_->Invalidate();
|
||
}
|
||
}
|
||
}
|
||
|
||
UIImageAnimatorView *TjdUiAppSpO2View::GetAnimatorView(void) { return imageAnimator_; }
|
||
|
||
} // namespace TJD
|