显示方式视图修改
authorluozheng <1732036298@qq.com>
Sat, 15 Jun 2024 02:26:32 +0000 (10:26 +0800)
committerluozheng <1732036298@qq.com>
Sat, 15 Jun 2024 02:26:32 +0000 (10:26 +0800)
code/sdk/application/wearable/fd230app/nativeui/themestyle/src/ThemeStylePresenter.cpp

index 3771bf5..9f3952b 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-04-08 16:43:48
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-06-14 19:39:03
+ * @LastEditTime: 2024-06-15 10:07:09
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/set_desktop/src/ThemeStylePresenter.cpp
  */
 
@@ -58,35 +58,39 @@ namespace OHOS
     {
         UNUSED(event);
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThemeStylePresenter::OnClick");
-        UILabelButtonExt *LabelButtonExt = dynamic_cast<UILabelButtonExt *>(&view);
-        std::string viewId = LabelButtonExt->GetViewId();
+
+        UILabelButtonExt *labelButtonExt = dynamic_cast<UILabelButtonExt *>(&view);
+        if (!labelButtonExt)
+        {
+            // 处理无法将 view 转换为 UILabelButtonExt 的情况
+            return false;
+        }
+
+        std::string viewId = labelButtonExt->GetViewId();
         if (viewId == THEMESTYLEVIEWEXIT)
         {
             NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);
             return true;
         }
+
+        if (viewId == THEME_STYLE_LIST)
+        {
+            ThemeStyleModel::GetInstance().SetAppListDisplayStyle(ThemeStyle::APPLIST_STYLE);
+        }
+        else if (viewId == THEME_STYLE_HEXAGONS)
+        {
+            ThemeStyleModel::GetInstance().SetAppListDisplayStyle(ThemeStyle::HEXAGONS_STYLE);
+        }
+
+        uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
+        if (preSlice == VIEW_APPLIST)
+        {
+            NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);
+        }
         else
         {
-            if (viewId == THEME_STYLE_LIST)
-            {
-                ThemeStyleModel::GetInstance().SetAppListDisplayStyle(ThemeStyle::APPLIST_STYLE);
-            }
-            else if (viewId == THEME_STYLE_HEXAGONS)
-            {
-                ThemeStyleModel::GetInstance().SetAppListDisplayStyle(ThemeStyle::HEXAGONS_STYLE);
-            }
-            // LabelButtonExt->SetImageSrc(PNG_CHECKBOX_ON_IMAGE, PNG_CHECKBOX_ON_IMAGE);
-            // LabelButtonExt->Invalidate();
-            uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
-            if (preSlice == VIEW_APPLIST)
-            {
-                NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);
-            }
-            else
-            {
-                NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);
-                NativeAbility::GetInstance().ClearSliceIdStack();
-            }
+            NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);
+            NativeAbility::GetInstance().ClearSliceIdStack();
         }
 
         return true;