Skip to content

Instantly share code, notes, and snippets.

@dilrajsingh1997
Created December 3, 2021 07:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dilrajsingh1997/c49dba13a18091e38e79a50fc516493f to your computer and use it in GitHub Desktop.
Save dilrajsingh1997/c49dba13a18091e38e79a50fc516493f to your computer and use it in GitHub Desktop.
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