59 lines
1.6 KiB
C++
59 lines
1.6 KiB
C++
/*----------------------------------------------------------------------------
|
|
* Copyright (c) TJD Technologies Co., Ltd. 2024. All rights reserved.
|
|
*
|
|
* Description:
|
|
*
|
|
* Author: huangshuyi
|
|
*
|
|
* Create: 2024-6
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
#ifndef TJDUI_MEM_MANAGE_H
|
|
#define TJDUI_MEM_MANAGE_H
|
|
#include "components/ui_view_group.h"
|
|
|
|
namespace TJD {
|
|
|
|
class TjdUiMemManage {
|
|
public:
|
|
TjdUiMemManage(const TjdUiMemManage &) = delete;
|
|
TjdUiMemManage &operator=(const TjdUiMemManage &) = delete;
|
|
TjdUiMemManage() {}
|
|
virtual ~TjdUiMemManage()
|
|
{
|
|
|
|
}
|
|
static void DeleteChildren(OHOS::UIView* view)
|
|
{
|
|
if (view == nullptr) {
|
|
return;
|
|
}
|
|
while (view != nullptr) {
|
|
OHOS::UIView* tempView = view;
|
|
view = view->GetNextSibling();
|
|
if (tempView->IsViewGroup()) {
|
|
DeleteChildren(static_cast<OHOS::UIViewGroup*>(tempView)->GetChildrenHead());
|
|
}
|
|
if (tempView->GetParent()) {
|
|
static_cast<OHOS::UIViewGroup*>(tempView->GetParent())->Remove(tempView);
|
|
}
|
|
delete tempView;
|
|
tempView = nullptr;
|
|
}
|
|
}
|
|
static void CleanChildren(OHOS::UIView* view)
|
|
{
|
|
if (view == nullptr) {
|
|
return;
|
|
}
|
|
OHOS::UIViewGroup* group = dynamic_cast<OHOS::UIViewGroup*>(view);
|
|
while (group->GetChildrenNumber() > 0) {
|
|
OHOS::UIView* child = group->GetChildrenHead();
|
|
group->Remove(child);
|
|
DeleteChildren(child);
|
|
}
|
|
}
|
|
};
|
|
|
|
}
|
|
#endif |