From 6c05c6348f1f7cb7c5f0e4cb5792cd032181d9c7 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Fri, 31 May 2024 16:35:11 +0800 Subject: [PATCH] =?utf8?q?applist=20=E4=BC=98=E5=8C=96=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/applist/src/ApplistModel.cpp | 40 +++++++------------ .../nativeui/applist/src/ApplistPresenter.cpp | 3 +- .../set_desktop/src/SetDesktopPresenter.cpp | 7 ++-- 3 files changed, 21 insertions(+), 29 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp index 66181e31f..6fce66237 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp @@ -80,8 +80,7 @@ namespace OHOS void ApplistModel::Init() { - if (!initFlag) - { + if (!initFlag) { ResolvingJSAppItems(); initFlag = true; } @@ -89,18 +88,13 @@ namespace OHOS void ApplistModel::ResolvingJSAppItems(void) { - uint8 i, ret, nativeAppNum; - int32 len = 0; #ifdef JS_ENABLE - if (bundleInfos != nullptr) - { - for (i = 0; i < bundleLen; i++) - { + if (bundleInfos != nullptr) { + for (uint8_t i = 0; i < bundleLen; i++) { ClearBundleInfo(bundleInfos + i); } - if (bundleInfos != nullptr) - { + if (bundleInfos != nullptr) { AdapterFree(bundleInfos); bundleInfos = nullptr; } @@ -108,29 +102,27 @@ namespace OHOS #endif bundleLen = 0; appLen = 0; - nativeAppNum = sizeof(g_nativeAppList) / sizeof(AppItem); - if (nativeAppNum >= APP_MAX_NUM) - { + + uint8_t nativeAppNum = sizeof(g_nativeAppList) / sizeof(AppItem); + if (nativeAppNum >= APP_MAX_NUM) { nativeAppNum = APP_MAX_NUM; } - ret = memcpy_s(applist, sizeof(AppItem) * APP_MAX_NUM, g_nativeAppList, sizeof(AppItem) * nativeAppNum); - if (ret != EOK) - { + + uint8_t ret = memcpy_s(applist, sizeof(AppItem) * APP_MAX_NUM, g_nativeAppList, sizeof(AppItem) * nativeAppNum); + if (ret != EOK) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%s] ret = %d, nativeAppNum = %d", __FUNCTION__, ret, nativeAppNum); nativeAppNum = 0; } appLen = nativeAppNum; #ifdef JS_ENABLE + int32_t len = 0; ret = BundleMsClient::GetInstance().GetBundleInfos(0, &bundleInfos, &len); - if ((ret == 0) && (len > 0) && (bundleInfos != nullptr)) - { + if ((ret == 0) && (len > 0) && (bundleInfos != nullptr)) { bundleLen = len; - if (len > APP_MAX_NUM - nativeAppNum) - { + if (len > APP_MAX_NUM - nativeAppNum) { len = APP_MAX_NUM - nativeAppNum; } - while (len--) - { + while (len--) { applist[appLen].id = VIEW_EXTERN_APP; applist[appLen].iconLarge = bundleInfos[len].smallIconPath; applist[appLen].iconSmall = bundleInfos[len].smallIconPath; @@ -144,9 +136,7 @@ namespace OHOS appLen++; bundleInfos[len].abilityInfo = nullptr; } - } - else - { + } else { WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "ResolvingJSAppItems GetBundleInfos ret = %d \r", ret); } #endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistPresenter.cpp index 8bc3fd223..0de9bc177 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistPresenter.cpp @@ -119,7 +119,8 @@ namespace OHOS { } WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnClick viewid = %d", viewId); if (viewId < VIEW_MAX_INTER_APP) { - NativeAbility::GetInstance().ChangeSlice(viewId, type); + //NativeAbility::GetInstance().ChangeSlice(viewId, type); + NativeAbility::GetInstance().EnterSlice(viewId, type); return true; } else if (viewId == VIEW_EXTERN_APP) { #ifdef JS_ENABLE diff --git a/code/sdk/application/wearable/fd230app/nativeui/set_desktop/src/SetDesktopPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/set_desktop/src/SetDesktopPresenter.cpp index cadd1c796..4cbda582e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/set_desktop/src/SetDesktopPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/set_desktop/src/SetDesktopPresenter.cpp @@ -59,7 +59,7 @@ namespace OHOS { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnDrag ChangeSlice"); // uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); // NativeAbility::GetInstance().ChangeSlice(preSlice); - NativeAbility::GetInstance().Back(); + NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); } return false; } @@ -73,7 +73,8 @@ namespace OHOS { SetDesktopModel::GetInstance().SetDesktopStyle(APPLIST_STYLE); } // uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + //NativeAbility::GetInstance().ChangeSlice(preSlice); + NativeAbility::GetInstance().EnterSlice(VIEW_APPLIST); return true; } bool SetDesktopPresenter::GetHexagonsStyleState(void) @@ -89,7 +90,7 @@ namespace OHOS { // 如果是power键就返回上一级 if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) { - NativeAbility::GetInstance().Back(); + NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); } return true; } -- 2.17.1