From: luozheng <1732036298@qq.com> Date: Sat, 28 Sep 2024 10:14:34 +0000 (+0800) Subject: 解决,#672,蓝牙耳机界面退出,稍微右滑就退出了bug X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=refs%2Fchanges%2F1047%2F3;p=mirrors%2FFD230.git 解决,#672,蓝牙耳机界面退出,稍微右滑就退出了bug --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothPresenter.h index e6c7e1037..50303a5dd 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothPresenter.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-08-05 15:20:01 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-09-04 15:43:50 + * @LastEditTime: 2024-09-28 18:06:32 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothPresenter.h */ @@ -44,6 +44,7 @@ public: ~BluetoothPresenter(); bool OnClick(UIView &view, const ClickEvent &event) override; static BluetoothPresenter *GetInstance(); + bool OnDrag(UIView& view, const DragEvent& event) override; bool OnDragEnd(UIView& view, const DragEvent& event) override; bool OnKeyAct(UIView &view, const KeyEvent &event) override; void OnStart() override; @@ -60,6 +61,7 @@ public: void ClickConnfailBackButton(void); private: BluetoothModel *bluetoothMode_{nullptr}; + bool X_DRAG_FLAG{false}; }; } // namespace OHOS #endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothPresenter.cpp index 9d6b02e17..aa5f2ff2a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothPresenter.cpp @@ -190,10 +190,25 @@ void BluetoothPresenter::ClickConnfailBackButton(void) WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ClickConnfailBackButton ConnectRemoteDevice retVal = %d", retVal); } -bool BluetoothPresenter::OnDragEnd(UIView& view, const DragEvent& event) +bool BluetoothPresenter::OnDrag(UIView& view, const DragEvent& event) { if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) { + int16_t deltaX; + int16_t deltaY; + deltaX = event.GetDeltaX(); + deltaY = event.GetDeltaY(); + if (MATH_ABS(deltaX) >= MATH_ABS(deltaY) && MATH_ABS(deltaX) > 30) { + X_DRAG_FLAG = true; + } + } + return true; +} + +bool BluetoothPresenter::OnDragEnd(UIView& view, const DragEvent& event) +{ + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && X_DRAG_FLAG) { view_->DropView(view); + X_DRAG_FLAG = false; } return true; }