bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件
void OnSwipe(UISwipeView &view) override;
- GoalModel *weatherModel{nullptr};
+ GoalModel *GoalModelModel{nullptr};
bool X_DRAG_FLAG{false};
};
} // namespace OHOS
void ClearAll();
bool GetInitViewState(void);
void GoalViewrefresh();
+ ImageAnimatorInfo PullUpimageAnimatorInfo[70]{0};
private:
UILabelExt *InitLabelExt(int x, int y, int w, int h, const char *text, int textfont, int lineheight);
private:
- const char **CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages);
+ void CreateImagePathsArray(const char **,const char *basePath, const char *fileExtension, int numImages);
void FreeImagePathsArray(const char **imagePaths, const int numImages);
+
private:
UICircleProgress * circleProgress1_{nullptr}; //步数进度条
UIImageView* circleProgressimage{nullptr};
UIImageAnimatorView *PullUpAnimatorView{nullptr}; // 上拉动画
UIImageAnimatorView *stepAnimatorView{nullptr}; // 走路动画
- const char **PullUpPathsArray{nullptr};
- const char **goalPathsArray{nullptr};
+ ImageAnimatorInfo goalAnimatorInfo[20]{0};
+
+ const char *PullUpPathsArray[70]{nullptr};
+ const char *goalPathsArray[20]{nullptr};
bool viewInitStatus{false};
};
} // namespace OHOS
MaingoalPresenter::MaingoalPresenter()
{
- weatherModel = &GoalModel::GetInstance();
+ GoalModelModel = &GoalModel::GetInstance();
g_pMainWeatherPresenter = this;
#ifdef MEM_CHECK
MemCheck::GetInstance()->EnableLeakCheck(true);
MaingoalPresenter::~MaingoalPresenter()
{
g_pMainWeatherPresenter = nullptr;
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MaingoalPresenter::~MaingoalPresenter");
#ifdef MEM_CHECK
MemCheck::GetInstance()->EnableLeakCheck(false);
#endif
MaingoalrView::~MaingoalrView()
{
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MaingoalrView::~MaingoalrView");
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MaingoalrView::~MaingoalrView");
ClearAll();
g_pgoalView = nullptr;
}
void MaingoalrView::ClearAll(void)
{
- if (goalSwipeViewList != nullptr)
+
+ if(goalSwipeViewList)
{
- for (int32_t i = 0; i < maxPage; i++)
- {
- recordCard[i] = nullptr;
- }
goalSwipeViewList->RemoveAll();
delete goalView;
delete goalhintView;
goalhintView = nullptr;
-
+
delete goalSwipeViewList;
goalSwipeViewList = nullptr;
+
+ for (int32_t i = 0; i < 3; i++)
+ {
+ recordCard[i] = nullptr;
+ }
}
+
}
return goalSwipeViewList;
}
- // 获取天气页面视图
UIView *MaingoalrView::GetGoalPageView()
{
void MaingoalrView::OnStop()
{
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MaingoalrView OnStop!!");
+
View<MaingoalPresenter>::OnStop();
RootView::GetInstance()->ClearOnKeyActListener();
RootView::GetInstance()->RemoveAll();
+
return;
}
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MaingoalrView::new goalView fail!");
return nullptr;
}
-
return goalView;
}
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MaingoalrView::new goalView fail!");
return nullptr;
}
-
return goalhintView;
}
AppGroupView *view = nullptr;
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CreatePage WeatherPageId:%d", WeatherPageId);
- for (i = 0; i < sizeof(g_pageMapper) / sizeof(g_pageMapper[0]); i++)
+ for (i = 0; i < 3;i++)
+ //sizeof(g_pageMapper) / sizeof(g_pageMapper[0]); i++)
{
if (g_pageMapper[i].viewId == WeatherPageId)
{ // 正确使用 WeatherPageId 来匹配视图ID
view = (this->*(g_pageMapper[i].func))(); // 如果找到匹配项,则调用相应的函数创建视图
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CreatePage view:%p", view);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreatePage view:%p", view);
return view; // 返回创建的视图
}
}
#include "ConfigModel.h"
#include "goal/include/goalmodel.h"
#include "common/image_cache_manager.h"
+#include "goal/include/goalview.h"
/*
当至天气界面时,主动获取最新天气数据。
(此操作静默将进行,获取到则立刻更新显示,获取不到则重试
static constexpr int16_t PULLUP_ANIMATOR_VIEW_H = 40;
static constexpr int16_t PULLUP_ANIMATOR_VIEW_NUM_FRAMES = 70;
static constexpr int16_t PULLUP_ANIMATOR_VIEW_TIME = 100;
- static ImageAnimatorInfo PullUpimageAnimatorInfo[PULLUP_ANIMATOR_VIEW_NUM_FRAMES];
+ //static ImageAnimatorInfo PullUpimageAnimatorInfo[PULLUP_ANIMATOR_VIEW_NUM_FRAMES];
static ImageAnimatorInfo goalAnimatorInfo[20];
static constexpr const char *PullUpPaths = "/user/res/weather/PullUp/PullUp_";
void GoalotherView::GoalViewrefresh()
{
+ if(mileagenowdataLabel)
mileagenowdataLabel->SetText(GoalModel::GetInstance().getdistancenew());
+ if(mileagegoaldataLabel)
mileagegoaldataLabel->SetText(GoalModel::GetInstance().getdistanceGoal());
-
+ if(fatburningnowdataLabel)
fatburningnowdataLabel->SetText(GoalModel::GetInstance().getfatburningnew());
+ if(fatburninggoaldataLabel)
fatburninggoaldataLabel->SetText(GoalModel::GetInstance().getfatburninggoal());
-
+ if(standnowdataLabel)
standnowdataLabel->SetText(GoalModel::GetInstance().getstandnew());
+ if(standgoaldataLabel)
standgoaldataLabel->SetText(GoalModel::GetInstance().getstandgoal());
-
+ if(calorienowdataLabel)
calorienowdataLabel->SetText(GoalModel::GetInstance().getcaloriespnew());
+ if(caloriegoaldataLabel)
caloriegoaldataLabel->SetText(GoalModel::GetInstance().getcaloriesGoal());
Invalidate();
delete PullUpAnimatorView;
PullUpAnimatorView = nullptr;
}
- FreeImagePathsArray(PullUpPathsArray, PULLUP_ANIMATOR_VIEW_NUM_FRAMES);
+ //FreeImagePathsArray(PullUpPathsArray, PULLUP_ANIMATOR_VIEW_NUM_FRAMES);
}
caloriegoaldataLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40);
caloriegoaldataLabel->SetVisible(true);
- PullUpPathsArray = CreateImagePathsArray(PullUpPaths, "bin", PULLUP_ANIMATOR_VIEW_NUM_FRAMES);
if (PullUpAnimatorView == nullptr)
{
PullUpAnimatorView = new UIImageAnimatorView();
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PullUpAnimatorView new fail");
return false;
}
- for (uint8_t i = 0; i < PULLUP_ANIMATOR_VIEW_NUM_FRAMES; i++)
+ if(GoalView::GetInstance()==nullptr)
{
- PullUpimageAnimatorInfo[i].imageInfo = ImageCacheManager::GetInstance().LoadSingleRes(PullUpPathsArray[i]);
- PullUpimageAnimatorInfo[i].imageType = IMG_SRC_IMAGE_INFO;
- PullUpimageAnimatorInfo[i].pos.x = PULLUP_ANIMATOR_VIEW_X;
- PullUpimageAnimatorInfo[i].pos.y = PULLUP_ANIMATOR_VIEW_Y;
- PullUpimageAnimatorInfo[i].width = PULLUP_ANIMATOR_VIEW_W;
- PullUpimageAnimatorInfo[i].height = PULLUP_ANIMATOR_VIEW_H;
+ // PullUpPathsArray = CreateImagePathsArray(PullUpPaths, "bin", PULLUP_ANIMATOR_VIEW_NUM_FRAMES);
+ // for (uint8_t i = 0; i < PULLUP_ANIMATOR_VIEW_NUM_FRAMES; i++)
+ // {
+ // PullUpimageAnimatorInfo[i].imageInfo = ImageCacheManager::GetInstance().LoadSingleRes(PullUpPathsArray[i]);
+ // PullUpimageAnimatorInfo[i].imageType = IMG_SRC_IMAGE_INFO;
+ // PullUpimageAnimatorInfo[i].pos.x = PULLUP_ANIMATOR_VIEW_X;
+ // PullUpimageAnimatorInfo[i].pos.y = PULLUP_ANIMATOR_VIEW_Y;
+ // PullUpimageAnimatorInfo[i].width = PULLUP_ANIMATOR_VIEW_W;
+ // PullUpimageAnimatorInfo[i].height = PULLUP_ANIMATOR_VIEW_H;
+ // }
+ // PullUpAnimatorView->SetPosition(PULLUP_ANIMATOR_VIEW_X, PULLUP_ANIMATOR_VIEW_Y, PULLUP_ANIMATOR_VIEW_W, PULLUP_ANIMATOR_VIEW_H);
+ // PullUpAnimatorView->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
+ // PullUpAnimatorView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+ return false;
+
}
- PullUpAnimatorView->SetPosition(PULLUP_ANIMATOR_VIEW_X, PULLUP_ANIMATOR_VIEW_Y, PULLUP_ANIMATOR_VIEW_W, PULLUP_ANIMATOR_VIEW_H);
- PullUpAnimatorView->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
- PullUpAnimatorView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
- PullUpAnimatorView->SetImageAnimatorSrc(PullUpimageAnimatorInfo, PULLUP_ANIMATOR_VIEW_NUM_FRAMES, PULLUP_ANIMATOR_VIEW_TIME);
+ PullUpAnimatorView->SetImageAnimatorSrc(GoalView::GetInstance()->PullUpimageAnimatorInfo, PULLUP_ANIMATOR_VIEW_NUM_FRAMES, PULLUP_ANIMATOR_VIEW_TIME);
PullUpAnimatorView->SetRepeat(true);
PullUpAnimatorView->Start();
}
for (int i = 0; i < numImages; i++)
{
ImageCacheManager::GetInstance().UnloadSingleRes(imagePaths[i]);
- delete imagePaths[i];
+ if(imagePaths[i])
+ free( (void *)imagePaths[i]);
imagePaths[i] = nullptr;
}
+ delete imagePaths;
+ imagePaths = nullptr;
}
}
\ No newline at end of file
#include "ConfigModel.h"
#include "goal/include/goalmodel.h"
#include "common/image_cache_manager.h"
+#include "gfx_utils/mem_api.h"
/*
当至天气界面时,主动获取最新天气数据。
(此操作静默将进行,获取到则立刻更新显示,获取不到则重试
static constexpr int16_t PULLUP_ANIMATOR_VIEW_H = 40;
static constexpr int16_t PULLUP_ANIMATOR_VIEW_NUM_FRAMES = 70;
static constexpr int16_t PULLUP_ANIMATOR_VIEW_TIME = 100;
- static ImageAnimatorInfo PullUpimageAnimatorInfo[PULLUP_ANIMATOR_VIEW_NUM_FRAMES];
-
- static ImageAnimatorInfo goalAnimatorInfo[20];
+
+
static constexpr const char *PullUpPaths = "/user/res/weather/PullUp/PullUp_";
static constexpr const char *stepPaths = "/user/res/step/";
void GoalView::GoalViewrefresh()
{
+ if(nowstepLabel)
nowstepLabel->SetText(GoalModel::GetInstance().getstepnew());
+ if(goalstepLabel)
goalstepLabel->SetText(GoalModel::GetInstance().getstepGoal());
+ if(circleProgress1_)
circleProgress1_->SetValue(GoalModel::GetInstance().getstepvalue());
Invalidate();
if (stepAnimatorView != nullptr)
{
stepAnimatorView->Stop();
+ //stepAnimatorView->ClearImagesCache();
delete stepAnimatorView;
stepAnimatorView = nullptr;
}
delete circleProgressimage;
circleProgressimage = nullptr;
}
-
+ // for(int i=0;i<20;i++)
+ // {
+
+ // }
+ ImageCacheManager::GetInstance().UnloadSingleRes("/user/res/step/step_b.bin");
+
FreeImagePathsArray(PullUpPathsArray, PULLUP_ANIMATOR_VIEW_NUM_FRAMES);
FreeImagePathsArray(goalPathsArray, 20);
+
+ // if(goalAnimatorInfo)
+ // {
+
+ // delete goalAnimatorInfo;
+ // goalAnimatorInfo= nullptr;
+ // }
}
// 初始化天气页面
bool GoalView::InitPage(void)
{
-
-
+
/* --------------------------------goalTitle--------------------------------- */
if (goalTitle == nullptr) {
goalTitle = new UILabelExt();
char* image5imagesPath = "/user/res/step/step_b.bin";
-
- circleProgressimage->SetSrc(image5imagesPath);
+ ImageInfo *info= ImageCacheManager::GetInstance().LoadSingleRes(image5imagesPath);
+ circleProgressimage->SetSrc(info);
// Add to rootView
circleProgress1_->SetCapType(CAP_ROUND);
/*----------------------------------------------------------------------------- */
- goalPathsArray = CreateImagePathsArray(stepPaths, "bin", 20);
+ CreateImagePathsArray(goalPathsArray,stepPaths, "bin", 20);
if (stepAnimatorView == nullptr)
{
stepAnimatorView = new UIImageAnimatorView();
{
//goalAnimatorInfo[i].imageInfo = ImageCacheManager::GetInstance().LoadSingleRes(goalPathsArray[i]);
//goalAnimatorInfo[i].imageType = IMG_SRC_IMAGE_INFO;
- goalAnimatorInfo[i].imagePath = goalPathsArray[i];
- goalAnimatorInfo[i].imageType = IMG_SRC_FILE_PATH;
+ //goalAnimatorInfo=new ImageAnimatorInfo [20];
+ //goalAnimatorInfo[i].imageInfo=nullptr;
+ goalAnimatorInfo[i].imageInfo = ImageCacheManager::GetInstance().LoadSingleRes(goalPathsArray[i]);
+ goalAnimatorInfo[i].imageType = IMG_SRC_IMAGE_INFO;
+
+ //goalAnimatorInfo[i].imagePath = goalPathsArray[i];
+ //goalAnimatorInfo[i].imageInfo=nullptr;
+ //goalAnimatorInfo[i].imageType = IMG_SRC_FILE_PATH;
goalAnimatorInfo[i].pos.x = 193;
goalAnimatorInfo[i].pos.y = 90;
goalAnimatorInfo[i].width = 100;
goalAnimatorInfo[i].height = 100;
+
}
stepAnimatorView->SetPosition(183, 90, 100, 100);
stepAnimatorView->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
stepAnimatorView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+ //这里出现内存泄露
stepAnimatorView->SetImageAnimatorSrc(goalAnimatorInfo, 20, 50);
+
stepAnimatorView->SetRepeat(true);
stepAnimatorView->Start();
}
- PullUpPathsArray = CreateImagePathsArray(PullUpPaths, "bin", PULLUP_ANIMATOR_VIEW_NUM_FRAMES);
+ CreateImagePathsArray( PullUpPathsArray,PullUpPaths, "bin", PULLUP_ANIMATOR_VIEW_NUM_FRAMES);
if (PullUpAnimatorView == nullptr)
{
PullUpAnimatorView = new UIImageAnimatorView();
{
//PullUpimageAnimatorInfo[i].imageInfo = ImageCacheManager::GetInstance().LoadSingleRes(PullUpPathsArray[i]);
//PullUpimageAnimatorInfo[i].imageType = IMG_SRC_IMAGE_INFO;
- PullUpimageAnimatorInfo[i].imagePath = PullUpPathsArray[i];
- PullUpimageAnimatorInfo[i].imageType = IMG_SRC_FILE_PATH;
+ PullUpimageAnimatorInfo[i].imageInfo = ImageCacheManager::GetInstance().LoadSingleRes(PullUpPathsArray[i]);
+ //PullUpPathsArray[i];
+ PullUpimageAnimatorInfo[i].imageType = IMG_SRC_IMAGE_INFO;
PullUpimageAnimatorInfo[i].pos.x = PULLUP_ANIMATOR_VIEW_X;
PullUpimageAnimatorInfo[i].pos.y = PULLUP_ANIMATOR_VIEW_Y;
PullUpimageAnimatorInfo[i].width = PULLUP_ANIMATOR_VIEW_W;
}
- const char **GoalView::CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages)
+ void GoalView::CreateImagePathsArray(const char **imagePaths,const char *basePath, const char *fileExtension, int numImages)
{
- const char **imagePaths = new const char *[numImages];
+ //const char **imagePaths = new const char *[numImages];
char buffer[256];
for (int i = 0; i < numImages; i++)
{
+ imagePaths[i]=(char *)UIMalloc(128);
+ memset_s((void *)imagePaths[i],128,0,128);
snprintf(buffer, sizeof(buffer), "%s%d.%s", basePath, i + 1, fileExtension);
- imagePaths[i] = strdup(buffer);
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " imagePaths[%d] = %s", i, imagePaths[i]);
+ memcpy_s((void*)imagePaths[i],128,(void*)buffer,128);
+ // imagePaths[i] = strdup(buffer);
+ //WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " imagePaths[%d] = %s", i, imagePaths[i]);
}
- return imagePaths;
+ return ;
}
/*
for (int i = 0; i < numImages; i++)
{
//ImageCacheManager::GetInstance().UnloadSingleRes(imagePaths[i]);
- delete imagePaths[i];
- imagePaths[i] = nullptr;
+ ImageCacheManager::GetInstance().UnloadSingleRes(imagePaths[i]);
+
+ if(imagePaths[i])
+ UIFree((void*)imagePaths[i]);
+ //imagePaths[i] = nullptr;
}
+ // delete[] imagePaths;
+ // imagePaths=nullptr;
}
}
\ No newline at end of file
alarm_UILabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
alarm_UILabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
alarm_UILabel->SetRollSpeed(0);
- alarm_UILabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 33);
+ alarm_UILabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
osStatus_t retTimer;
low_power_timer = osTimerNew((osTimerFunc_t)low_power_TimerCallBack, osTimerPeriodic, NULL, NULL);
retTimer = osTimerStart(low_power_timer, 1000*1);
// Set additional property
alarm_labelbutton->SetText("确认");
alarm_labelbutton->SetTextId(STR_KONW);
- alarm_labelbutton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 44);
+ alarm_labelbutton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
alarm_labelbutton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
UIView::OnClickListener *button1Click = static_cast<UIView::OnClickListener *>(lowppowrViewEventListener::GetInstance());