1774 lines
68 KiB
C++
1774 lines
68 KiB
C++
#include "TjdUiAppSportPage.h"
|
||
#include "TjdUiAppSportDrawGuiAPI.h"
|
||
#include "TjdUiAppSportPresenter.h"
|
||
#include "TjdUiAppSportView.h"
|
||
#include "TjdUiImageIds.h"
|
||
#include "TjdUiMultiLanguageExt.h"
|
||
#include "TjdUiUtils.h"
|
||
#include "common/image_cache_manager.h"
|
||
#include "debug_print.h"
|
||
#include "graphic_math.h"
|
||
#include "graphic_service.h"
|
||
#include "motor.h"
|
||
#include "notification_manager.h"
|
||
#include "service_sport.h"
|
||
#include "sql_fit.h"
|
||
#include "sql_setting.h"
|
||
#include "sys_config.h"
|
||
#include <iomanip>
|
||
#include <sstream>
|
||
#include <stdio.h>
|
||
|
||
#define ENABLE_PRINT_INFO 1
|
||
#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__) // 错误信息打印一般常开
|
||
#define static_print_debug(...) sys_ui_log_d(__VA_ARGS__) // 调试信息打印
|
||
#else
|
||
#define static_print_info(...)
|
||
#define static_print_warn(...)
|
||
#define static_print_error(...)
|
||
#define static_print_debug(...)
|
||
#endif
|
||
|
||
#define SPORT_IMAGE_BIN_PATH TJD_IMAGE_PATH "img_sport.bin"
|
||
#define CONFIRM_CANCEL_RES_BIN_PATH TJD_IMAGE_PATH "img_confirm_cancel.bin"
|
||
|
||
using namespace OHOS;
|
||
|
||
namespace TJD {
|
||
// clang-format off
|
||
static OHOS::GraphicTimer *popupTimer_ = nullptr; // 弹窗定时器
|
||
static OHOS::GraphicTimer *finishTimer_ = nullptr; // 弹窗定时器
|
||
static SportGoalSelectView *g_pv_SportGoalSelectView = nullptr;
|
||
static CommonViewGoalPage *g_pv_CommonViewGoalPage = nullptr;
|
||
static RemindGoalListView *g_pv_RemindGoalListView = nullptr;
|
||
static DistnaceGoalSelectView *g_pv_DistnaceGoalSelectView = nullptr;
|
||
static CaloriesGoalSelectView *g_pv_CaloriesGoalSelectView = nullptr;
|
||
uint8_t DistanceRemindPickView::curSelectDistanceIndex = PER_1000_METERS_INDEX;
|
||
uint8_t TimeRemindPickView::curSelectTimeIndex = PER_THIRTY_MIN_INDEX;
|
||
uint8_t CommonViewGoalPage::CurSelectGoalView = MAX_SELECT_VIEW_INDEX;
|
||
static int16_t HorizontalCenter(int16_t width) { return (OHOS::HORIZONTAL_RESOLUTION - width) / 2; }
|
||
|
||
#pragma region 运动设置主界面(运动目标页)
|
||
static const char *distUiPickerData[] = {
|
||
"500m", "1000m", "1500m", "2000m", "2500m", "3000m", "3500m", "4000m",
|
||
"4500m", "5000m", "5500m", "6000m", "6500m", "7000m", "7500m", "8000m",
|
||
"8500m", "9000m", "9500m", "10000m", "10500m", "11000m", "11500m", "12000m",
|
||
"12500m", "13000m", "13500m", "14000m", "14500m", "15000m"
|
||
};
|
||
|
||
static const char *caloriesUiPickerData[] = {
|
||
"50", "100", "150", "200", "250", "300", "350", "400", "450", "500", "550", "600", "650", "700",
|
||
"750", "800", "850", "900", "950", "1000", "1050", "1100", "1150", "1200", "1250", "1300", "1350", "1400",
|
||
"1450", "1500", "1550", "1600", "1650", "1700", "1750", "1800", "1850", "1900", "1950", "2000",
|
||
};
|
||
|
||
// clang-format off
|
||
GoalSelectViewInfo g_pv_CommonViewItemInfo[][2] = {
|
||
{{static_cast<GoalSelectView>(GOAL_SELECT_ITEM), IMG_SPORT_INDOOR_DIS, STR_ID_209, STR_ID_596, "distItemGoals"},
|
||
{static_cast<GoalSelectView>(REMIND_SELECT_ITEM), IMG_SPORT_ICON_REMIND, STR_ID_229, STR_ID_595,
|
||
"distItemReminds"}},
|
||
|
||
{{static_cast<GoalSelectView>(GOAL_SELECT_ITEM), IMG_SPORT_INDOOR_TIME, STR_ID_594, STR_ID_597, "timeItemGoals"},//时间
|
||
{static_cast<GoalSelectView>(REMIND_SELECT_ITEM), IMG_SPORT_ICON_REMIND, STR_ID_229, STR_ID_595,
|
||
"timeItemReminds"}},
|
||
|
||
{{static_cast<GoalSelectView>(GOAL_SELECT_ITEM), IMG_SPORT_INDOOR_KCAL, STR_ID_201, STR_ID_598, "CaloriesItemGoals"},
|
||
{static_cast<GoalSelectView>(REMIND_SELECT_ITEM), IMG_SPORT_ICON_REMIND, STR_ID_229, STR_ID_595,
|
||
"CaloriesItemReminds"}},
|
||
|
||
{{static_cast<GoalSelectView>(GOAL_SELECT_ITEM), IMG_SPORT_INDOOR_TARGET, STR_ID_208, STR_ID_208,
|
||
"FreeTrainItemGoals"},
|
||
{static_cast<GoalSelectView>(REMIND_SELECT_ITEM), IMG_SPORT_ICON_REMIND, STR_ID_229, STR_ID_595,
|
||
"FreeTrainItemReminds"}},
|
||
|
||
};
|
||
|
||
GoalSelectViewInfo g_pv_GoalSelect[] = {
|
||
{DISTANCE_SELECT_VIEW,IMG_SPORT_INDOOR_DIS, STR_ID_209, STR_ID_596, "distanceSelect" },
|
||
{TIME_SELECT_VIEW,IMG_SPORT_INDOOR_TIME, STR_ID_594, STR_ID_597, "timeSelect" },//时间
|
||
{CALORIES_SELECT_VIEW,IMG_SPORT_INDOOR_KCAL, STR_ID_201, STR_ID_598, "caloriesSelect" },
|
||
{FREE_TRAINING_SELECT_VIEW,IMG_SPORT_INDOOR_TARGET,STR_ID_208, STR_ID_597, "freeTrainingSelect" },
|
||
};
|
||
|
||
RemindItemInfo g_pv_CommonRemindGoalList[] = {
|
||
{HEART_RATE_INDEX, IMG_SPORT_HR_DESC, STR_ID_00, STR_ID_217, "heartRatePick"},
|
||
{TIME_INDEX, IMG_SPORT_INDOOR_TIME, STR_ID_594, STR_ID_220, "timePick"},
|
||
{ONCE_INDEX, IMG_SPORT_DIN, STR_ID_599, STR_ID_225, "distPick"},
|
||
};
|
||
|
||
HeartRateItemInfo g_pv_HeartRateItemInfo[] = {
|
||
{FIRAT_SECTOR_INDEX,IMG_SPORT_ONE, STR_ID_600, STR_ID_110},
|
||
{SECOND_SECTOR_INDEX,IMG_SPORT_TWO, STR_ID_601, STR_ID_110},
|
||
{THREE_SECTOR_INDEX,IMG_SPORT_THREE, STR_ID_602, STR_ID_110},
|
||
{FOUR_SECTOR_INDEX,IMG_SPORT_FOUR, STR_ID_603, STR_ID_110},
|
||
{NONE_SECTOR_INDEX,IMG_SPORT_TWO, STR_ID_217, STR_ID_110},
|
||
};
|
||
|
||
TimeOrDistRemindItemInfo g_pv_TimeRemindItemInfo[] = {
|
||
{PER_TEN_MIN_INDEX, STR_ID_218, 0},
|
||
{PER_TWENTY_MIN_INDEX, STR_ID_219, 0},
|
||
{PER_THIRTY_MIN_INDEX, STR_ID_220, 0},
|
||
{PER_FORTY_MIN_INDEX, STR_ID_221, 0},
|
||
{PER_FIFTY_MIN_INDEX, STR_ID_222, 0},
|
||
{PER_SIXTY_MIN_INDEX, STR_ID_223, 0},
|
||
{UNSELECT_MIN_INDEX, STR_ID_217, 0},
|
||
};
|
||
|
||
TimeOrDistRemindItemInfo g_pv_DistanceRemindItemInfo[] = {
|
||
{ PER_500_METERS_INDEX, STR_ID_224, 1},
|
||
{ PER_1000_METERS_INDEX, STR_ID_225, 1},
|
||
{ PER_2000_METERS_INDEX, STR_ID_226, 1},
|
||
{ PER_3000_METERS_INDEX, STR_ID_227, 1},
|
||
{ PER_5000_METERS_INDEX, STR_ID_228, 1},
|
||
{ UNSELECT_DISTANCE_INDEX, STR_ID_217, 1},
|
||
};
|
||
// clang-format on
|
||
static inline int16_t CalculateBottomHidePos(OHOS::UIView &screenBottomView)
|
||
{
|
||
const int16_t lastItemBottom = screenBottomView.GetY() + screenBottomView.GetHeight();
|
||
return (lastItemBottom + (OHOS::VERTICAL_RESOLUTION / 2) - (screenBottomView.GetHeight() / 2));
|
||
}
|
||
|
||
bool ItemViewOnclickListener::OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event)
|
||
{
|
||
printf("ItemViewOnclickListener::OnClick id = %s\n", view.GetViewId());
|
||
auto sportView = TjdUiAppSportView::GetInstance();
|
||
// auto iconIndex = sportView->currentIconIndex_;
|
||
if (view.GetViewId() == "distanceSelect") {
|
||
sportView->ShowTargetView(SPORT_GOAL_DISTANCES_VIEW, static_cast<uint8_t>(DISTANCE_SELECT_VIEW));
|
||
} else if (view.GetViewId() == "timeSelect") {
|
||
sportView->ShowTargetView(SPORT_GOAL_TIME_VIEW, static_cast<uint8_t>(TIME_SELECT_VIEW));
|
||
} else if (view.GetViewId() == "caloriesSelect") {
|
||
sportView->ShowTargetView(SPORT_GOAL_CALORIES_VIEW, static_cast<uint8_t>(CALORIES_SELECT_VIEW));
|
||
} else if (view.GetViewId() == "freeTrainingSelect") {
|
||
CommonViewGoalPage::CurSelectGoalView = FREE_TRAINING_SELECT_VIEW;
|
||
sportView->ShowTargetView(SPORT_GOAL_FREE_TRAINING_VIEW, static_cast<uint8_t>(FREE_TRAINING_SELECT_VIEW));
|
||
}
|
||
|
||
return true;
|
||
}
|
||
#pragma endregion
|
||
|
||
#pragma region 室外运动列表页
|
||
OHOS::UIView *SportGoalSelectAdapter::GetView(OHOS::UIView *inView, int16_t index)
|
||
{
|
||
std::list<GoalSelectViewInfo> *ItemList_ = SportGoalSelectView::GetInstance()->ItemList_;
|
||
|
||
if (ItemList_->empty() || index > ItemList_->size() - 1 || index < 0) {
|
||
return nullptr;
|
||
}
|
||
|
||
auto node = ItemList_->begin();
|
||
std::advance(node, index);
|
||
|
||
if (inView == nullptr) {
|
||
itemView_ = new ItemView(*node, index);
|
||
} else {
|
||
itemView_ = static_cast<ItemView *>(inView);
|
||
}
|
||
|
||
itemView_->UpdateView(*node, index);
|
||
return itemView_;
|
||
}
|
||
|
||
uint16_t SportGoalSelectAdapter::GetCount() { return SportGoalSelectView::GetInstance()->ItemList_->size(); }
|
||
|
||
SportGoalSelectAdapter::~SportGoalSelectAdapter()
|
||
{
|
||
if (itemView_ != nullptr) {
|
||
delete itemView_;
|
||
itemView_ = nullptr;
|
||
}
|
||
}
|
||
|
||
ItemView::ItemView(GoalSelectViewInfo &info, uint8_t i)
|
||
{
|
||
auto image = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(info.imgIconResId, SPORT_IMAGE_BIN_PATH);
|
||
bool ifLastItem = (i == INTDOOR_MAX_INDEX) ? true : false;
|
||
SetPosition(0, 0, 450, 128);
|
||
SetStyle(OHOS::STYLE_BACKGROUND_COLOR, 0xff202020);
|
||
SetStyle(OHOS::STYLE_BORDER_RADIUS, 55);
|
||
SetViewIndex(info.index);
|
||
|
||
icon_.SetPosition(18, 13, 92, 92);
|
||
if (image != nullptr) {
|
||
icon_.SetSrc(image);
|
||
}
|
||
|
||
name_.SetPosition(0, 14 + ifLastItem * 22, 450, 56);
|
||
name_.SetFont(TJD_VECTOR_FONT_FILENAME, 42);
|
||
// name_.SetText(info.name);
|
||
// name_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_ADAPT);
|
||
name_.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
||
printf("name_ height = %d\n", name_.GetHeight());
|
||
|
||
if (i < INTDOOR_MAX_INDEX) {
|
||
goal_.SetPosition(0, 73, 450, 40);
|
||
goal_.SetFont(TJD_VECTOR_FONT_FILENAME, 30);
|
||
goal_.SetTextId(info.goalId);
|
||
goal_.SetStyle(STYLE_TEXT_OPA, 0xff * 0.2);
|
||
// goal_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_ADAPT);
|
||
goal_.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
||
printf("goal_ height = %d\n", goal_.GetHeight());
|
||
}
|
||
|
||
image = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_SPORT_INDOOR_MORE, SPORT_IMAGE_BIN_PATH);
|
||
moreIcon_.SetPosition(401, 52, 14, 24);
|
||
if (image != nullptr) {
|
||
moreIcon_.SetSrc(image);
|
||
}
|
||
|
||
SetTouchable(true);
|
||
SetOnClickListener(&itemViewOnclickListener);
|
||
|
||
Add(&icon_);
|
||
Add(&name_);
|
||
Add(&goal_);
|
||
Add(&moreIcon_);
|
||
}
|
||
|
||
void ItemView::UpdateView(GoalSelectViewInfo &info, uint8_t index)
|
||
{
|
||
SetVisible(true);
|
||
SetViewIndex(index);
|
||
SetViewId(info.itemId);
|
||
auto image = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(info.imgIconResId, SPORT_IMAGE_BIN_PATH);
|
||
if (image != nullptr) {
|
||
icon_.SetSrc(image);
|
||
}
|
||
|
||
bool ifLastItem = (index == INTDOOR_FREE_TRAINING_INDEX) ? true : false;
|
||
printf("UpdateView index = %d, ifLastItem = %d\n", index, ifLastItem);
|
||
name_.SetTextId(info.nameId);
|
||
name_.SetY(14 + ifLastItem * 22);
|
||
|
||
switch (info.index) {
|
||
case INTDOOR_DISTANCE_INDEX:
|
||
goal_.SetText(g_pv_SportGoal[TjdUiAppSportView::currentIconIndex_].distGoal.c_str());
|
||
break;
|
||
case INTDOOR_TIME_INDEX:
|
||
printf("line = %d=====g_pv_SportGoal[%d].timeGoal=%s\n", __LINE__, TjdUiAppSportView::currentIconIndex_,
|
||
g_pv_SportGoal[index].timeGoal.c_str());
|
||
goal_.SetText(g_pv_SportGoal[TjdUiAppSportView::currentIconIndex_].timeGoal.c_str());
|
||
break;
|
||
case INTDOOR_CALORIES_INDEX:
|
||
printf("line = %d=====g_pv_SportGoal[%d].caloriesGoal=%s\n", __LINE__, TjdUiAppSportView::currentIconIndex_,
|
||
g_pv_SportGoal[index].caloriesGoal.c_str());
|
||
goal_.SetText(g_pv_SportGoal[TjdUiAppSportView::currentIconIndex_].caloriesGoal.c_str());
|
||
break;
|
||
case INTDOOR_FREE_TRAINING_INDEX:
|
||
goal_.SetText("");
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
// goal_.SetPosition(HorizontalCenter(goal_.GetWidth()), 74);
|
||
|
||
image = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_SPORT_INDOOR_MORE, SPORT_IMAGE_BIN_PATH);
|
||
if (image != nullptr) {
|
||
moreIcon_.SetSrc(image);
|
||
}
|
||
}
|
||
|
||
SportGoalSelectAdapter *sportGoalSelectAdapter_{nullptr};
|
||
SportGoalSelectView::SportGoalSelectView()
|
||
{
|
||
InitList();
|
||
g_pv_SportGoalSelectView = this;
|
||
SetPosition(0, 0, OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
||
SetDraggable(true);
|
||
SetOnDragListener(TjdUiAppSportPresenter::GetInstance());
|
||
|
||
mainTitle_.SetPosition(0, 17, 466, 37);
|
||
mainTitle_.SetFont(TJD_VECTOR_FONT_FILENAME, 28);
|
||
mainTitle_.SetText("室外运动");
|
||
// mainTitle_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_ADAPT);
|
||
mainTitle_.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
||
|
||
if (sportGoalSelectList_ == nullptr) {
|
||
sportGoalSelectList_ = new UITransformList();
|
||
}
|
||
|
||
if (sportGoalSelectAdapter_ == nullptr) {
|
||
sportGoalSelectAdapter_ = new SportGoalSelectAdapter();
|
||
}
|
||
|
||
sportGoalSelectList_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
|
||
sportGoalSelectList_->SetItemTransformFunc(&TransformItemBaseOnPosition);
|
||
sportGoalSelectList_->SetAdapter(sportGoalSelectAdapter_);
|
||
sportGoalSelectList_->SetThrowDrag(true);
|
||
sportGoalSelectList_->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
|
||
// sportGoalSelectList_->SetMaxScrollDistance(1000); // 1000: max scroll distance
|
||
// sportGoalSelectList_->SetSwipeACCLevel(800); // 800: compensation distance
|
||
sportGoalSelectList_->SetDragACCLevel(5); // 5: drag acceleration
|
||
sportGoalSelectList_->SetYScrollBarVisible(true);
|
||
sportGoalSelectList_->SetReboundSize((VERTICAL_RESOLUTION - 120) / 2);
|
||
sportGoalSelectList_->ScrollBy(60);
|
||
sportGoalSelectList_->SetScrollBlankSize((VERTICAL_RESOLUTION - 120) / 2);
|
||
sportGoalSelectList_->SetSelectPosition(VERTICAL_RESOLUTION / 2);
|
||
sportGoalSelectList_->SetRotateFactor(-10);
|
||
sportGoalSelectList_->SetRotateThreshold(8);
|
||
// listScrollListener.SetSource(sportGoalSelectList_, &mainTitle_);
|
||
// sportGoalSelectList_->SetScrollStateListener(&listScrollListener);
|
||
|
||
Add(&mainTitle_);
|
||
Add(sportGoalSelectList_);
|
||
// Add(&hide_);
|
||
}
|
||
|
||
void SportGoalSelectView::ReMeasure()
|
||
{
|
||
if (sportGoalSelectList_ == nullptr || mainTitle_.GetText() == nullptr) {
|
||
return;
|
||
}
|
||
const OHOS::UIView *head = sportGoalSelectList_->GetChildrenHead();
|
||
if (head == nullptr) {
|
||
return;
|
||
}
|
||
const int16_t scrollDistance = head->GetRect().GetTop();
|
||
if (head->GetViewIndex() == 0) {
|
||
OHOS::Vector2<int16_t> trans = {0, scrollDistance - mainTitle_.GetHeight() - 32};
|
||
mainTitle_.Translate(trans);
|
||
mainTitle_.SetVisible(true);
|
||
} else {
|
||
mainTitle_.SetVisible(false);
|
||
}
|
||
|
||
/* 标题渐进透明度 */
|
||
int16_t titleTop = -mainTitle_.GetRect().GetTop();
|
||
if (titleTop < 0) {
|
||
titleTop = 0;
|
||
}
|
||
mainTitle_.SetStyle(OHOS::STYLE_TEXT_OPA, EasingEquation::QuintEaseOut(OHOS::OPA_OPAQUE, OHOS::OPA_TRANSPARENT,
|
||
titleTop, mainTitle_.GetHeight()));
|
||
}
|
||
|
||
void SportGoalSelectView::InitList()
|
||
{
|
||
auto &image = OHOS::ImageCacheManager::GetInstance();
|
||
|
||
if (ItemList_ == nullptr) {
|
||
ItemList_ = new std::list<GoalSelectViewInfo>();
|
||
}
|
||
ItemList_->clear();
|
||
|
||
for (uint8_t i = 0; i < MAX_SELECT_VIEW_INDEX; i++) {
|
||
imgItemInfo[i] = image.LoadOneInMultiRes(g_pv_GoalSelect[i].imgIconResId, SPORT_IMAGE_BIN_PATH);
|
||
ItemList_->push_back({g_pv_GoalSelect[i].index, g_pv_GoalSelect[i].imgIconResId, g_pv_GoalSelect[i].nameId,
|
||
g_pv_GoalSelect[i].goalId, g_pv_GoalSelect[i].itemId});
|
||
}
|
||
}
|
||
|
||
SportGoalSelectView *SportGoalSelectView::GetInstance() { return g_pv_SportGoalSelectView; }
|
||
|
||
void SportGoalSelectView::SportGoalSelectViewRefresh()
|
||
{
|
||
|
||
auto index = TjdUiAppSportView::currentIconIndex_;
|
||
mainTitle_.SetTextId(g_pv_Sport[index].sportTypeId);
|
||
int16_t startY = 17 + mainTitle_.GetHeight() + 8;
|
||
int16_t interval = 8;
|
||
|
||
switch (index) {
|
||
case SPORT_TYPE_01_OUTDOOR_RUNNING_INDEX:
|
||
case SPORT_TYPE_02_OUTDOOR_WALKING_INDEX:
|
||
case SPORT_TYPE_04_FOOTBALL_INDEX:
|
||
case SPORT_TYPE_05_BASKETBALL_INDEX:
|
||
case SPORT_TYPE_12_ON_FOOT_INDEX:
|
||
case SPORT_TYPE_13_STAIRCASE_INDEX:
|
||
|
||
case SPORT_TYPE_09_INDOOR_SWIMMI_INDEX:
|
||
case SPORT_TYPE_10_OUTDOOR_SWIMM_INDEX:
|
||
case SPORT_TYPE_11_CYCLING_INDEX:
|
||
case SPORT_TYPE_51_RIDING_INDEX ... SPORT_TYPE_57_MOTORBOAT_INDEX:
|
||
ifDistance = true;
|
||
break;
|
||
default:
|
||
ifDistance = false;
|
||
break;
|
||
}
|
||
|
||
ItemList_->clear();
|
||
auto &image = OHOS::ImageCacheManager::GetInstance();
|
||
if (ifDistance) {
|
||
for (uint8_t i = 0; i < MAX_SELECT_VIEW_INDEX; i++) {
|
||
imgItemInfo[i] = image.LoadOneInMultiRes(g_pv_GoalSelect[i].imgIconResId, SPORT_IMAGE_BIN_PATH);
|
||
ItemList_->push_back({g_pv_GoalSelect[i].index, g_pv_GoalSelect[i].imgIconResId, g_pv_GoalSelect[i].nameId,
|
||
g_pv_GoalSelect[i].goalId, g_pv_GoalSelect[i].itemId});
|
||
}
|
||
|
||
} else {
|
||
for (uint8_t i = 1; i < MAX_SELECT_VIEW_INDEX; i++) {
|
||
imgItemInfo[i] = image.LoadOneInMultiRes(g_pv_GoalSelect[i].imgIconResId, SPORT_IMAGE_BIN_PATH);
|
||
ItemList_->push_back({g_pv_GoalSelect[i].index, g_pv_GoalSelect[i].imgIconResId, g_pv_GoalSelect[i].nameId,
|
||
g_pv_GoalSelect[i].goalId, g_pv_GoalSelect[i].itemId});
|
||
}
|
||
}
|
||
sportGoalSelectList_->RefreshList();
|
||
Invalidate();
|
||
}
|
||
|
||
void SportGoalSelectView::HideView()
|
||
{
|
||
// SportList::GetInstance()->customSportList_->RefreshList();
|
||
SetVisible(false);
|
||
}
|
||
|
||
void SportGoalSelectView::SetListTitleVisible(bool visible)
|
||
{
|
||
if (visible)
|
||
sportGoalSelectList_->SetVisible(true);
|
||
else
|
||
sportGoalSelectList_->SetVisible(false);
|
||
}
|
||
|
||
void SportGoalSelectView::ShowView()
|
||
{
|
||
SportGoalSelectViewRefresh();
|
||
OHOS::FocusManager::GetInstance()->ClearFocus();
|
||
sportGoalSelectList_->RequestFocus();
|
||
SetVisible(true);
|
||
}
|
||
|
||
SportGoalSelectView::~SportGoalSelectView()
|
||
{
|
||
ifDistance = false;
|
||
g_pv_SportGoalSelectView = nullptr;
|
||
RemoveAll();
|
||
for (int i = 0; i < MAX_SELECT_VIEW_INDEX; ++i) {
|
||
if (itemViews_[i] != nullptr) {
|
||
itemViews_[i]->RemoveAll();
|
||
delete itemViews_[i];
|
||
itemViews_[i] = nullptr;
|
||
}
|
||
}
|
||
|
||
for (int i = 0; i < MAX_SELECT_VIEW_INDEX; ++i) {
|
||
if (imgItemInfo[i] != nullptr) {
|
||
delete imgItemInfo[i];
|
||
imgItemInfo[i] = nullptr;
|
||
}
|
||
}
|
||
|
||
if (sportGoalSelectList_ != nullptr) {
|
||
// sportGoalSelectList_->ClearFocus();
|
||
sportGoalSelectList_->RemoveAll();
|
||
delete sportGoalSelectList_;
|
||
sportGoalSelectList_ = nullptr;
|
||
}
|
||
|
||
// if (sportGoalSelectAdapter_ != nullptr) { // <20><><EFBFBD><EFBFBD>ᵼ<EFBFBD><E1B5BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
// static int a = 0;
|
||
// printf("line = %d=====a=%d=====\n", __LINE__, a++);
|
||
// delete sportGoalSelectAdapter_;
|
||
// printf("line = %d===========\n", __LINE__);
|
||
// sportGoalSelectAdapter_ = nullptr;
|
||
// printf("line = %d===========\n", __LINE__);
|
||
// }
|
||
}
|
||
|
||
#pragma endregion
|
||
|
||
#pragma region 通用目标页
|
||
void CommonGoalItemOnclickListener::EnterCallBack(OHOS::UIView &view)
|
||
{
|
||
static_print_info("======cxin is click CommonGoalItemOnclickListener::EnterCallBack===%s=\n", view.GetViewId());
|
||
auto sportModel = TjdUiAppSportModel::GetInstance();
|
||
if (view.GetViewId() == "distStart") {
|
||
// std::string distStr = "1000m"; // 用于调试测试
|
||
std::string distStr = g_pv_SportGoal[TjdUiAppSportView::currentIconIndex_].distGoal;
|
||
g_pv_SportGoal[TjdUiAppSportView::currentIconIndex_].sportGoal = distStr;
|
||
sportModel->SetDistancePopUpRemind(distStr);
|
||
} else if (view.GetViewId() == "timeStart") {
|
||
std::string timeStr = g_pv_SportGoal[TjdUiAppSportView::currentIconIndex_].timeGoal;
|
||
g_pv_SportGoal[TjdUiAppSportView::currentIconIndex_].sportGoal = timeStr;
|
||
// std::string timeStr = "00H01min"; // 用于调试测试
|
||
sportModel->SetTimePopUpRemind(timeStr);
|
||
} else if (view.GetViewId() == "caloriesStart") {
|
||
std::string calStr = g_pv_SportGoal[TjdUiAppSportView::currentIconIndex_].caloriesGoal;
|
||
g_pv_SportGoal[TjdUiAppSportView::currentIconIndex_].sportGoal = calStr;
|
||
sportModel->SetCaloriesPopUpRemind(calStr);
|
||
}
|
||
}
|
||
|
||
bool CommonGoalItemOnclickListener::OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event)
|
||
{
|
||
static_print_info("======cxin is click CommonGoalItemOnclickListener::OnClick===%s=\n", view.GetViewId());
|
||
auto sportView = TjdUiAppSportView::GetInstance();
|
||
if (view.GetViewId() == "distItemGoals") {
|
||
sportView->ShowTargetView(DISTANCE_GOAL_SELECT_VIEW);
|
||
} else if (view.GetViewId() == "timeItemGoals") {
|
||
auto sportView = TjdUiAppSportView::GetInstance();
|
||
sportView->ShowTargetView(TIME_GOAL_SELECT_VIEW);
|
||
} else if (view.GetViewId() == "CaloriesItemGoals") {
|
||
sportView->ShowTargetView(CALORIES_GOAL_SELECT_VIEW);
|
||
} else if (view.GetViewId() == "distItemReminds" || view.GetViewId() == "timeItemReminds" ||
|
||
view.GetViewId() == "CaloriesItemReminds" || view.GetViewId() == "FreeTrainItemReminds") {
|
||
if (view.GetViewId() == "distItemReminds")
|
||
sportView->lastViewIndex_ = SPORT_GOAL_DISTANCES_VIEW;
|
||
else if (view.GetViewId() == "timeItemReminds")
|
||
sportView->lastViewIndex_ = SPORT_GOAL_TIME_VIEW;
|
||
else if (view.GetViewId() == "CaloriesItemReminds")
|
||
sportView->lastViewIndex_ = SPORT_GOAL_CALORIES_VIEW;
|
||
else if (view.GetViewId() == "FreeTrainItemReminds")
|
||
sportView->lastViewIndex_ = SPORT_GOAL_FREE_TRAINING_VIEW;
|
||
|
||
sportView->ShowTargetView(SPORT_REMIND_SELECT_VIEW);
|
||
} else if (view.GetViewId() == "distStart" || view.GetViewId() == "timeStart" ||
|
||
view.GetViewId() == "caloriesStart" || view.GetViewId() == "freeTrainStart") {
|
||
static_print_info("aaaaa viewid = %s\n", view.GetViewId());
|
||
EnterCallBack(view);
|
||
sportView->ShowTargetView(COUNT_DOWN_VIEW, TjdUiAppSportView::currentIconIndex_);
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
CommonGoalItemView::CommonGoalItemView(GoalSelectViewInfo &info)
|
||
{
|
||
auto image = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(info.imgIconResId, SPORT_IMAGE_BIN_PATH);
|
||
SetPosition(0, 0, 450, 128);
|
||
SetStyle(OHOS::STYLE_BACKGROUND_COLOR, 0xff202020);
|
||
SetStyle(OHOS::STYLE_BORDER_RADIUS, 64);
|
||
SetViewIndex(info.index);
|
||
SetViewId(info.itemId);
|
||
|
||
icon_.SetPosition(12, 18, 92, 92);
|
||
if (image != nullptr) {
|
||
icon_.SetSrc(image);
|
||
}
|
||
|
||
name_.SetPosition(0, 14, 450, 56);
|
||
name_.SetFont(TJD_VECTOR_FONT_FILENAME, 42);
|
||
name_.SetTextId(info.nameId);
|
||
// name_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_ADAPT);
|
||
name_.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
||
|
||
goal_.SetPosition(0, 73, 450, 40);
|
||
goal_.SetFont(TJD_VECTOR_FONT_FILENAME, 30);
|
||
goal_.SetTextId(info.goalId);
|
||
goal_.SetStyle(STYLE_TEXT_OPA, 0xff * 0.2);
|
||
// goal_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_ADAPT);
|
||
goal_.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
||
|
||
image = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_SPORT_INDOOR_MORE, SPORT_IMAGE_BIN_PATH);
|
||
moreIcon_.SetPosition(401, 52, 14, 24);
|
||
if (image != nullptr) {
|
||
moreIcon_.SetSrc(image);
|
||
}
|
||
|
||
SetTouchable(true);
|
||
SetOnClickListener(&goalItemOnclickListener);
|
||
|
||
Add(&icon_);
|
||
Add(&name_);
|
||
Add(&goal_);
|
||
Add(&moreIcon_);
|
||
}
|
||
|
||
static void timeTimerCallBack(void *arg)
|
||
{
|
||
GraphicService::GetInstance()->PostGraphicEvent(
|
||
std::bind([](void *arg) { CommonViewGoalPage::GetInstance()->UpdateLocalTime(); }, arg));
|
||
}
|
||
|
||
CommonViewGoalPage::CommonViewGoalPage(GoalSelectView index)
|
||
{
|
||
index_ = index;
|
||
g_pv_CommonViewGoalPage = this;
|
||
|
||
uint32_t imageId[4] = {IMG_SPORT_START_DIS, IMG_SPORT_START_TIME, IMG_SPORT_START_CAL, IMG_SPORT_START_ZDY};
|
||
|
||
char *startId[4] = {"distStart", "timeStart", "caloriesStart", "freeTrainStart"};
|
||
|
||
SetPosition(0, 0, OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
||
SetDraggable(true);
|
||
SetOnDragListener(TjdUiAppSportPresenter::GetInstance());
|
||
|
||
rtc_class_ops *rtc = tjd_driver_rtc_get_ops();
|
||
struct rtc_time localTime;
|
||
rtc->get_rtc_time(&localTime);
|
||
char timeStr[15] = {0};
|
||
sprintf(timeStr, "%02d.%02d", localTime.tm_hour, localTime.tm_min);
|
||
timeTitle_.SetText(timeStr);
|
||
InitLabel(timeTitle_, 28, 193, 17, timeStr);
|
||
|
||
int16_t startY = 80;
|
||
int16_t interval = 8;
|
||
|
||
for (int i = 0; i < MAX_COMMON_VIEW_ITEM_INDEX; ++i) {
|
||
if (FREE_TRAINING_SELECT_VIEW == index && i == 0) {
|
||
startY = 154;
|
||
continue;
|
||
}
|
||
goalItemViews_[i] = new CommonGoalItemView(g_pv_CommonViewItemInfo[index][i]);
|
||
goalItemViews_[i]->SetPosition(8, startY, 450, 128);
|
||
Add(goalItemViews_[i]);
|
||
startY += 128 + interval;
|
||
}
|
||
|
||
auto image = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(imageId[index], SPORT_IMAGE_BIN_PATH);
|
||
if (image != nullptr) {
|
||
startIcon_.SetSrc(image);
|
||
startIcon_.SetPosition(187, 352);
|
||
}
|
||
|
||
if (timeTimer_ == nullptr)
|
||
timeTimer_ = new OHOS::GraphicTimer(1000, timeTimerCallBack, nullptr, true);
|
||
|
||
startIcon_.SetTouchable(true);
|
||
startIcon_.SetViewId(startId[index]);
|
||
startIcon_.SetOnClickListener(&startIconOnclickListener);
|
||
|
||
Add(&startIcon_);
|
||
Add(&timeTitle_);
|
||
}
|
||
|
||
void CommonViewGoalPage::GoalPageDataRefresh()
|
||
{
|
||
char tempStr[20] = {0};
|
||
uint16_t selectIndex = 0;
|
||
uint8_t curTouchIndex = TjdUiAppSportView::currentIconIndex_;
|
||
|
||
switch (index_) {
|
||
case DISTANCE_SELECT_VIEW:
|
||
goalItemViews_[0]->goal_.SetText(g_pv_SportGoal[curTouchIndex].distGoal.c_str());
|
||
break;
|
||
case TIME_SELECT_VIEW:
|
||
goalItemViews_[0]->goal_.SetText(g_pv_SportGoal[curTouchIndex].timeGoal.c_str());
|
||
break;
|
||
case CALORIES_SELECT_VIEW:
|
||
goalItemViews_[0]->goal_.SetText(g_pv_SportGoal[curTouchIndex].caloriesGoal.c_str());
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
|
||
if (index_ != FREE_TRAINING_SELECT_VIEW) {
|
||
static_cast<UITransformGroup *>(goalItemViews_[0])->Scale(OHOS::Vector2<float>(0.9, 0.9), {233, 60});
|
||
goalItemViews_[0]->Invalidate();
|
||
}
|
||
}
|
||
|
||
void CommonViewGoalPage::UpdateLocalTime()
|
||
{
|
||
rtc_class_ops *rtc = tjd_driver_rtc_get_ops();
|
||
struct rtc_time localTime;
|
||
rtc->get_rtc_time(&localTime);
|
||
char timeStr[15] = {0};
|
||
sprintf(timeStr, "%02d.%02d", localTime.tm_hour, localTime.tm_min);
|
||
timeTitle_.SetText(timeStr);
|
||
}
|
||
|
||
void CommonViewGoalPage::ShowView()
|
||
{
|
||
GoalPageDataRefresh(); // 接口有问题,先不用
|
||
Invalidate();
|
||
SetVisible(true);
|
||
timeTimer_->Start();
|
||
}
|
||
|
||
void CommonViewGoalPage::HideView()
|
||
{
|
||
timeTimer_->Stop();
|
||
SetVisible(false);
|
||
}
|
||
|
||
CommonViewGoalPage *CommonViewGoalPage::GetInstance(void) { return g_pv_CommonViewGoalPage; }
|
||
|
||
CommonViewGoalPage::~CommonViewGoalPage()
|
||
{
|
||
static_print_info("CommonViewGoalPage==line[%d]==func[%s]\n", __LINE__, __func__);
|
||
g_pv_CommonViewGoalPage = nullptr;
|
||
RemoveAll();
|
||
if (timeTimer_ != nullptr) {
|
||
timeTimer_->Stop();
|
||
delete timeTimer_;
|
||
timeTimer_ = nullptr;
|
||
}
|
||
|
||
for (int i = 0; i < MAX_COMMON_VIEW_ITEM_INDEX; ++i) {
|
||
if (goalItemViews_[i] != nullptr) {
|
||
goalItemViews_[i]->RemoveAll();
|
||
delete goalItemViews_[i];
|
||
goalItemViews_[i] = nullptr;
|
||
}
|
||
}
|
||
}
|
||
#pragma endregion
|
||
|
||
#pragma region CommonUiPicker
|
||
CommonUiPicker::CommonUiPicker(const char *uiPickerId, ColorType highlightColor, const char *uiPickerData[],
|
||
uint8_t len, int64_t highlightBgColor)
|
||
{
|
||
SetPosition(0, 0, OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
||
uiPicker_.SetPosition(54, 97);
|
||
uiPicker_.Resize(358, 235);
|
||
uiPicker_.SetViewId(uiPickerId);
|
||
uiPicker_.SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
|
||
uiPicker_.SetStyle(STYLE_BACKGROUND_OPA, 0xff);
|
||
uiPicker_.SetBackgroundFont(TJD_VECTOR_FONT_FILENAME, 50);
|
||
uiPicker_.SetHighlightFont(TJD_VECTOR_FONT_FILENAME, 70);
|
||
uiPicker_.SetItemHeight(90);
|
||
uiPicker_.SetTextColor(Color::GetColorFromRGBA(0x26, 0x26, 0x26, 0xff), highlightColor);
|
||
uiPicker_.SetValues(uiPickerData, len);
|
||
uiPicker_.SetVisible(true);
|
||
highLightBg_.SetPosition(54, 164);
|
||
highLightBg_.Resize(358, 100);
|
||
highLightBg_.SetStyle(STYLE_BORDER_WIDTH, 4);
|
||
highLightBg_.SetStyle(STYLE_BORDER_RADIUS, 16);
|
||
highLightBg_.SetStyle(STYLE_BORDER_COLOR, highlightBgColor);
|
||
Add(&uiPicker_);
|
||
Add(&highLightBg_);
|
||
}
|
||
|
||
void CommonUiPicker::ViewRequestFocus()
|
||
{
|
||
OHOS::FocusManager::GetInstance()->ClearFocus();
|
||
uiPicker_.RequestFocus();
|
||
}
|
||
|
||
#pragma endregion
|
||
|
||
#pragma region 距离、卡路里监听器
|
||
bool GoalOnclickListener::OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event)
|
||
{
|
||
auto sportView = TjdUiAppSportView::GetInstance();
|
||
static_print_info("======GoalOnclickListener::OnClick===%s=\n", view.GetViewId());
|
||
if (view.GetViewId() == "distConfirm") {
|
||
sportView->ShowTargetView(SPORT_GOAL_DISTANCES_VIEW);
|
||
} else if (view.GetViewId() == "caloriesConfirm") {
|
||
sportView->ShowTargetView(SPORT_GOAL_CALORIES_VIEW);
|
||
}
|
||
|
||
return true;
|
||
}
|
||
#pragma endregion
|
||
|
||
#pragma region 距离目标选择
|
||
DistnaceGoalSelectView::DistnaceGoalSelectView()
|
||
{
|
||
g_pv_DistnaceGoalSelectView = this;
|
||
SetPosition(0, 0, OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
||
SetTouchable(true);
|
||
SetDraggable(true);
|
||
SetOnDragListener(TjdUiAppSportPresenter::GetInstance());
|
||
|
||
// InitLabel(lbTitle_, 28, 203, 17, "距离");
|
||
lbTitle_.SetFont(TJD_VECTOR_FONT_FILENAME, 28);
|
||
lbTitle_.SetTextId(STR_ID_209);
|
||
// lbTitle_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_ADAPT);
|
||
lbTitle_.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
||
lbTitle_.SetPosition(0, 17, 466, 37);
|
||
|
||
distancePicker_ =
|
||
new CommonUiPicker("distancePicker", Color::GetColorFromRGBA(0x00, 0xB1, 0x36, 0xff), distUiPickerData,
|
||
sizeof(distUiPickerData) / sizeof(distUiPickerData[0]), 0xFF00B136);
|
||
distancePicker_->uiPicker_.SetSelected(5);
|
||
OHOS::ImageInfo *imgInfo = ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_SPORT_BJ, SPORT_IMAGE_BIN_PATH);
|
||
UiDrawImage(&imgConfirm, 187, 352, "distConfirm", imgInfo);
|
||
imgConfirm.SetTouchable(true);
|
||
imgConfirm.SetOnClickListener(&distnaceGoalOnclickListener);
|
||
|
||
Add(distancePicker_);
|
||
Add(&lbTitle_);
|
||
Add(&imgConfirm);
|
||
}
|
||
|
||
void DistnaceGoalSelectView::ShowView()
|
||
{
|
||
distancePicker_->ViewRequestFocus();
|
||
SetVisible(true);
|
||
}
|
||
|
||
void DistnaceGoalSelectView::HideView()
|
||
{
|
||
distancePickIndex = distancePicker_->uiPicker_.GetSelected();
|
||
g_pv_SportGoal[TjdUiAppSportView::currentIconIndex_].distGoal = (char *)distUiPickerData[distancePickIndex];
|
||
g_pv_SportGoal[TjdUiAppSportView::currentIconIndex_].sportGoal =
|
||
g_pv_SportGoal[TjdUiAppSportView::currentIconIndex_].distGoal;
|
||
CommonViewGoalPage::CurSelectGoalView = DISTANCE_SELECT_VIEW;
|
||
static_print_info("===distancePickIndex = %d\n", distancePickIndex);
|
||
SetVisible(false);
|
||
}
|
||
|
||
DistnaceGoalSelectView *DistnaceGoalSelectView::GetInstance(void) { return g_pv_DistnaceGoalSelectView; }
|
||
|
||
DistnaceGoalSelectView::~DistnaceGoalSelectView()
|
||
{
|
||
static_print_info("CommonViewGoalPage==line[%d]==func[%s]\n", __LINE__, __func__);
|
||
g_pv_DistnaceGoalSelectView = nullptr;
|
||
RemoveAll();
|
||
if (distancePicker_ != nullptr) {
|
||
delete distancePicker_;
|
||
distancePicker_ = nullptr;
|
||
}
|
||
}
|
||
|
||
#pragma endregion
|
||
|
||
#pragma region 时间目标选择
|
||
void SportTimerPickerOnListener::OnSelectTimePicker(OHOS::UIPicker &picker) { TjdUiUtils::ViewRequestFocus(picker); }
|
||
|
||
void SportTimerPickerOnListener::OnEnter(int32_t hour, int32_t minute)
|
||
{
|
||
char tempStr[16] = {0};
|
||
sprintf(tempStr, "%02dH%02dmin", hour, minute);
|
||
g_pv_SportGoal[TjdUiAppSportView::currentIconIndex_].timeGoal = tempStr;
|
||
g_pv_SportGoal[TjdUiAppSportView::currentIconIndex_].sportGoal = tempStr;
|
||
CommonViewGoalPage::CurSelectGoalView = TIME_SELECT_VIEW;
|
||
printf("SportTimeSelectView::EnterCallback hour:%d, minute:%d, tempStr:%s\n", hour, minute, tempStr);
|
||
if (hour == 0 && minute == 0) {
|
||
return;
|
||
}
|
||
TjdUiAppSportView::GetInstance()->ShowTargetView(SPORT_GOAL_TIME_VIEW);
|
||
}
|
||
|
||
TimeGoalSelectView::TimeGoalSelectView()
|
||
{
|
||
SetPosition(0, 0, OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
||
SetDraggable(true);
|
||
SetOnDragListener(TjdUiAppSportPresenter::GetInstance());
|
||
|
||
if (timePicker == nullptr) {
|
||
timePicker = new TjdUITimePicker();
|
||
}
|
||
timePicker->SetTitleId(STR_ID_594); //时间
|
||
// timePicker->SetEnterViewType(TjdUIEnterViewBase::EnterViewType::OK);
|
||
timePicker->SetPosition(0, 0, 466, 466);
|
||
timePicker->SetOkSmallBackground(0xff00C487);
|
||
timePicker->SetHighlightColor(0xff00C487);
|
||
timePicker->SetItemSelectdEnterListener(&timePickerOnListener);
|
||
|
||
ImageInfo *imgInfo = ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_SPORT_TIME_BJ, SPORT_IMAGE_BIN_PATH);
|
||
timePicker->SetOkSrc(imgInfo);
|
||
|
||
Add(timePicker);
|
||
}
|
||
|
||
#pragma endregion
|
||
|
||
#pragma region 卡路里目标选择
|
||
CaloriesGoalSelectView::CaloriesGoalSelectView()
|
||
{
|
||
g_pv_CaloriesGoalSelectView = this;
|
||
SetPosition(0, 0, OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
||
SetTouchable(true);
|
||
SetDraggable(true);
|
||
SetOnDragListener(TjdUiAppSportPresenter::GetInstance());
|
||
|
||
// InitLabel(lbTitle_, 28, 203, 17, "卡路里");
|
||
lbTitle_.SetFont(TJD_VECTOR_FONT_FILENAME, 28);
|
||
lbTitle_.SetTextId(STR_ID_201);
|
||
// lbTitle_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_ADAPT);
|
||
lbTitle_.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
||
lbTitle_.SetPosition(0, 17, 466, 37);
|
||
|
||
caloriesPicker_ =
|
||
new CommonUiPicker("caloriesPicker", Color::GetColorFromRGBA(0xFC, 0x3C, 0x01, 0xff), caloriesUiPickerData,
|
||
sizeof(caloriesUiPickerData) / sizeof(caloriesUiPickerData[0]), 0xFFFC3C01);
|
||
OHOS::ImageInfo *imgInfo =
|
||
ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_SPORT_CALORIES_BJ, SPORT_IMAGE_BIN_PATH);
|
||
UiDrawImage(&imgConfirm, 187, 352, "caloriesConfirm", imgInfo);
|
||
imgConfirm.SetTouchable(true);
|
||
imgConfirm.SetOnClickListener(&caloriesGoalOnclickListener);
|
||
|
||
Add(caloriesPicker_);
|
||
Add(&lbTitle_);
|
||
Add(&imgConfirm);
|
||
}
|
||
|
||
void CaloriesGoalSelectView::ShowView()
|
||
{
|
||
caloriesPicker_->ViewRequestFocus();
|
||
SetVisible(true);
|
||
}
|
||
|
||
void CaloriesGoalSelectView::HideView()
|
||
{
|
||
char tempStr[20] = {0};
|
||
caloriesPickIndex = caloriesPicker_->uiPicker_.GetSelected();
|
||
sprintf(tempStr, "%s Kcal", caloriesUiPickerData[caloriesPickIndex]);
|
||
g_pv_SportGoal[TjdUiAppSportView::currentIconIndex_].caloriesGoal = tempStr;
|
||
g_pv_SportGoal[TjdUiAppSportView::currentIconIndex_].sportGoal = tempStr;
|
||
CommonViewGoalPage::CurSelectGoalView = CALORIES_SELECT_VIEW;
|
||
SetVisible(false);
|
||
}
|
||
|
||
CaloriesGoalSelectView *CaloriesGoalSelectView::GetInstance() { return g_pv_CaloriesGoalSelectView; }
|
||
|
||
CaloriesGoalSelectView::~CaloriesGoalSelectView()
|
||
{
|
||
static_print_info("CaloriesGoalSelectView==line[%d]==func[%s]\n", __LINE__, __func__);
|
||
g_pv_CaloriesGoalSelectView = nullptr;
|
||
RemoveAll();
|
||
if (caloriesPicker_ != nullptr) {
|
||
delete caloriesPicker_;
|
||
caloriesPicker_ = nullptr;
|
||
}
|
||
}
|
||
#pragma endregion
|
||
|
||
#pragma region 提醒目标页
|
||
bool RemindGoalListItemOnclickListener::OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event)
|
||
{
|
||
auto sportView = TjdUiAppSportView::GetInstance();
|
||
if (view.GetViewId() == "heartRatePick") {
|
||
sportView->ShowTargetView(HEART_RATE_PICK_VIEW);
|
||
} else if (view.GetViewId() == "timePick") {
|
||
sportView->ShowTargetView(TIME_PICK_VIEW);
|
||
} else if (view.GetViewId() == "distPick") {
|
||
sportView->ShowTargetView(DISTANCE_PICK_VIEW);
|
||
}
|
||
return true;
|
||
}
|
||
|
||
RemindGoalListItemView::RemindGoalListItemView(RemindItemInfo &info)
|
||
{
|
||
RemoveAll();
|
||
static_print_info("RemindGoalListItemView::RemindGoalListItemView\n");
|
||
auto image = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(info.iconResId, SPORT_IMAGE_BIN_PATH);
|
||
SetPosition(0, 0, 450, 130);
|
||
SetStyle(OHOS::STYLE_BACKGROUND_COLOR, 0xff202020);
|
||
SetStyle(OHOS::STYLE_BORDER_RADIUS, 70);
|
||
SetViewId(info.itemId);
|
||
// SetViewIndex(index);
|
||
|
||
icon_.SetPosition(16, 19, 92, 92);
|
||
if (image != nullptr) {
|
||
icon_.SetSrc(image);
|
||
}
|
||
|
||
name_.SetFont(TJD_VECTOR_FONT_FILENAME, 42);
|
||
name_.SetTextId(info.nameId);
|
||
// name_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_ADAPT);
|
||
name_.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
||
name_.SetPosition(0, 15, 450, 56);
|
||
printf("name width = %d, height = %d\n", name_.GetWidth(), name_.GetHeight());
|
||
|
||
goal_.SetFont(TJD_VECTOR_FONT_FILENAME, 30);
|
||
goal_.SetTextId(info.goalId);
|
||
goal_.SetStyle(STYLE_TEXT_OPA, 0xff * 0.2);
|
||
goal_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_OSCILLATION);
|
||
goal_.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
||
goal_.SetPosition(143, 74, 180, 40);
|
||
|
||
image = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_SPORT_INDOOR_MORE, SPORT_IMAGE_BIN_PATH);
|
||
moreIcon_.SetPosition(401, 53, 14, 24);
|
||
if (image != nullptr) {
|
||
moreIcon_.SetSrc(image);
|
||
}
|
||
|
||
SetTouchable(true);
|
||
SetOnClickListener(&remindGoalListItemOnclickListener);
|
||
|
||
Add(&icon_);
|
||
Add(&name_);
|
||
Add(&goal_);
|
||
Add(&moreIcon_);
|
||
}
|
||
|
||
RemindGoalListView::RemindGoalListView()
|
||
{
|
||
g_pv_RemindGoalListView = this;
|
||
SetPosition(0, 0, OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
||
SetTouchable(true);
|
||
SetDraggable(true);
|
||
SetOnDragListener(TjdUiAppSportPresenter::GetInstance());
|
||
|
||
// InitLabel(remindTitle_, 28, 203, 17, "提醒");
|
||
remindTitle_.SetFont(TJD_VECTOR_FONT_FILENAME, 28);
|
||
remindTitle_.SetTextId(STR_ID_229);
|
||
// remindTitle_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_ADAPT);
|
||
remindTitle_.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
||
remindTitle_.SetPosition(0, 17, 466, 37);
|
||
|
||
int16_t startY = 50;
|
||
int16_t interval = 3;
|
||
for (int i = 0; i < REMIND_GOAL_MAX_INDEX; ++i) {
|
||
remindItemViews_[i] = new RemindGoalListItemView(g_pv_CommonRemindGoalList[i]);
|
||
remindItemViews_[i]->SetPosition(8, startY, 450, 130);
|
||
Add(remindItemViews_[i]);
|
||
startY += 130 + interval;
|
||
}
|
||
Add(&remindTitle_);
|
||
}
|
||
|
||
void RemindGoalListView::RemindGoalListViewRefresh()
|
||
{
|
||
string remindGoal = g_pv_SportGoal[TjdUiAppSportView::currentIconIndex_].heartRateRemindGoal;
|
||
remindItemViews_[HEART_RATE_INDEX]->goal_.SetText(remindGoal.c_str());
|
||
remindItemViews_[HEART_RATE_INDEX]->goal_.SetX(
|
||
(HORIZONTAL_RESOLUTION - remindItemViews_[HEART_RATE_INDEX]->goal_.GetWidth()) / 2);
|
||
|
||
remindGoal = g_pv_SportGoal[TjdUiAppSportView::currentIconIndex_].timeRemindGoal;
|
||
remindItemViews_[TIME_INDEX]->goal_.SetText(remindGoal.c_str());
|
||
remindItemViews_[TIME_INDEX]->SetY(178);
|
||
|
||
remindGoal = g_pv_SportGoal[TjdUiAppSportView::currentIconIndex_].distRemindGoal;
|
||
remindItemViews_[ONCE_INDEX]->goal_.SetText(remindGoal.c_str());
|
||
|
||
static_cast<UITransformGroup *>(remindItemViews_[HEART_RATE_INDEX])
|
||
->Scale(OHOS::Vector2<float>(0.8, 0.8), {(float)remindItemViews_[HEART_RATE_INDEX]->GetWidth() / 2,
|
||
(float)remindItemViews_[HEART_RATE_INDEX]->GetHeight() / 2});
|
||
|
||
static_cast<UITransformGroup *>(remindItemViews_[ONCE_INDEX])
|
||
->Scale(OHOS::Vector2<float>(0.74, 0.74), {(float)remindItemViews_[ONCE_INDEX]->GetWidth() / 2,
|
||
(float)remindItemViews_[ONCE_INDEX]->GetHeight() / 2});
|
||
|
||
remindItemViews_[ONCE_INDEX]->SetY(304);
|
||
remindItemViews_[ONCE_INDEX]->Invalidate();
|
||
|
||
Invalidate();
|
||
}
|
||
|
||
void RemindGoalListView::ShowView()
|
||
{
|
||
RemindGoalListViewRefresh();
|
||
SetVisible(true);
|
||
}
|
||
|
||
RemindGoalListView::~RemindGoalListView()
|
||
{
|
||
static_print_info("RemindGoalListView==line[%d]==func[%s]\n", __LINE__, __func__);
|
||
g_pv_RemindGoalListView = nullptr;
|
||
RemoveAll();
|
||
};
|
||
|
||
RemindGoalListView *RemindGoalListView::GetInstance(void) { return g_pv_RemindGoalListView; }
|
||
|
||
#pragma endregion
|
||
|
||
#pragma region 心率区间选择
|
||
HeartRateItemView::HeartRateItemView(const HeartRateItemInfo &info)
|
||
{
|
||
iconRes_ = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(info.imgIconResId, SPORT_IMAGE_BIN_PATH);
|
||
selectRes_ = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_SPORT_ICON_SELECT, SPORT_IMAGE_BIN_PATH);
|
||
unSelectRes_ = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_SPORT_ICON_NO, SPORT_IMAGE_BIN_PATH);
|
||
SetPosition(0, 0, 450, 128);
|
||
SetStyle(OHOS::STYLE_BACKGROUND_COLOR, 0xff202020);
|
||
SetStyle(OHOS::STYLE_BORDER_RADIUS, 64);
|
||
SetViewIndex(info.index);
|
||
|
||
icon_.SetPosition(28, 38, 52, 52);
|
||
if (iconRes_ != nullptr) {
|
||
icon_.SetSrc(iconRes_);
|
||
}
|
||
|
||
content_.SetTextId(info.contentId);
|
||
content_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_ADAPT);
|
||
content_.SetAlign(OHOS::TEXT_ALIGNMENT_LEFT, OHOS::TEXT_ALIGNMENT_CENTER);
|
||
|
||
printf("content_ width = %d, height = %d\n", content_.GetWidth(), content_.GetHeight());
|
||
|
||
unit_.SetFont(TJD_VECTOR_FONT_FILENAME, 28);
|
||
unit_.SetTextId(info.unitId);
|
||
unit_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_ADAPT);
|
||
unit_.SetStyle(STYLE_TEXT_OPA, 0xff * 0.2);
|
||
unit_.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
||
unit_.SetPosition(263, 45, 79, 37);
|
||
printf("unit width = %d, height = %d\n", unit_.GetWidth(), unit_.GetHeight());
|
||
|
||
switch_.SetPosition(382, 44, 40, 40);
|
||
switch_.SetViewIndex(info.index);
|
||
switch_.SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
|
||
switch_.SetSrc(selectRes_);
|
||
|
||
SetTouchable(true);
|
||
|
||
Add(&icon_);
|
||
Add(&content_);
|
||
Add(&unit_);
|
||
Add(&switch_);
|
||
}
|
||
|
||
void HeartRateItemView::RefreshItem(const HeartRateItemInfo &itemInfo, int16_t index)
|
||
{
|
||
itemInfo_ = itemInfo;
|
||
SetViewIndex(itemInfo.index);
|
||
icon_.SetSrc(iconRes_);
|
||
if (itemInfo.contentId == STR_ID_217) {
|
||
content_.SetPosition(108, 36, 149, 50);
|
||
content_.SetFont(TJD_VECTOR_FONT_FILENAME, 42);
|
||
unit_.SetVisible(false);
|
||
icon_.SetVisible(false);
|
||
} else {
|
||
content_.SetPosition(108, 39, 149, 50);
|
||
content_.SetFont(TJD_DIN_MEDIUM_FONT_FILENAME, 42);
|
||
unit_.SetVisible(true);
|
||
icon_.SetVisible(true);
|
||
}
|
||
content_.SetTextId(itemInfo.contentId);
|
||
|
||
if (g_HeartRateReminder[TjdUiAppSportView::currentIconIndex_][itemInfo_.index] == true) {
|
||
switch_.SetSrc(selectRes_);
|
||
} else {
|
||
switch_.SetSrc(unSelectRes_);
|
||
}
|
||
}
|
||
|
||
bool HeartRateItemView::OnClickEvent(const OHOS::ClickEvent &event)
|
||
{
|
||
uint8_t selectCount = 0;
|
||
for (uint8_t i = 0; i < 5; i++) {
|
||
if (g_HeartRateReminder[TjdUiAppSportView::currentIconIndex_][i])
|
||
selectCount++;
|
||
}
|
||
|
||
if (selectCount == 1 && g_HeartRateReminder[TjdUiAppSportView::currentIconIndex_][itemInfo_.index])
|
||
return true;
|
||
|
||
if (selectCount == 1 && itemInfo_.index != NONE_SECTOR_INDEX) {
|
||
OHOS::UIView *childView = static_cast<OHOS::UITransformList *>(GetParent())->GetChildrenTail();
|
||
static_cast<HeartRateItemView *>(childView)->switch_.SetSrc(unSelectRes_);
|
||
g_HeartRateReminder[TjdUiAppSportView::currentIconIndex_][NONE_SECTOR_INDEX] = false;
|
||
} else if (itemInfo_.index == NONE_SECTOR_INDEX) {
|
||
OHOS::UIView *childView = static_cast<OHOS::UITransformList *>(GetParent())->GetChildrenHead();
|
||
while (childView != nullptr) {
|
||
static_cast<HeartRateItemView *>(childView)->switch_.SetSrc(unSelectRes_);
|
||
childView = childView->GetNextSibling();
|
||
}
|
||
|
||
for (uint8_t i = 0; i < 5; i++) {
|
||
g_HeartRateReminder[TjdUiAppSportView::currentIconIndex_][i] = false;
|
||
}
|
||
}
|
||
|
||
g_HeartRateReminder[TjdUiAppSportView::currentIconIndex_][itemInfo_.index] =
|
||
!g_HeartRateReminder[TjdUiAppSportView::currentIconIndex_][itemInfo_.index];
|
||
if (g_HeartRateReminder[TjdUiAppSportView::currentIconIndex_][itemInfo_.index] == true) {
|
||
switch_.SetSrc(selectRes_);
|
||
} else {
|
||
switch_.SetSrc(unSelectRes_);
|
||
}
|
||
return true;
|
||
}
|
||
|
||
HeartRatePickView::HeartRatePickView()
|
||
{
|
||
SetPosition(0, 0, OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
||
SetDraggable(true);
|
||
SetOnDragListener(TjdUiAppSportPresenter::GetInstance());
|
||
|
||
// InitLabel(heartRateTitle_, 28, 203, 17, "提醒");
|
||
heartRateTitle_.SetFont(TJD_VECTOR_FONT_FILENAME, 28);
|
||
heartRateTitle_.SetTextId(STR_ID_229);
|
||
// heartRateTitle_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_ADAPT);
|
||
heartRateTitle_.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
||
heartRateTitle_.SetPosition(0, 17, 466, 37);
|
||
|
||
heartRateListItemInfo_.clear();
|
||
for (int i = 0; i < HEART_RATE_MAX_INDEX; ++i) {
|
||
heartRateListItemInfo_.push_back(g_pv_HeartRateItemInfo[i]);
|
||
}
|
||
|
||
heartRateAdapterPtr_ =
|
||
new TjdUITransformListGroupAdapter<HeartRateItemInfo, HeartRateItemView, std::list<HeartRateItemInfo>>(
|
||
heartRateListItemInfo_);
|
||
heartRateListView_ = new TjdUITransformListGroup(heartRateAdapterPtr_);
|
||
heartRateListView_->AddCustomView(&heartRateTitle_, TjdUITransformListGroup::CustomViewPos::TITLE);
|
||
heartRateListView_->SetTitleOffset(70);
|
||
|
||
Add(heartRateListView_);
|
||
}
|
||
|
||
void HeartRatePickView::ShowView()
|
||
{
|
||
heartRateListView_->RefreshList();
|
||
OHOS::FocusManager::GetInstance()->ClearFocus();
|
||
heartRateListView_->RequestFocus();
|
||
SetVisible(true);
|
||
}
|
||
|
||
void HeartRatePickView::HideView()
|
||
{
|
||
uint8_t selectCount = 0;
|
||
uint8_t curSelectIndex = 0;
|
||
g_pv_SportGoal[TjdUiAppSportView::currentIconIndex_].heartRateRemindGoal.clear();
|
||
for (uint8_t i = 0; i < 5; i++) {
|
||
sql_fit_set_sport_heart_rate_remind_value(i, g_HeartRateReminder[TjdUiAppSportView::currentIconIndex_][i]);
|
||
if (g_HeartRateReminder[TjdUiAppSportView::currentIconIndex_][i]) {
|
||
selectCount++;
|
||
curSelectIndex = i;
|
||
}
|
||
}
|
||
|
||
static_print_info("===selectCount = %d,curSelectIndex = %d\n", selectCount, curSelectIndex);
|
||
if (selectCount == 1 && curSelectIndex == NONE_SECTOR_INDEX) {
|
||
g_pv_SportGoal[TjdUiAppSportView::currentIconIndex_].heartRateRemindGoal =
|
||
FontGlobalManager::GetInstance()->GetText(STR_ID_217);
|
||
} else if (selectCount == 1) {
|
||
g_pv_SportGoal[TjdUiAppSportView::currentIconIndex_].heartRateRemindGoal =
|
||
std::string(FontGlobalManager::GetInstance()->GetText(g_pv_HeartRateItemInfo[curSelectIndex].contentId)) +
|
||
std::string(" ") +
|
||
std::string(FontGlobalManager::GetInstance()->GetText(g_pv_HeartRateItemInfo[curSelectIndex].unitId));
|
||
} else {
|
||
string heartRateRemindGoal = "";
|
||
uint8_t count = 0;
|
||
for (uint8_t j = 0; j < HEART_RATE_MAX_INDEX; j++) {
|
||
{
|
||
if (g_HeartRateReminder[TjdUiAppSportView::currentIconIndex_][j]) {
|
||
if (count < selectCount - 1) {
|
||
heartRateRemindGoal += std::string(FontGlobalManager::GetInstance()->GetText(
|
||
g_pv_HeartRateItemInfo[j].contentId)) +
|
||
std::string("、");
|
||
} else
|
||
heartRateRemindGoal +=
|
||
std::string(FontGlobalManager::GetInstance()->GetText(g_pv_HeartRateItemInfo[j].contentId));
|
||
count++;
|
||
}
|
||
}
|
||
}
|
||
|
||
g_pv_SportGoal[TjdUiAppSportView::currentIconIndex_].heartRateRemindGoal = heartRateRemindGoal;
|
||
}
|
||
SetVisible(false);
|
||
}
|
||
|
||
HeartRatePickView::~HeartRatePickView()
|
||
{
|
||
RemoveAll();
|
||
|
||
if (heartRateAdapterPtr_ != nullptr) {
|
||
delete heartRateAdapterPtr_;
|
||
heartRateAdapterPtr_ = nullptr;
|
||
}
|
||
|
||
if (heartRateListView_ != nullptr) {
|
||
heartRateListView_->RemoveAll();
|
||
delete heartRateListView_;
|
||
heartRateListView_ = nullptr;
|
||
}
|
||
};
|
||
|
||
#pragma endregion
|
||
|
||
#pragma region 时间提醒、距离提醒item
|
||
TimeOrDistRemindItemView::TimeOrDistRemindItemView(const TimeOrDistRemindItemInfo &info)
|
||
{
|
||
selectRes_ = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_SPORT_ICON_SELECT, SPORT_IMAGE_BIN_PATH);
|
||
unSelectRes_ = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_SPORT_ICON_NO, SPORT_IMAGE_BIN_PATH);
|
||
SetPosition(0, 0, 450, 128);
|
||
SetStyle(OHOS::STYLE_BACKGROUND_COLOR, 0xff202020);
|
||
SetStyle(OHOS::STYLE_BORDER_RADIUS, 64);
|
||
|
||
content_.SetFont(TJD_VECTOR_FONT_FILENAME, 36);
|
||
content_.SetTextId(info.contentId);
|
||
content_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_MARQUEE);
|
||
content_.SetAlign(OHOS::TEXT_ALIGNMENT_LEFT, OHOS::TEXT_ALIGNMENT_CENTER);
|
||
content_.SetPosition(42, 36, 300, 56);
|
||
|
||
switch_.SetPosition(382, 44, 40, 40);
|
||
switch_.SetViewIndex(info.index);
|
||
switch_.SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
|
||
switch_.SetSrc(selectRes_);
|
||
|
||
SetTouchable(true);
|
||
|
||
Add(&content_);
|
||
Add(&switch_);
|
||
}
|
||
|
||
void TimeOrDistRemindItemView::RefreshItem(const TimeOrDistRemindItemInfo &itemInfo, int16_t index)
|
||
{
|
||
itemInfo_ = itemInfo;
|
||
SetViewIndex(itemInfo.index);
|
||
// if (itemInfo.contentId == STR_ID_217) {
|
||
// content_.SetPosition(108, 36, 149, 50);
|
||
// content_.SetFont(TJD_VECTOR_FONT_FILENAME, 42);
|
||
// unit_.SetVisible(false);
|
||
// } else {
|
||
// content_.SetPosition(108, 39, 149, 50);
|
||
// content_.SetFont(TJD_DIN_MEDIUM_FONT_FILENAME, 42);
|
||
// unit_.SetVisible(true);
|
||
// }
|
||
content_.SetTextId(itemInfo_.contentId);
|
||
|
||
if (g_TimeReminder[TjdUiAppSportView::currentIconIndex_][itemInfo_.index] == true) {
|
||
switch_.SetSrc(selectRes_);
|
||
} else {
|
||
switch_.SetSrc(unSelectRes_);
|
||
}
|
||
}
|
||
|
||
void TimeOrDistRemindItemView::TimeRemindOnClickEventHandle(void)
|
||
{
|
||
if (g_TimeReminder[TjdUiAppSportView::currentIconIndex_][itemInfo_.index])
|
||
return;
|
||
|
||
OHOS::UIView *childView = static_cast<OHOS::UITransformList *>(GetParent())->GetChildrenHead();
|
||
while (childView != nullptr) {
|
||
static_cast<TimeOrDistRemindItemView *>(childView)->switch_.SetSrc(unSelectRes_);
|
||
childView = childView->GetNextSibling();
|
||
}
|
||
|
||
for (uint8_t i = 0; i < 7; i++) {
|
||
g_TimeReminder[TjdUiAppSportView::currentIconIndex_][i] = false;
|
||
}
|
||
|
||
g_TimeReminder[TjdUiAppSportView::currentIconIndex_][itemInfo_.index] =
|
||
!g_TimeReminder[TjdUiAppSportView::currentIconIndex_][itemInfo_.index];
|
||
if (g_TimeReminder[TjdUiAppSportView::currentIconIndex_][itemInfo_.index] == true) {
|
||
switch_.SetSrc(selectRes_);
|
||
} else {
|
||
switch_.SetSrc(unSelectRes_);
|
||
}
|
||
|
||
TimeRemindPickView::curSelectTimeIndex = itemInfo_.index;
|
||
}
|
||
|
||
void TimeOrDistRemindItemView::DistanceRemindOnClickEventHandle(void)
|
||
{
|
||
if (g_DistanceReminder[TjdUiAppSportView::currentIconIndex_][itemInfo_.index])
|
||
return;
|
||
|
||
OHOS::UIView *childView = static_cast<OHOS::UITransformList *>(GetParent())->GetChildrenHead();
|
||
while (childView != nullptr) {
|
||
static_cast<TimeOrDistRemindItemView *>(childView)->switch_.SetSrc(unSelectRes_);
|
||
childView = childView->GetNextSibling();
|
||
}
|
||
|
||
for (uint8_t i = 0; i < 6; i++) {
|
||
g_DistanceReminder[TjdUiAppSportView::currentIconIndex_][i] = false;
|
||
}
|
||
|
||
g_DistanceReminder[TjdUiAppSportView::currentIconIndex_][itemInfo_.index] =
|
||
!g_DistanceReminder[TjdUiAppSportView::currentIconIndex_][itemInfo_.index];
|
||
if (g_DistanceReminder[TjdUiAppSportView::currentIconIndex_][itemInfo_.index] == true) {
|
||
switch_.SetSrc(selectRes_);
|
||
} else {
|
||
switch_.SetSrc(unSelectRes_);
|
||
}
|
||
|
||
DistanceRemindPickView::curSelectDistanceIndex = itemInfo_.index;
|
||
}
|
||
|
||
bool TimeOrDistRemindItemView::OnClickEvent(const OHOS::ClickEvent &event)
|
||
{
|
||
if (itemInfo_.type == 0) {
|
||
TimeRemindOnClickEventHandle();
|
||
} else {
|
||
DistanceRemindOnClickEventHandle();
|
||
}
|
||
return true;
|
||
}
|
||
|
||
#pragma endregion
|
||
|
||
#pragma region 时间提醒区间选择
|
||
|
||
TimeRemindPickView::TimeRemindPickView()
|
||
{
|
||
SetPosition(0, 0, OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
||
SetDraggable(true);
|
||
SetOnDragListener(TjdUiAppSportPresenter::GetInstance());
|
||
|
||
// InitLabel(timeRemindTitle_, 28, 203, 17, "提醒");
|
||
timeRemindTitle_.SetFont(TJD_VECTOR_FONT_FILENAME, 28);
|
||
timeRemindTitle_.SetTextId(STR_ID_229);
|
||
// timeRemindTitle_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_ADAPT);
|
||
timeRemindTitle_.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
||
timeRemindTitle_.SetPosition(0, 17, 466, 37);
|
||
|
||
timeListItemInfo_.clear();
|
||
for (int i = 0; i < MAX_MIN_INDEX; ++i) {
|
||
timeListItemInfo_.push_back(g_pv_TimeRemindItemInfo[i]);
|
||
}
|
||
|
||
timeAdapterPtr_ = new TjdUITransformListGroupAdapter<TimeOrDistRemindItemInfo, TimeOrDistRemindItemView,
|
||
std::list<TimeOrDistRemindItemInfo>>(timeListItemInfo_);
|
||
timeListView_ = new TjdUITransformListGroup(timeAdapterPtr_);
|
||
timeListView_->AddCustomView(&timeRemindTitle_, TjdUITransformListGroup::CustomViewPos::TITLE);
|
||
timeListView_->SetTitleOffset(80);
|
||
|
||
Add(timeListView_);
|
||
}
|
||
|
||
void TimeRemindPickView::ShowView()
|
||
{
|
||
// TjdUiUtils::ScrollByTop(*this);
|
||
// timeItemViews_[curSelectTimeIndex]->checkBox_.SetState(OHOS::UICheckBox::UICheckBoxState::SELECTED);
|
||
timeListView_->RefreshList();
|
||
OHOS::FocusManager::GetInstance()->ClearFocus();
|
||
timeListView_->RequestFocus();
|
||
SetVisible(true);
|
||
// TjdUiUtils::ViewRequestFocus(*this);
|
||
}
|
||
void TimeRemindPickView::HideView()
|
||
{
|
||
for (uint8_t k = 0; k < MAX_MIN_INDEX; k++) {
|
||
if (g_TimeReminder[TjdUiAppSportView::currentIconIndex_][k])
|
||
g_pv_SportGoal[TjdUiAppSportView::currentIconIndex_].timeRemindGoal =
|
||
std::string(FontGlobalManager::GetInstance()->GetText(g_pv_TimeRemindItemInfo[k].contentId));
|
||
}
|
||
|
||
sql_fit_set_sport_time_remind_value(curSelectTimeIndex); // 数据保存到sql中
|
||
SetVisible(false);
|
||
}
|
||
|
||
TimeRemindPickView::~TimeRemindPickView()
|
||
{
|
||
RemoveAll();
|
||
|
||
if (timeAdapterPtr_ != nullptr) {
|
||
delete timeAdapterPtr_;
|
||
timeAdapterPtr_ = nullptr;
|
||
}
|
||
|
||
if (timeListView_ != nullptr) {
|
||
timeListView_->RemoveAll();
|
||
delete timeListView_;
|
||
timeListView_ = nullptr;
|
||
}
|
||
};
|
||
#pragma endregion
|
||
|
||
#pragma region 距离提醒区间选择
|
||
DistanceRemindPickView::DistanceRemindPickView()
|
||
{
|
||
SetPosition(0, 0, OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
||
SetDraggable(true);
|
||
SetOnDragListener(TjdUiAppSportPresenter::GetInstance());
|
||
|
||
// InitLabel(distRemindTitle_, 28, 203, 17, "提醒");
|
||
distRemindTitle_.SetFont(TJD_VECTOR_FONT_FILENAME, 28);
|
||
distRemindTitle_.SetTextId(STR_ID_229);
|
||
// distRemindTitle_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_ADAPT);
|
||
distRemindTitle_.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
||
distRemindTitle_.SetPosition(0, 17, 466, 37);
|
||
|
||
distanceListItemInfo_.clear();
|
||
for (int i = 0; i < MAX_DISTANCE_INDEX; ++i) {
|
||
distanceListItemInfo_.push_back(g_pv_DistanceRemindItemInfo[i]);
|
||
}
|
||
|
||
distanceAdapterPtr_ =
|
||
new TjdUITransformListGroupAdapter<TimeOrDistRemindItemInfo, TimeOrDistRemindItemView,
|
||
std::list<TimeOrDistRemindItemInfo>>(distanceListItemInfo_);
|
||
distanceListView_ = new TjdUITransformListGroup(distanceAdapterPtr_);
|
||
distanceListView_->AddCustomView(&distRemindTitle_, TjdUITransformListGroup::CustomViewPos::TITLE);
|
||
distanceListView_->SetTitleOffset(80);
|
||
|
||
Add(distanceListView_);
|
||
}
|
||
|
||
void DistanceRemindPickView::ShowView()
|
||
{
|
||
distanceListView_->RefreshList();
|
||
OHOS::FocusManager::GetInstance()->ClearFocus();
|
||
distanceListView_->RequestFocus();
|
||
SetVisible(true);
|
||
}
|
||
void DistanceRemindPickView::HideView()
|
||
{
|
||
// g_pv_SportGoal[TjdUiAppSportView::currentIconIndex_].distRemindGoal =
|
||
// std::string(g_pv_DistanceRemindItemInfo[curSelectDistanceIndex].content);
|
||
for (uint8_t k = 0; k < MAX_DISTANCE_INDEX; k++) {
|
||
if (g_DistanceReminder[TjdUiAppSportView::currentIconIndex_][k])
|
||
g_pv_SportGoal[TjdUiAppSportView::currentIconIndex_].distRemindGoal =
|
||
std::string(FontGlobalManager::GetInstance()->GetText(g_pv_DistanceRemindItemInfo[k].contentId));
|
||
}
|
||
SetVisible(false);
|
||
sql_fit_set_sport_dist_remind_value(curSelectDistanceIndex);
|
||
}
|
||
|
||
DistanceRemindPickView::~DistanceRemindPickView()
|
||
{
|
||
RemoveAll();
|
||
|
||
if (distanceAdapterPtr_ != nullptr) {
|
||
delete distanceAdapterPtr_;
|
||
distanceAdapterPtr_ = nullptr;
|
||
}
|
||
|
||
if (distanceListView_ != nullptr) {
|
||
distanceListView_->RemoveAll();
|
||
delete distanceListView_;
|
||
distanceListView_ = nullptr;
|
||
}
|
||
};
|
||
#pragma endregion
|
||
|
||
#pragma region 运动消息弹窗
|
||
// ----------------------------------------------------------------------------
|
||
static void popupTimerCallBack(void *data)
|
||
{
|
||
static_print_info("popupTimerCallBack\n");
|
||
if (popupTimer_ != nullptr) {
|
||
popupTimer_->Stop();
|
||
delete popupTimer_;
|
||
popupTimer_ = nullptr;
|
||
}
|
||
NotificationManager::GetInstance()->StopNotify();
|
||
// view.SetVisible(false);
|
||
}
|
||
|
||
// 运动消息弹窗
|
||
bool SportPopupWindowListener::OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event)
|
||
{
|
||
static_print_info("sport popup window click\n");
|
||
if (popupTimer_ != nullptr) {
|
||
popupTimer_->Stop();
|
||
delete popupTimer_;
|
||
popupTimer_ = nullptr;
|
||
}
|
||
tjd_driver_motor_user_stop();
|
||
NotificationManager::GetInstance()->StopNotify();
|
||
view.SetVisible(false);
|
||
return true;
|
||
}
|
||
|
||
bool SportPopupWindowListener::OnKeyAct(OHOS::UIView &view, const OHOS::KeyEvent &event)
|
||
{
|
||
if (popupTimer_ != nullptr) {
|
||
popupTimer_->Stop();
|
||
delete popupTimer_;
|
||
popupTimer_ = nullptr;
|
||
}
|
||
|
||
if (!TjdUiCommonOnKeyListener::CheckIsExitEvent(event)) {
|
||
return true;
|
||
}
|
||
NotificationManager::GetInstance()->StopNotify();
|
||
return true;
|
||
}
|
||
|
||
SportPopupWindow::SportPopupWindow(PopupMsgType msgType, char *goal)
|
||
{
|
||
SetPosition(0, 0, OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
||
SetViewId("SportPopupWindow");
|
||
SetTouchable(true);
|
||
SetOnClickListener(&onclickListener_);
|
||
OHOS::RootView::GetInstance()->SetOnKeyActListener(&onkeyListener_);
|
||
|
||
std::ostringstream oss;
|
||
std::string goalStr;
|
||
static_print_info("===SportPopupWindow::SportPopupWindow\n");
|
||
auto imgInfo = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(
|
||
g_pv_Sport[TjdUiAppSportView::currentIconIndex_].imgIconResId, SPORT_IMAGE_BIN_PATH);
|
||
|
||
UIDrawImageScale(&sportIcon_, 183, 20, imgInfo, 0.6, 0.6, 30, 30);
|
||
|
||
switch (msgType) {
|
||
case SPORT_POPUP_MSG_TYPE_TIME:
|
||
case SPORT_POPUP_MSG_TYPE_DISTANCE:
|
||
case SPORT_POPUP_MSG_TYPE_CALORIES:
|
||
imgInfo = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_SPORT_ACHIEVE, SPORT_IMAGE_BIN_PATH);
|
||
UiDrawImage(&achieveIcon_, 151, 134, imgInfo);
|
||
|
||
// InitLabelHorCenter(tip_, 28, 333, 466, "达成目标");
|
||
tip_.SetFont(TJD_VECTOR_FONT_FILENAME, 28);
|
||
tip_.SetTextId(STR_ID_210);
|
||
tip_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_ADAPT);
|
||
tip_.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
||
tip_.SetPosition((OHOS::HORIZONTAL_RESOLUTION - tip_.GetWidth()) / 2, 333);
|
||
|
||
// InitLabelHorCenter(popupContent_, 50, 372, 466, goal, 0xFFEA28FF);
|
||
popupContent_.SetFont(TJD_VECTOR_FONT_FILENAME, 50);
|
||
popupContent_.SetText(goal);
|
||
popupContent_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_WRAP);
|
||
popupContent_.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
||
popupContent_.SetPosition(50, 372, 366, 70);
|
||
popupContent_.SetTextColor(Color::GetColorFromRGBA(
|
||
static_cast<uint8_t>((0xFFEA28FF >> 24) & 0xFF), static_cast<uint8_t>((0xFFEA28FF >> 16) & 0xFF),
|
||
static_cast<uint8_t>((0xFFEA28FF >> 8) & 0xFF), static_cast<uint8_t>(0xFFEA28FF & 0xFF)));
|
||
|
||
Add(&tip_);
|
||
Add(&achieveIcon_);
|
||
break;
|
||
case SPORT_POPUP_MSG_TYPE_PER_DISTANCE:
|
||
// oss << "已运动" << goal << "m,\n请继续加油!";
|
||
oss << FontGlobalManager::GetInstance()->GetText(STR_ID_214) << goal << "m,"
|
||
<< FontGlobalManager::GetInstance()->GetText(STR_ID_215);
|
||
goalStr = oss.str();
|
||
imgInfo = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_SPORT_ENCOURAGE, SPORT_IMAGE_BIN_PATH);
|
||
UiDrawImage(&distanceIcon_, 171, 149, imgInfo);
|
||
// InitLabelHorCenter(popupContent_, 28, 311, 466, goalStr.c_str());
|
||
popupContent_.SetFont(TJD_VECTOR_FONT_FILENAME, 28);
|
||
popupContent_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_WRAP);
|
||
popupContent_.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
||
popupContent_.SetPosition(50, 311, 366, 40);
|
||
popupContent_.SetText(goalStr.c_str());
|
||
|
||
Add(&distanceIcon_);
|
||
break;
|
||
case SPORT_POPUP_MSG_TYPE_PER_TIME:
|
||
// oss << "已运动" << goal << ",\n请继续加油!";
|
||
oss << FontGlobalManager::GetInstance()->GetText(STR_ID_214) << goal << ","
|
||
<< FontGlobalManager::GetInstance()->GetText(STR_ID_215);
|
||
goalStr = oss.str();
|
||
imgInfo = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_SPORT_ENCOURAGE, SPORT_IMAGE_BIN_PATH);
|
||
UiDrawImage(&timeIcon_, 171, 149, imgInfo);
|
||
// InitLabelHorCenter(popupContent_, 28, 311, 466, goalStr.c_str());
|
||
popupContent_.SetFont(TJD_VECTOR_FONT_FILENAME, 28);
|
||
popupContent_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_WRAP);
|
||
popupContent_.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
||
popupContent_.SetPosition(50, 311, 366, 40);
|
||
popupContent_.SetText(goalStr.c_str());
|
||
|
||
Add(&timeIcon_);
|
||
break;
|
||
case SPORT_POPUP_MSG_TYPE_PER_HEARTRATE_TYPE_1:
|
||
case SPORT_POPUP_MSG_TYPE_PER_HEARTRATE_TYPE_2:
|
||
case SPORT_POPUP_MSG_TYPE_PER_HEARTRATE_TYPE_3:
|
||
case SPORT_POPUP_MSG_TYPE_PER_HEARTRATE_TYPE_4:
|
||
switch (msgType) {
|
||
case SPORT_POPUP_MSG_TYPE_PER_HEARTRATE_TYPE_1:
|
||
popupContent_.SetTextId(STR_ID_211);
|
||
imgInfo = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_SPORT_ICON_HR, SPORT_IMAGE_BIN_PATH);
|
||
break;
|
||
case SPORT_POPUP_MSG_TYPE_PER_HEARTRATE_TYPE_2:
|
||
popupContent_.SetTextId(STR_ID_212);
|
||
imgInfo = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_SPORT_ICON_HR, SPORT_IMAGE_BIN_PATH);
|
||
break;
|
||
case SPORT_POPUP_MSG_TYPE_PER_HEARTRATE_TYPE_3:
|
||
popupContent_.SetTextId(STR_ID_213);
|
||
imgInfo = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_SPORT_ICON_HR, SPORT_IMAGE_BIN_PATH);
|
||
break;
|
||
case SPORT_POPUP_MSG_TYPE_PER_HEARTRATE_TYPE_4:
|
||
popupContent_.SetTextId(STR_ID_216);
|
||
imgInfo = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_SPORT_ICON_HR_WARNING,
|
||
SPORT_IMAGE_BIN_PATH);
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
goalStr = oss.str();
|
||
UiDrawImage(&heartrateIcon_, 155, 127, imgInfo);
|
||
// InitLabelHorCenter(popupContent_, 28, 296, 466, goalStr.c_str());
|
||
popupContent_.SetFont(TJD_VECTOR_FONT_FILENAME, 28);
|
||
popupContent_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_WRAP);
|
||
popupContent_.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
||
popupContent_.SetPosition(50, 296, 366, 40);
|
||
|
||
Add(&heartrateIcon_);
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
|
||
if (popupTimer_ == nullptr) {
|
||
popupTimer_ = new OHOS::GraphicTimer(5000, popupTimerCallBack, nullptr, false);
|
||
}
|
||
popupTimer_->Start();
|
||
|
||
motor_param_t motorParam = {.cycle1_on = 2000, .cycle1_off = 0, .cycle1_cnt = 1, .duty = 100};
|
||
tjd_driver_motor_user_start(&motorParam);
|
||
|
||
Add(&popupContent_);
|
||
Add(&sportIcon_);
|
||
}
|
||
#pragma endregion
|
||
|
||
#pragma region 运动结束提醒
|
||
static void finishiTimerCallBack(void *data)
|
||
{
|
||
static_print_info("finishiTimerCallBack\n");
|
||
if (finishTimer_ != nullptr) {
|
||
finishTimer_->Stop();
|
||
delete finishTimer_;
|
||
finishTimer_ = nullptr;
|
||
}
|
||
NotificationManager::GetInstance()->StopNotify();
|
||
// view.SetVisible(false);
|
||
}
|
||
|
||
bool SportFinishRemindOnclickListener::OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event)
|
||
{
|
||
static_print_info("SportFinishRemindOnclickListener OnClick\n");
|
||
if (view.GetViewId() == "image_cancel") {
|
||
static_print_info("SportFinishRemindOnclickListener OnClick cancel\n");
|
||
view.GetParent()->SetVisible(false);
|
||
NotificationManager::GetInstance()->StopNotify();
|
||
} else if (view.GetViewId() == "image_confirm") {
|
||
static_print_info("SportFinishRemindOnclickListener OnClick confirm\n");
|
||
// view.GetParent()->SetVisible(false);
|
||
auto sportView = TjdUiAppSportView::GetInstance();
|
||
sportView->ShowTargetView(SPORT_END_DATA_VIEW);
|
||
NotificationManager::GetInstance()->StopNotify();
|
||
}
|
||
return true;
|
||
}
|
||
|
||
bool SportFinishRemindOnclickListener::OnKeyAct(OHOS::UIView &view, const OHOS::KeyEvent &event)
|
||
{
|
||
static_print_info("SportFinishRemindOnclickListener::OnKeyAct\n");
|
||
if (event.GetState() == OHOS::InputDevice::STATE_RELEASE) {
|
||
if (finishTimer_ != nullptr) {
|
||
finishTimer_->Stop();
|
||
delete finishTimer_;
|
||
finishTimer_ = nullptr;
|
||
}
|
||
NotificationManager::GetInstance()->StopNotify();
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
SportFinishRemindView::SportFinishRemindView(uint8_t time_stamp)
|
||
{
|
||
SetPosition(0, 0, OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
||
OHOS::RootView::GetInstance()->SetOnKeyActListener(&onkeyListener_);
|
||
|
||
std::string finalContent =
|
||
std::string("您已经") + std::to_string(time_stamp) + std::string("分钟未运动\n是否结束运动?");
|
||
InitLabelHorCenter(remindContent_, 34, 196, 466, finalContent.c_str());
|
||
|
||
auto image = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_CONFIRM_CANCEL_CANCEL,
|
||
CONFIRM_CANCEL_RES_BIN_PATH);
|
||
cancelImage_.SetPosition(103, 326);
|
||
if (image != nullptr) {
|
||
cancelImage_.SetSrc(image);
|
||
}
|
||
cancelImage_.SetTouchable(true);
|
||
cancelImage_.SetViewId("image_cancel");
|
||
cancelImage_.SetOnClickListener(&listener_);
|
||
|
||
image = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_CONFIRM_CANCEL_CONFIRM,
|
||
CONFIRM_CANCEL_RES_BIN_PATH);
|
||
confirmImage_.SetPosition(271, 326);
|
||
if (image != nullptr) {
|
||
confirmImage_.SetSrc(image);
|
||
}
|
||
confirmImage_.SetViewId("image_confirm");
|
||
confirmImage_.SetTouchable(true);
|
||
confirmImage_.SetOnClickListener(&listener_);
|
||
|
||
if (finishTimer_ == nullptr) {
|
||
finishTimer_ = new OHOS::GraphicTimer(5000, finishiTimerCallBack, nullptr, false);
|
||
}
|
||
finishTimer_->Start();
|
||
|
||
Add(&remindContent_);
|
||
Add(&cancelImage_);
|
||
Add(&confirmImage_);
|
||
}
|
||
|
||
SportFinishRemindView::~SportFinishRemindView()
|
||
{
|
||
static_print_info("SportFinishRemindView::~SportFinishRemindView\n");
|
||
if (finishTimer_ != nullptr) {
|
||
finishTimer_->Stop();
|
||
delete finishTimer_;
|
||
finishTimer_ = nullptr;
|
||
}
|
||
RemoveAll();
|
||
ImageCacheManager::GetInstance().UnloadAllInMultiRes(CONFIRM_CANCEL_RES_BIN_PATH);
|
||
};
|
||
#pragma endregion
|
||
|
||
#pragma region 运动目标页
|
||
#pragma endregion
|
||
|
||
#pragma region 运动目标页
|
||
#pragma endregion
|
||
|
||
#pragma region 运动目标页
|
||
#pragma endregion
|
||
|
||
} // namespace TJD
|