applist 优化更新 208/1 208/head 211/target/1 212/target/1
authorluozheng <1732036298@qq.com>
Fri, 31 May 2024 08:35:11 +0000 (16:35 +0800)
committerluozheng <1732036298@qq.com>
Fri, 31 May 2024 08:35:11 +0000 (16:35 +0800)
code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp
code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/set_desktop/src/SetDesktopPresenter.cpp

index 66181e3..6fce662 100644 (file)
@@ -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
index 8bc3fd2..0de9bc1 100644 (file)
@@ -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
index cadd1c7..4cbda58 100644 (file)
@@ -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<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0)
         {
-            NativeAbility::GetInstance().Back();
+            NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);
         }
         return true;
     }