mcu_hi3321_watch/tjd/ui/app/businesscard/TjdUiAppBusinesscardPresenter.cpp
2025-05-26 20:15:20 +08:00

89 lines
2.9 KiB
C++

#include "TjdUiAppBusinesscardPresenter.h"
#include "NativeAbility.h"
#include "TjdUiAppBusinesscardView.h"
#include "TjdUiAppIds.h"
#include "common/key_code.h"
#include "dock/input_device.h"
#include <stdio.h>
#include "TjdUiRegisterManager.h"
using namespace OHOS;
namespace TJD {
TJD_REGIST_NATIVE_MENU(TJD_APP_VIEW_BUSINESSCARD, TjdUiAppBusinessCardView, TjdUiAppBusinesscardPresenter, IMG_MENU_LIST_MENU_CARD, STR_ID_22);
static TjdUiAppBusinesscardPresenter *g_pv_AppBusinesscardPresenter = nullptr;
TjdUiAppBusinesscardPresenter::TjdUiAppBusinesscardPresenter() { g_pv_AppBusinesscardPresenter = this; }
TjdUiAppBusinesscardPresenter::~TjdUiAppBusinesscardPresenter() { g_pv_AppBusinesscardPresenter = nullptr; }
TjdUiAppBusinesscardPresenter *TjdUiAppBusinesscardPresenter::GetInstance(void)
{
return g_pv_AppBusinesscardPresenter;
}
void TjdUiAppBusinesscardPresenter::OnStart()
{
TjdUiCommonOnKeyListener::GetInstance()->SetOnKeyActListener(this, KeyModelType::APP_KEY_TYPE);
}
void TjdUiAppBusinesscardPresenter::OnStop()
{
TjdUiCommonOnKeyListener::GetInstance()->ClearOnKeyActListener(KeyModelType::APP_KEY_TYPE);
}
bool TjdUiAppBusinesscardPresenter::OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event)
{
TjdUiAppBusinessCardView *businessCardView = TjdUiAppBusinessCardView::GetInstance();
if (view.GetViewId() == "imgReturn_Return") {
// OHOS::NativeAbility::GetInstance().ChangeSlice(TJD_APP_VIEW_MENU_LIST);
OHOS::NativeAbility::GetInstance().ChangePreSlice();
} else if (view.GetViewId() == "imgReturn_cardView") {
businessCardView->ShowView(BusinessCardIndex::BUSINESSCARD_LISTVIEW);
} else if (view.GetViewId() == "imgReturn_listView") {
businessCardView->ShowView(BusinessCardIndex::BUSINESSCARD_LISTVIEW);
}
return true;
}
bool TjdUiAppBusinesscardPresenter::OnKeyAct(OHOS::UIView &view, const OHOS::KeyEvent &event)
{
if (!TjdUiCommonOnKeyListener::CheckIsExitEvent(event)) {
return true;
}
if (event.GetState() == OHOS::InputDevice::STATE_RELEASE) {
ViewExitEvent(true);
return true;
}
return false;
}
void TjdUiAppBusinesscardPresenter::ExitBusinessCardView(void) { OHOS::NativeAbility::GetInstance().ChangePreSlice(); }
void TjdUiAppBusinesscardPresenter::ViewExitEvent(bool isSwipe)
{
TjdUiAppBusinessCardView *businesscardView = TjdUiAppBusinessCardView::GetInstance();
if (businesscardView == nullptr) {
return;
}
switch (TjdUiAppBusinessCardView::currentViewIndex_) {
case BusinessCardIndex::BUSINESSCARD_TIPVIEW:
OHOS::NativeAbility::GetInstance().ChangePreSlice();
break;
case BusinessCardIndex::BUSINESSCARD_LISTVIEW:
OHOS::NativeAbility::GetInstance().ChangePreSlice();
break;
case BusinessCardIndex::BUSINESSCARD_CARDVIEW:
businesscardView->ShowView(BusinessCardIndex::BUSINESSCARD_LISTVIEW);
break;
default:
break;
}
}
} // namespace TJD