From d4d703ba9e5b9ba799e79f26dcaf45f141411c8c Mon Sep 17 00:00:00 2001 From: Caisking <3449750381@qq.com> Date: Mon, 27 Nov 2023 11:05:47 +0800 Subject: [PATCH] =?utf8?q?=E8=A1=A8=E7=9B=98=E9=95=BF=E6=8C=89=E4=BA=8B?= =?utf8?q?=E4=BB=B6=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeapp/nativeui/clock/src/MainClockView.cpp | 14 +++++++++----- .../nativeui/main/include/MainPresenterSample.h | 3 ++- .../nativeui/main/src/MainPresenterSample.cpp | 14 +++++++++++++- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/code/sdk/application/wearable/nativeapp/nativeui/clock/src/MainClockView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/clock/src/MainClockView.cpp index b076bd132..4a0532475 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/clock/src/MainClockView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/clock/src/MainClockView.cpp @@ -131,9 +131,9 @@ void MainClockView::InitStepValue() bool MainClockView::InitLabelView(void) { - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::MainPresenterSample::GetInstance(); + //UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::MainPresenterSample::GetInstance(); // 创建长按事件监听器对象 - UIView::OnLongPressListener* longPressListener = (UIView::OnLongPressListener*)OHOS::MainPresenterSample::GetInstance(); + //UIView::OnLongPressListener* longPressListener = (UIView::OnLongPressListener*)OHOS::MainPresenterSample::GetInstance(); stepLabel = new UILabelButton(); @@ -147,7 +147,8 @@ bool MainClockView::InitLabelView(void) stepLabel->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); stepLabel->SetViewId(MAIN_CLICK_ACTIVITY); stepLabel->SetTouchable(true); - stepLabel->SetOnClickListener(clickListener); + //stepLabel->SetOnClickListener(clickListener); + //stepLabel->SetOnLongPressListener(longPressListener); InitStepValue(); batteryLabel = new UILabel(); @@ -351,13 +352,16 @@ void MainClockView::UnLoad(void) bool MainClockView::InitView(void) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainClockView::InitView"); - mainSweepClock = new UISweepClock(); if (mainSweepClock == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainSweepClock new fail"); return false; - } + } + UIView::OnLongPressListener* longPressListener = (UIView::OnLongPressListener*)OHOS::MainPresenterSample::GetInstance(); + mainSweepClock->SetOnLongPressListener(longPressListener); + if (InitSweepClock() == false) { return false; } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainPresenterSample.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainPresenterSample.h index 62082c75b..892549d77 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainPresenterSample.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainPresenterSample.h @@ -42,7 +42,7 @@ constexpr uint16_t HORIZONTAL_STATUS = 0; class MainViewSample; class MainPresenterSample : public Presenter, public ModelListenerSample, public UIView::OnClickListener, public UISwipeView::OnSwipeListener, - public UISwipeView, public CompassPresenter { + public UISwipeView, public CompassPresenter, public UIView::OnLongPressListener { public: MainPresenterSample(); virtual ~MainPresenterSample(); @@ -54,6 +54,7 @@ public: void OnStop() override; virtual void Notify() override; bool OnClick(UIView& view, const ClickEvent& event) override; + bool OnLongPress(UIView& view, const LongPressEvent& event) override; virtual void OnSwipe(UISwipeView& view) override; void setCallback(ZoomEffect* callback) { diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainPresenterSample.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainPresenterSample.cpp index ca923bc77..3470989c3 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainPresenterSample.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainPresenterSample.cpp @@ -136,7 +136,19 @@ namespace OHOS } return true; } - + bool MainPresenterSample::OnLongPress(UIView& view, const LongPressEvent& event) + { + printf("coming LongPress\n"); + UNUSED(event); + //string curViewId = view.GetViewId(); + int page = MainViewSample::GetInstance()->GetHorCurrentPage(); + //callback_->OnSwipe(view); + if(page == WATCH_FACE) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_DIAL); + return true; + } + } void MainPresenterSample::OnSwipe(UISwipeView &view) { UNUSED(view); -- 2.17.1