利用OnDragEnd()解决系统视图在退出到上一级时会出现跳转两次问题
authorluozheng <root@luozheng>
Thu, 8 Feb 2024 05:41:32 +0000 (13:41 +0800)
committerluozheng <root@luozheng>
Thu, 8 Feb 2024 05:41:32 +0000 (13:41 +0800)
code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/system/include/SystemPresenter.h
code/sdk/application/wearable/fd230app/nativeui/system/src/SystemLanguageView.cpp
code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp

index 73d5ad2..df6639d 100644 (file)
@@ -69,10 +69,12 @@ namespace OHOS
             if (preSlice == VIEW_APPLIST)
             {
                 NativeAbility::GetInstance().ChangeSlice(preSlice);
+                return true;
             }
             else
             {
                 NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN);
+                return true;
             }
         }
         return false;
index 405828c..37def53 100644 (file)
@@ -57,6 +57,7 @@ namespace OHOS
         SystemViewOnDragListener() {}\r
         ~SystemViewOnDragListener() {}\r
         bool OnDrag(UIView &view, const DragEvent &event) override;\r
+        bool OnDragEnd(UIView &view, const DragEvent &event) override;\r
     };\r
 \r
     class SystemView;\r
index 3f46050..6bf24f8 100644 (file)
@@ -195,9 +195,9 @@ namespace OHOS
         /* ---------------------- SimplifiedChineseRadioButton ---------------------- */\r
         RadioButtonConfig radioButtonConfig = {\r
             .left = 300,\r
-            .top = 120,\r
-            .width = 100,\r
-            .height = 100,\r
+            .top = 130,\r
+            .width = 80,\r
+            .height = 80,\r
             .name = "LanguageCategory",\r
             .viewId = SIMPLIFIED_CHINESE_CHECKBOX,\r
             .select = "/user/res/CHECKBOX_ON.bin",\r
@@ -215,7 +215,7 @@ namespace OHOS
         scrollView->Add(SimplifiedChineseRadioButton);\r
         /* --------------------------- EnglishRadioButton --------------------------- */\r
         radioButtonConfig.left = 300;\r
-        radioButtonConfig.top = 240;\r
+        radioButtonConfig.top = 250;\r
         radioButtonConfig.viewId = ENGLISH_CHECKBOX;\r
         EnglishRadioButton = SetUpRadioButton(radioButtonConfig);\r
         if (EnglishRadioButton == nullptr)\r
index 86b0271..b3cb3f8 100644 (file)
@@ -118,8 +118,12 @@ namespace OHOS
     // 该拖拽是用来处理系统视图(slice)的左滑退出事件和子视图的左滑退出到系统视图区分开\r
     bool SystemViewOnDragListener::OnDrag(UIView &view, const DragEvent &event)\r
     {\r
-        if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) &&\r
-            (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY()))))\r
+        return true;\r
+    }\r
+\r
+    bool SystemViewOnDragListener::OnDragEnd(UIView &view, const DragEvent &event)\r
+    {\r
+        if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT))\r
         {\r
             NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING);\r
         }\r
@@ -187,7 +191,7 @@ namespace OHOS
                 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Switched to English language");\r
             }\r
             m_label->SetTextId(11);\r
-            //强制刷新\r
+            // 强制刷新\r
             m_label->ForceResetText();\r
             RootView::GetInstance()->Invalidate();\r
             break;\r