void StopTimer(void);
void StartTimer(uint32_t interval = 2 * 1000);//2秒
void StartReminderHideTimer(uint32_t intervalMs = 1000);
+ void StopReminderHideTimer(void);
void StartOtaCountdown(uint32_t startVal);
void StopOtaCountdown(void);
void StartCountUpTimer(uint32_t targetSeconds);
// 对话相关函数
bool StartRecording(std::string audioPath);
bool StopRecording();
+ bool IsRecording() const;
bool SendRecording();
bool ReceiveAnswer();
std::string GetConversationText();
{
if (group != nullptr)
{
+ // 移除所有子组件
group->RemoveAll();
+
+ // 删除子组件
+ if (TextLabel != nullptr) {
+ delete TextLabel;
+ TextLabel = nullptr;
+ }
+ if (TextLabel_Y != nullptr) {
+ delete TextLabel_Y;
+ TextLabel_Y = nullptr;
+ }
+ if (RemindLabel != nullptr) {
+ delete RemindLabel;
+ RemindLabel = nullptr;
+ }
+ if (RemindIcon != nullptr) {
+ delete RemindIcon;
+ RemindIcon = nullptr;
+ }
+ if (RemindIcon2 != nullptr) {
+ delete RemindIcon2;
+ RemindIcon2 = nullptr;
+ }
+ if (listenAnimator != nullptr) {
+ delete listenAnimator;
+ listenAnimator = nullptr;
+ }
+
+ // 最后删除group
delete group;
group = nullptr;
}
- if (TextLabel != nullptr) { delete TextLabel; TextLabel = nullptr; }
- if (TextLabel_Y != nullptr) { delete TextLabel_Y; TextLabel_Y = nullptr; }
- if (RemindLabel != nullptr) { delete RemindLabel; RemindLabel = nullptr; }
- if (RemindIcon != nullptr) { delete RemindIcon; RemindIcon = nullptr; }
- if (RemindIcon2 != nullptr) { delete RemindIcon2; RemindIcon2 = nullptr; }
- if (listenAnimator != nullptr) { delete listenAnimator; listenAnimator = nullptr; }
}
bool ThunderBirdLullabyView::EnsureListenAnimator()
{
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView::ThunderBirdMainView");
g_pThunderBirdMainView = this;
- ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); // 打开屏幕常亮
+ //ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); // 打开屏幕常亮
ThunderBirdModel::GetInstance()->StartTimer();
}
ScrollView_ = nullptr;
}
g_pThunderBirdMainView = nullptr;
- ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); // 关闭屏幕常亮
+ //ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); // 关闭屏幕常亮
ThunderBirdModel::GetInstance()->StopTimer();
}
void ThunderBirdMainView::DeInit()
{
+ // 先清理所有group,确保UI组件正确移除
+ for (int i = 0; i < MAXVIEW; i++)
+ {
+ if (group[i] != nullptr && ScrollView_ != nullptr)
+ {
+ ScrollView_->Remove(group[i]);
+ group[i] = nullptr;
+ }
+ }
+
// 释放各子界面对象
if (g_pThunderBirdOtaView)
{
delete g_pThunderBirdShutdownView;
g_pThunderBirdShutdownView = nullptr;
}
- if (g_pThunderBirdShutdownView)
- {
- delete g_pThunderBirdShutdownView;
- g_pThunderBirdShutdownView = nullptr;
- }
- // 置空所有分组索引,避免悬空指针
- for (int i = 0; i < MAXVIEW; i++)
- {
- group[i] = nullptr;
- }
// 不再持有旧 View 实例,全部使用聚合组件
// 先停止视频播放
if (curFace != nullptr)
{
+ // 先从父组件中移除
+ if (ScrollView_ != nullptr) {
+ ScrollView_->Remove(curFace);
+ }
delete curFace;
curFace = nullptr;
}
if (surfaceView_ != nullptr)
{
+ // 先从父组件中移除
+ if (ScrollView_ != nullptr) {
+ ScrollView_->Remove(surfaceView_);
+ }
delete surfaceView_;
surfaceView_ = nullptr;
}
// 清理顶部状态UI group1 及其子控件
if (group1 != nullptr)
{
+ // 先从父组件中移除group1
+ if (ScrollView_ != nullptr) {
+ ScrollView_->Remove(group1);
+ }
+
+ // 移除所有子组件
+ group1->RemoveAll();
+
+ // 删除子组件
if (timeLabel != nullptr)
{
delete timeLabel;
delete chargeBatteryicon;
chargeBatteryicon = nullptr;
}
- group1->RemoveAll();
+
+ // 最后删除group1
delete group1;
group1 = nullptr;
}
bool ThunderBirdMainView::SwitchVideo(const char *uri) // 切换表情接口
{
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView::SwitchVideo: Switching to video: %s", uri ? uri : "null");
+
if (uri == nullptr || surfaceView_ == nullptr)
{
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView::SwitchVideo: Invalid parameters");
return false;
}
// 停止并销毁旧播放器
return;
}
curFace->SetAutoEnable(false);
- curFace->SetPosition(0, 0, 360, 360);
+ curFace->SetPosition(0, 0, 360, 243);
curFace->SetResizeMode(UIImageView::COVER);
curFace->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
//curFace->SetStyle(STYLE_BACKGROUND_COLOR, 0xffe0c7c1);
ThunderBirdModel::~ThunderBirdModel()
{
+ // 停止所有定时器
+ StopTimer();
+ StopOtaCountdown();
+ StopCountUpTimer();
+ StopReminderHideTimer();
+
+ // 停止录音
+ if (IsRecording()) {
+ StopRecording();
+ }
+
// 析构时保存提醒数据
// SaveRemindersToFile();
+
+ // 清理字符串资源
+ ClearTextStr();
+ m_reminders.clear();
}
ThunderBirdModel *ThunderBirdModel::GetInstance()
}
}
-
-
+ void ThunderBirdModel::StopReminderHideTimer(void)
+ {
+ if (g_reminderHideTimer != nullptr)
+ {
+ osTimerStop(g_reminderHideTimer);
+ osStatus_t ret = osTimerDelete(g_reminderHideTimer);
+ if (ret != osOK)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StopReminderHideTimer delete failed, ret = %lx!!", ret);
+ }
+ g_reminderHideTimer = nullptr;
+ }
+ }
// ---------------------- OTA 倒计时定时器(5 -> 1,每步1秒,然后监控下载状态) ----------------------
static osTimerId_t g_otaCountdownTimer = nullptr;
return true; // 模拟成功
}
-
+
+ bool ThunderBirdModel::IsRecording() const
+ {
+ return g_isRecording;
+ }
+
bool ThunderBirdModel::StopRecording()
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::StopRecording");
{
if (group != nullptr)
{
+ // 移除所有子组件
group->RemoveAll();
+
+ // 删除子组件
+ if (titleLabel != nullptr) { delete titleLabel; titleLabel = nullptr; }
+ if (TextLabel != nullptr) { delete TextLabel; TextLabel = nullptr; }
+ if (LittleTextLabel != nullptr) { delete LittleTextLabel; LittleTextLabel = nullptr; }
+ if (LittleTextLabel_2 != nullptr) { delete LittleTextLabel_2; LittleTextLabel_2 = nullptr; }
+ if (RemindLabel != nullptr) { delete RemindLabel; RemindLabel = nullptr; }
+ if (RemindIcon != nullptr) { delete RemindIcon; RemindIcon = nullptr; }
+ if (RemindIcon2 != nullptr) { delete RemindIcon2; RemindIcon2 = nullptr; }
+ if (BackGround != nullptr) { delete BackGround; BackGround = nullptr; }
+
+ // 最后删除group
delete group;
group = nullptr;
}
- if (titleLabel != nullptr) { delete titleLabel; titleLabel = nullptr; }
- if (TextLabel != nullptr) { delete TextLabel; TextLabel = nullptr; }
- if (LittleTextLabel != nullptr) { delete LittleTextLabel; LittleTextLabel = nullptr; }
- if (LittleTextLabel_2 != nullptr) { delete LittleTextLabel_2; LittleTextLabel_2 = nullptr; }
- if (RemindLabel != nullptr) { delete RemindLabel; RemindLabel = nullptr; }
- if (RemindIcon != nullptr) { delete RemindIcon; RemindIcon = nullptr; }
- if (RemindIcon2 != nullptr) { delete RemindIcon2; RemindIcon2 = nullptr; }
- if (BackGround != nullptr) { delete BackGround; BackGround = nullptr; }
}
UIViewGroup *ThunderBirdOtaView::ThunderBirdOtaViewInit(void)
ThunderBirdPresenter::~ThunderBirdPresenter()
{
+ // 停止所有定时器和资源
+ ThunderBirdModel::GetInstance()->StopTimer();
+ ThunderBirdModel::GetInstance()->StopOtaCountdown();
+ ThunderBirdModel::GetInstance()->StopCountUpTimer();
+ ThunderBirdModel::GetInstance()->StopReminderHideTimer();
+
+ // 停止录音
+ if (ThunderBirdModel::GetInstance()->IsRecording()) {
+ ThunderBirdModel::GetInstance()->StopRecording();
+ }
+
g_pThunderBirdPresenter = nullptr;
}