解决,#672,蓝牙耳机界面退出,稍微右滑就退出了bug 1047/3 1047/head
authorluozheng <1732036298@qq.com>
Sat, 28 Sep 2024 10:14:34 +0000 (18:14 +0800)
committerluozheng <1732036298@qq.com>
Sat, 28 Sep 2024 10:14:34 +0000 (18:14 +0800)
code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothPresenter.h
code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothPresenter.cpp

index e6c7e10..50303a5 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com\r
  * @Date: 2024-08-05 15:20:01\r
  * @LastEditors: luozheng 1732036298@qq.com\r
- * @LastEditTime: 2024-09-04 15:43:50\r
+ * @LastEditTime: 2024-09-28 18:06:32\r
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothPresenter.h\r
  */\r
 \r
@@ -44,6 +44,7 @@ public:
     ~BluetoothPresenter();\r
     bool OnClick(UIView &view, const ClickEvent &event) override;\r
     static BluetoothPresenter *GetInstance();\r
+    bool OnDrag(UIView& view, const DragEvent& event) override;\r
     bool OnDragEnd(UIView& view, const DragEvent& event) override;\r
     bool OnKeyAct(UIView &view, const KeyEvent &event) override;\r
     void OnStart() override;\r
@@ -60,6 +61,7 @@ public:
     void ClickConnfailBackButton(void);\r
 private:\r
     BluetoothModel *bluetoothMode_{nullptr};\r
+    bool X_DRAG_FLAG{false};\r
 };\r
 } // namespace OHOS\r
 #endif\r
index 9d6b02e..aa5f2ff 100644 (file)
@@ -190,10 +190,25 @@ void BluetoothPresenter::ClickConnfailBackButton(void)
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ClickConnfailBackButton ConnectRemoteDevice retVal = %d", retVal);\r
 }\r
 \r
-bool BluetoothPresenter::OnDragEnd(UIView& view, const DragEvent& event)\r
+bool BluetoothPresenter::OnDrag(UIView& view, const DragEvent& event)\r
 {\r
     if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) {\r
+        int16_t deltaX;\r
+        int16_t deltaY;\r
+        deltaX = event.GetDeltaX();\r
+        deltaY = event.GetDeltaY();\r
+        if (MATH_ABS(deltaX) >= MATH_ABS(deltaY) && MATH_ABS(deltaX) > 30) {\r
+            X_DRAG_FLAG = true;\r
+        }\r
+    }\r
+    return true;\r
+}\r
+\r
+bool BluetoothPresenter::OnDragEnd(UIView& view, const DragEvent& event)\r
+{\r
+    if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && X_DRAG_FLAG) {\r
         view_->DropView(view);\r
+        X_DRAG_FLAG = false;\r
     }\r
     return true;\r
 }\r