#include "custom_utils.h"
#include "traing/training_card/include/Training_CardView.h"
#include "dnotdisturb/include/DnotDisturbModel.h"
+#include "weather/include/WeatherModel.h"
#if USE_OFFLINE_DIAL
#include "DialViewGroup.h"
#endif
}
}
break;
+ case WEATHER:
+ if(WeatherModel::GetInstance().GetWeatherDataIsValid()) {
+ WeatherModel::GetInstance().UpdateWeatherCurTime();
+ }
+ break;
}
}
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-04-08 18:40:20
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-06-19 10:24:03
+ * @LastEditTime: 2024-07-23 14:41:27
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherModel.h
*/
#ifndef WEATHER_MODEL_H
static WeatherModel &GetInstance(void);
void InitFutureWeatherItem();
void TimestampToMonthDayString(time_t timestamp, char *buffer);
+ std::string GetWeatherCurTime();
std::string GetWeatherImage();
std::string GetWeatherTemperature();
std::string GetWeatherDescription();
void SetWeatherDataIsValid(bool value);
/* -------------------------------------------------------------------------- */
void UpdateMainWeatherData(void);
+ void UpdateWeatherCurTime(void);
private:
WeatherModel();
WeatherModel(const WeatherModel &) = delete;
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-03-30 09:14:38
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-06-15 16:31:50
+ * @LastEditTime: 2024-07-23 14:51:03
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherView.h
*/
#ifndef WEATHER_VIEW_H
virtual bool InitView(void *caller) override;
void ClearAll();
bool UpdateWeatherViewData(void);
+ bool UpdateWeatherTime(void);
private:
UILabelExt *InitLabelExt(int x, int y, int w, int h, const char *text, int textfont, int lineheight);
void DumpWeatherInfo();
bool SetImageSource(UIImageView *image, const std::string &source);
bool SetTextLabel(UILabel *label, const std::string &text);
- bool UpdateWeatherTime(void);
bool UpdateWeatherImag(void);
bool UpdateWeatherTemperature(void);
bool UpdateWeatherWeatherDescription(void);
{\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainWeatherPresenter::OnSwipe,current tab index = %d", view.GetCurrentPage());\r
// WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "the view index = %d,dragging direction = %d,current tab index = %d", view.GetViewIndex(), view.GetDirection(), view.GetCurrentPage());\r
- if (view.GetCurrentPage() == WEATHERREPORTVIEW)\r
+ if (view.GetCurrentPage() == MAINWEATHERVIEW)\r
{\r
- //MainWeatherView::GetInstance()->GetFutureWeatherView()->GetFutureWeatherList()->RefreshList();\r
+ WeatherModel::GetInstance().UpdateWeatherCurTime();\r
}\r
}\r
\r
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-04-08 18:40:09
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-06-19 10:24:12
+ * @LastEditTime: 2024-07-23 14:54:46
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherModel.cpp
*/
#include "weather/include/WeatherModel.h"
sprintf(buffer, "%02d.%02d", timeinfo.tm_mon + 1, timeinfo.tm_mday);
}
+ /*获取天气界面的当前时间*/
+ std::string WeatherModel::GetWeatherCurTime()
+ {
+ struct tm pTM;
+ time_t seconds;
+ time(&seconds);
+ localtime_r(&seconds, &pTM);
+
+ int hour = pTM.tm_hour;
+ int minute = pTM.tm_min;
+
+ std::string weatherTime = (hour < 10 ? "0" : "") + std::to_string(hour) + ":" + (minute < 10 ? "0" : "") + std::to_string(minute);
+
+ return weatherTime;
+ }
+
// 获取天气图片
std::string WeatherModel::GetWeatherImage()
{
/* 更新所有天气数据 */
void WeatherModel::UpdateMainWeatherData(void)
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpdateMainWeatherData");
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "UpdateMainWeatherData");
MainWeatherView *p_MainWeatherView = MainWeatherView::GetInstance();
if (p_MainWeatherView != nullptr)
p_WeatherControlView->UpdateWeatherControlViewVisibility();
}
}
+
+ /*更新天气界面的时间显示*/
+ void WeatherModel::UpdateWeatherCurTime(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "UpdateWeatherCurTime");
+ MainWeatherView *p_MainWeatherView = MainWeatherView::GetInstance();
+ if (p_MainWeatherView != nullptr)
+ {
+ p_MainWeatherView->GetWeatherView()->UpdateWeatherTime();
+ }
+ }
}
\ No newline at end of file
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-06-12 11:44:04
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-06-19 10:51:02
+ * @LastEditTime: 2024-07-23 14:44:07
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherView.cpp
*/
#include "weather/include/WeatherView.h"
SetViewIndex(0); // 视图索引
WeatherModel *p_WeatherModel = &WeatherModel::GetInstance();
+ WeatherTime = p_WeatherModel->GetWeatherCurTime();
WeatherImag = p_WeatherModel->GetWeatherImage();
Temperature = p_WeatherModel->GetWeatherTemperature();
WeatherDescription = p_WeatherModel->GetWeatherDescription();
showWeatherImage->SetResizeMode(UIImageView::CONTAIN);
showWeatherImage->SetSrc(WeatherImag.c_str());
/* -------------------------------------------------------------------------- */
- showCurrentTimeLabel = InitLabelExt(CURRENT_TIME_LABEL_X, CURRENT_TIME_LABEL_Y, CURRENT_TIME_LABEL_W, CURRENT_TIME_LABEL_H, "",
+ showCurrentTimeLabel = InitLabelExt(CURRENT_TIME_LABEL_X, CURRENT_TIME_LABEL_Y, CURRENT_TIME_LABEL_W, CURRENT_TIME_LABEL_H, WeatherTime.c_str(),
CURRENT_TIME_LABEL_TEXT_FONT, CURRENT_TIME_LABEL_LINE_HEIGHT);
if (showCurrentTimeLabel == nullptr)
{
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherView::UpdateWeatherTime");
- struct tm pTM;
- time_t seconds;
- time(&seconds);
- localtime_r(&seconds, &pTM);
-
- int hour = pTM.tm_hour;
- int minute = pTM.tm_min;
-
- std::string weatherTime = (hour < 10 ? "0" : "") + std::to_string(hour) + ":" + (minute < 10 ? "0" : "") + std::to_string(minute);
+ std::string weatherTime = WeatherModel::GetInstance().GetWeatherCurTime();
return SetTextLabel(showCurrentTimeLabel, weatherTime);
}