Skip to content

Instantly share code, notes, and snippets.

@dilrajsingh1997
Created Dec 3, 2021
Embed
What would you like to do?
fun getParsedElement() {
when (propertyInfo.composeArgumentType) {
ComposeArgumentType.BOOLEAN -> file addPhrase "backStackEntry.arguments?.getBoolean(\"$argumentName\") ?: false"
ComposeArgumentType.STRING -> file addPhrase "backStackEntry.arguments?.getString(\"$argumentName\") ?: \"\""
ComposeArgumentType.FLOAT -> file addPhrase "backStackEntry.arguments?.getFloat(\"$argumentName\") ?: 0F"
ComposeArgumentType.INT -> file addPhrase "backStackEntry.arguments?.getInt(\"$argumentName\") ?: 0"
ComposeArgumentType.LONG -> file addPhrase "backStackEntry.arguments?.getLong(\"$argumentName\") ?: 0L"
ComposeArgumentType.INT_ARRAY -> file addPhrase "backStackEntry.arguments?.getIntArray(\"$argumentName\") ?: intArrayOf()"
ComposeArgumentType.BOOLEAN_ARRAY -> file addPhrase "backStackEntry.arguments?.getBooleanArray(\"$argumentName\") ?: booleanArrayOf()"
ComposeArgumentType.LONG_ARRAY -> file addPhrase "backStackEntry.arguments?.getLongArray(\"$argumentName\") ?: longArrayOf()"
ComposeArgumentType.FLOAT_ARRAY -> file addPhrase "backStackEntry.arguments?.getFloatArray(\"$argumentName\") ?: floatArrayOf()"
ComposeArgumentType.PARCELABLE -> {
file addPhrase "backStackEntry.arguments?.getParcelable<"
addVariableType(file, propertyInfo)
file addPhrase ">(\"$argumentName\") ?: throw NullPointerException(\"parcel value not found\")"
}
ComposeArgumentType.PARCELABLE_ARRAY -> {
file addPhrase "backStackEntry.arguments?.getParcelableArrayList"
visitChildTypeArguments(propertyInfo.typeArguments)
file addPhrase "(\"$argumentName\")"
file addPhrase " ?: throw NullPointerException(\"parcel value not found\")"
}
ComposeArgumentType.SERIALIZABLE -> {
file addPhrase "backStackEntry.arguments?.getSerializable"
file addPhrase "(\"$argumentName\") as? "
addVariableType(file, propertyInfo)
file addPhrase " ?: throw NullPointerException(\"parcel value not found\")"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment