fix(folder): crash when opening a folder with an empty preview (#7482)

getAnimationData() read itemsInPreview[0] to derive the base icon size. The
preview list can be empty when the folder has no bound child views yet, which
made opening the folder crash with an IndexOutOfBoundsException.

Fall back to the device profile icon size when the list is empty; the normal
path is unchanged.

Co-authored-by: caizhixing <17589399+caizhixing03@user.noreply.gitee.com>
This commit is contained in:
caizhixingandcaizhixing authored and GitHub committed 2026-11-06 14:05:10 +08:00
1 parent 448f542eac
commit fcbf433f39
1 file changed
+5 -1
@@ -74,7 +74,11 @@ data class FolderAnimationData(
folderIconWorkspacePosition,
)
val scaledFolderRadius: Int = previewBackground.scaledRadius
val baseIconSize: Float = getBubbleTextView(itemsInPreview[0]).iconSize.toFloat()
// The preview can be empty when the folder has no bound child views yet. Fall back
// to the device profile icon size so that opening the folder does not crash.
val baseIconSize: Float =
itemsInPreview.firstOrNull()?.let { getBubbleTextView(it).iconSize.toFloat() }
?: mActivityContext.deviceProfile.iconSizePx.toFloat()
val initialFolderSize = (scaledFolderRadius * 2) * scaleRelativeToDragLayer
val initialFolderScale = previewSize / baseIconSize * scaleRelativeToDragLayer