137 lines
4.2 KiB
C++
137 lines
4.2 KiB
C++
#include "TjdUiAppFindPhonePresenter.h"
|
|
#include "TjdUiAppFindPhoneView.h"
|
|
#include "ble_api.h"
|
|
#include "dock/input_device.h"
|
|
#include "rtc_api.h"
|
|
#include "sql_fit.h"
|
|
#include "wearable_log.h"
|
|
#include "TjdUiRegisterManager.h"
|
|
#include "TjdUiScreenManage.h"
|
|
|
|
namespace TJD {
|
|
|
|
TJD_REGIST_SLICE(TJD_APP_VIEW_FINDPHONE, TjdUiAppFindPhoneView, TjdUiAppFindPhonePresenter);
|
|
|
|
static TjdUiAppFindPhonePresenter *g_pv_AppFindPhonePresenter = nullptr;
|
|
|
|
void find_phone_callback(void)
|
|
{
|
|
printf("find_phone_callback\r\n");
|
|
GraphicService::GetInstance()->PostGraphicEvent([&]() {
|
|
TjdUiAppFindPhoneView *findmyphoneView = TjdUiAppFindPhoneView::GetInstance();
|
|
findmyphoneView->Changestatus2();
|
|
});
|
|
}
|
|
|
|
TjdUiAppFindPhonePresenter::TjdUiAppFindPhonePresenter()
|
|
{
|
|
g_pv_AppFindPhonePresenter = this;
|
|
register_find_phone_end_callback(find_phone_callback);
|
|
}
|
|
|
|
TjdUiAppFindPhonePresenter::~TjdUiAppFindPhonePresenter()
|
|
{
|
|
g_pv_AppFindPhonePresenter = nullptr;
|
|
unregister_find_phone_end_callback();
|
|
}
|
|
|
|
TjdUiAppFindPhonePresenter *TjdUiAppFindPhonePresenter::GetInstance(void) { return g_pv_AppFindPhonePresenter; }
|
|
|
|
static void FindPhoneCallBackProc(void *param)
|
|
{
|
|
TjdUiAppFindPhoneView::GetInstance()->ShowView(FindPhoneViewIndex::FIND_PHONE_FAIL_VIEW,
|
|
FindPhoneViewIndex::FIND_PHONE_VIEW);
|
|
}
|
|
|
|
static void FindPhoneCallBack(void *param)
|
|
{
|
|
GraphicService::GetInstance()->PostGraphicEvent(std::bind(&FindPhoneCallBackProc, param));
|
|
}
|
|
|
|
void TjdUiAppFindPhonePresenter::Notify()
|
|
{
|
|
if (backFlag) {
|
|
num1++;
|
|
if (num1 >= 125) {
|
|
FindPhoneCallBack(nullptr);
|
|
backFlag = false;
|
|
num1 = 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
void TjdUiAppFindPhonePresenter::OnStart()
|
|
{
|
|
TjdUiCommonOnKeyListener::GetInstance()->SetOnKeyActListener(this, KeyModelType::APP_KEY_TYPE);
|
|
}
|
|
|
|
void TjdUiAppFindPhonePresenter::OnStop()
|
|
{
|
|
TjdUiCommonOnKeyListener::GetInstance()->ClearOnKeyActListener(KeyModelType::APP_KEY_TYPE);
|
|
}
|
|
|
|
void TjdUiAppFindPhonePresenter::OnPause() { Presenter::OnPause(); }
|
|
|
|
void TjdUiAppFindPhonePresenter::OnResume()
|
|
{
|
|
Presenter::OnResume();
|
|
}
|
|
|
|
bool TjdUiAppFindPhonePresenter::OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event)
|
|
{
|
|
printf("TjdUiAppFindPhonePresenter onclick\r\n");
|
|
TjdUiAppFindPhoneView *findmyphoneView = TjdUiAppFindPhoneView::GetInstance();
|
|
std::string viewId = view.GetViewId();
|
|
bleFlag = tjd_get_ble_is_connect();
|
|
if (viewId.empty()) {
|
|
return false;
|
|
}
|
|
if (viewId == FINDPHONE_START_ID && bleFlag) {
|
|
TjdUiScreenManage::SetScreenKeepOnTimeout(1000*60);
|
|
findmyphoneView->Changestatus1();
|
|
tjd_lefun_request_find_phone();
|
|
return true;
|
|
} else if (viewId == FINDPHONE_START_ID && !bleFlag) {
|
|
findmyphoneView->ShowView(FindPhoneViewIndex::FIND_PHONE_VIEW, FindPhoneViewIndex::FIND_PHONE_FAIL_VIEW);
|
|
backFlag = true;
|
|
num1 = 0;
|
|
return true;
|
|
} else if (viewId == FINDPHONE_PAUSE_ID) {
|
|
findmyphoneView->Changestatus2();
|
|
tjd_lefun_request_find_phone_cancel();
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void TjdUiAppFindPhonePresenter::ViewExitEvent(OHOS::UIView &view)
|
|
{
|
|
std::string viewId_ = view.GetViewId();
|
|
printf("TjdUiAppFindPhonePresenter ViewExitEvent\r\n");
|
|
TjdUiAppFindPhoneView *findmyphoneView = TjdUiAppFindPhoneView::GetInstance();
|
|
if (findmyphoneView->GetCurrentView() == FindPhoneViewIndex::FIND_PHONE_VIEW) {
|
|
tjd_lefun_request_find_phone_cancel();
|
|
OHOS::NativeAbility::GetInstance().ChangeSlice(TJD_APP_VIEW_MAIN);
|
|
}
|
|
if (findmyphoneView->GetCurrentView() == FindPhoneViewIndex::FIND_PHONE_FAIL_VIEW) {
|
|
findmyphoneView->ShowView(FindPhoneViewIndex::FIND_PHONE_FAIL_VIEW, FindPhoneViewIndex::FIND_PHONE_VIEW);
|
|
backFlag = false;
|
|
}
|
|
// if (viewId_ == FINDPHONE_COVER_ID) {
|
|
// OHOS::NativeAbility::GetInstance().ChangeSlice(TJD_APP_VIEW_MAIN);
|
|
// }
|
|
|
|
return;
|
|
}
|
|
|
|
bool TjdUiAppFindPhonePresenter::OnKeyAct(OHOS::UIView &view, const OHOS::KeyEvent &event)
|
|
{
|
|
if(!TjdUiCommonOnKeyListener::CheckIsExitEvent(event)) {
|
|
return true;
|
|
}
|
|
ViewExitEvent(view);
|
|
|
|
return false;
|
|
}
|
|
|
|
} // namespace TJD
|