From: luozheng Date: Thu, 8 Feb 2024 05:41:32 +0000 (+0800) Subject: 利用OnDragEnd()解决系统视图在退出到上一级时会出现跳转两次问题 X-Git-Tag: release_V1.2.70_20241020_135402~1307^2~1 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=41775c05f43846aed71a1309cffbdfb9f0a1cd91;p=mirrors%2FFD230.git 利用OnDragEnd()解决系统视图在退出到上一级时会出现跳转两次问题 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingPresenter.cpp index 73d5ad2c6..df6639d3d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingPresenter.cpp @@ -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; diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemPresenter.h index 405828c1f..37def53b9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemPresenter.h @@ -57,6 +57,7 @@ namespace OHOS SystemViewOnDragListener() {} ~SystemViewOnDragListener() {} bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnDragEnd(UIView &view, const DragEvent &event) override; }; class SystemView; diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemLanguageView.cpp b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemLanguageView.cpp index 3f460502a..6bf24f867 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemLanguageView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemLanguageView.cpp @@ -195,9 +195,9 @@ namespace OHOS /* ---------------------- SimplifiedChineseRadioButton ---------------------- */ RadioButtonConfig radioButtonConfig = { .left = 300, - .top = 120, - .width = 100, - .height = 100, + .top = 130, + .width = 80, + .height = 80, .name = "LanguageCategory", .viewId = SIMPLIFIED_CHINESE_CHECKBOX, .select = "/user/res/CHECKBOX_ON.bin", @@ -215,7 +215,7 @@ namespace OHOS scrollView->Add(SimplifiedChineseRadioButton); /* --------------------------- EnglishRadioButton --------------------------- */ radioButtonConfig.left = 300; - radioButtonConfig.top = 240; + radioButtonConfig.top = 250; radioButtonConfig.viewId = ENGLISH_CHECKBOX; EnglishRadioButton = SetUpRadioButton(radioButtonConfig); if (EnglishRadioButton == nullptr) diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp index 86b02719c..b3cb3f880 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp @@ -118,8 +118,12 @@ namespace OHOS // 该拖拽是用来处理系统视图(slice)的左滑退出事件和子视图的左滑退出到系统视图区分开 bool SystemViewOnDragListener::OnDrag(UIView &view, const DragEvent &event) { - if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && - (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) + return true; + } + + bool SystemViewOnDragListener::OnDragEnd(UIView &view, const DragEvent &event) + { + if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)) { NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); } @@ -187,7 +191,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Switched to English language"); } m_label->SetTextId(11); - //强制刷新 + // 强制刷新 m_label->ForceResetText(); RootView::GetInstance()->Invalidate(); break;