* @Author: luozheng 1732036298@qq.com
* @Date: 2024-03-27 10:47:46
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-08-31 17:31:35
+ * @LastEditTime: 2024-08-31 18:27:22
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhoneView.cpp
*/
#include "findphone/include/FindPhoneView.h"
FindPhoneView::~FindPhoneView()
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FindPhoneView::~FindPhoneView");
- ClearAll();
g_pFindPhoneView = nullptr;
}
{
if (viewInitStatus == true)
{
+ // UIViewGroup *tmpGroup = dynamic_cast<UIViewGroup *>(container_);
+ // UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup);
+ // FreeImageInfoArray(FindPhonePathsArray, FIND_PONE_IMAGE_SRC, FINDPHONE_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+
+ if (container_ != nullptr)
+ {
+ container_->RemoveAll();
+ delete container_;
+ container_ = nullptr;
+ }
if (FindPhoneGroupView != nullptr)
{
FindPhoneGroupView->RemoveAll();
- if (FindPhoneTitleLabel == nullptr)
+ if (FindPhoneTitleLabel != nullptr)
{
delete FindPhoneTitleLabel;
FindPhoneTitleLabel = nullptr;
}
-
if (FindPhoneImageView != nullptr)
{
delete FindPhoneImageView;
FindPhoneImageView = nullptr;
}
-
if (FindPhoneImageAnimator != nullptr)
{
FindPhoneImageAnimator->Stop();
// FreeImagePathsArray(FindPhonePathsArray, FINDPHONE_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
FreeImageInfoArray(FindPhonePathsArray, FIND_PONE_IMAGE_SRC, FINDPHONE_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
}
-
if (FindPhoneLabel != nullptr)
{
delete FindPhoneLabel;
FindPhoneLabel = nullptr;
}
-
if (FindPhoneLabelButton != nullptr)
{
delete FindPhoneLabelButton;
FindPhoneLabelButton = nullptr;
}
-
delete FindPhoneGroupView;
FindPhoneGroupView = nullptr;
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FindPhoneView::ClearAll over!!");
}
}
}
}
FindPhoneGroupView->SetPosition(0, 0, 466, 466);
FindPhoneGroupView->SetStyle(STYLE_BACKGROUND_OPA, 0);
+ FindPhoneGroupView->SetTouchable(true);
+ FindPhoneGroupView->SetDraggable(true);
+ FindPhoneGroupView->SetOnDragListener(presenter_);
/* --------------------------- FindPhoneTitleLabel -------------------------- */
FindPhoneTitleLabel = new UILabelExt();
if (FindPhoneTitleLabel == nullptr)
FindPhoneLabelButton->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff));
FindPhoneLabelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
FindPhoneLabelButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
- UIView::OnClickListener *clickListener = static_cast<UIView::OnClickListener *>(FindPhonePresenter::GetInstance());
- FindPhoneLabelButton->SetOnClickListener(clickListener);
+ FindPhoneLabelButton->SetOnClickListener(presenter_);
/* ----------------------------------- Add ---------------------------------- */
FindPhoneGroupView->Add(FindPhoneTitleLabel);
FindPhoneGroupView->Add(FindPhoneImageView);
FindPhoneGroupView->Add(FindPhoneLabel);
FindPhoneGroupView->Add(FindPhoneLabelButton);
+ container_->Add(FindPhoneGroupView);
}
viewInitStatus = true;
}
}
FindPhoneGroupView->SetPosition(0, 0, 466, 466);
FindPhoneGroupView->SetStyle(STYLE_BACKGROUND_OPA, 0);
+ FindPhoneGroupView->SetTouchable(true);
+ FindPhoneGroupView->SetDraggable(true);
+ FindPhoneGroupView->SetOnDragListener(presenter_);
/* --------------------------- FindPhoneTitleLabel -------------------------- */
FindPhoneTitleLabel = new UILabelExt();
if (FindPhoneTitleLabel == nullptr)
FindPhoneImageAnimator->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
FindPhoneImageAnimator->SetImageAnimatorSrc(FindPhoneImageInfo, FINDPHONE_IMAGE_ANIMATOR_VIEW_NUM_FRAMES, FINDPHONE_IMAGE_ANIMATOR_VIEW_TIMEOFUPDATE);
FindPhoneImageAnimator->SetRepeat(true);
- FindPhoneImageAnimator->Start();
}
/* ----------------------------- FindPhoneLabel ----------------------------- */
FindPhoneLabel = new UILabelExt();
FindPhoneLabelButton->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff));
FindPhoneLabelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
FindPhoneLabelButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
- UIView::OnClickListener *clickListener = static_cast<UIView::OnClickListener *>(FindPhonePresenter::GetInstance());
- FindPhoneLabelButton->SetOnClickListener(clickListener);
+ FindPhoneLabelButton->SetOnClickListener(presenter_);
/* ----------------------------------- Add ---------------------------------- */
FindPhoneGroupView->Add(FindPhoneTitleLabel);
FindPhoneGroupView->Add(FindPhoneImageAnimator);
FindPhoneGroupView->Add(FindPhoneLabel);
FindPhoneGroupView->Add(FindPhoneLabelButton);
+ container_->Add(FindPhoneGroupView);
}
viewInitStatus = true;
}
void FindPhoneView::OnStart()
{
View<FindPhonePresenter>::OnStart();
-
// if (FindPhoneModel::GetInstance().GetBlueToothConnectedState() == true) // 判断蓝牙是否是连接状态
// {
// FindPhoneViewInit_BlueToothConnected();
// {
// FindPhoneViewInit_BlueToothDisConnected();
// }
+ SetContainerView(new UIViewGroup());
+ if (GetContainer() == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "container_ new fail!!");
+ return;
+ }
+ container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+ container_->SetTouchable(true);
+ container_->SetDraggable(true);
- FindPhoneViewInit_BlueToothConnected();
- senfindphoneSend(FINDPHONE_START);
-
- FindPhoneGroupView->SetTouchable(true);
- FindPhoneGroupView->SetDraggable(true);
- UIView::OnDragListener *dragListener = static_cast<UIView::OnDragListener *>(FindPhonePresenter::GetInstance());
- FindPhoneGroupView->SetOnDragListener(dragListener);
-
- // 增加按键监听
- RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::FindPhonePresenter::GetInstance();
- RootView::GetInstance()->SetOnKeyActListener(keyactListener);
+ if (!viewInitStatus)
+ {
+ FindPhoneViewInit_BlueToothConnected();
+ senfindphoneSend(FINDPHONE_START);
+ viewInitStatus = true;
+ }
+ RootView::GetInstance()->SetOnKeyActListener(presenter_);
}
void FindPhoneView::OnSetUpView()
{
View<FindPhonePresenter>::OnSetUpView();
- RootView::GetInstance()->Add(FindPhoneGroupView);
- container_ = FindPhoneGroupView;
+ if (FindPhoneImageAnimator)
+ {
+ FindPhoneImageAnimator->Start();
+ }
Draw();
}
void FindPhoneView::OnStop()
{
View<FindPhonePresenter>::OnStop();
- RootView::GetInstance()->RemoveAll();
RootView::GetInstance()->ClearOnKeyActListener();
+ ClearAll();
return;
}
}
\ No newline at end of file