Skip to content

Commit

Permalink
Fix Android interaction tool crash (project-chip#32197)
Browse files Browse the repository at this point in the history
  • Loading branch information
joonhaengHeo authored Feb 20, 2024
1 parent 165da46 commit 6b27278
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,19 @@ class ClusterDetailFragment : Fragment() {

private fun castStringToType(data: String, type: Class<*>, underlyingType: Class<*>): Any? {
return when (type) {
Int::class.java -> data.toInt()
Boolean::class.java -> data.toBoolean()
Int::class.java,
java.lang.Integer::class.java -> data.toInt()
Boolean::class.java,
java.lang.Boolean::class.java -> data.toBoolean()
ByteArray::class.java -> data.encodeToByteArray()
Long::class.java -> data.toLong()
Long::class.java,
java.lang.Long::class.java -> data.toLong()
Short::class.java,
java.lang.Short::class.java -> data.toShort()
Double::class.java,
java.lang.Double::class.java -> data.toDouble()
Float::class.java,
java.lang.Float::class.java -> data.toFloat()
Optional::class.java ->
if (data.isEmpty()) Optional.empty()
else Optional.of(castStringToType(data, underlyingType, underlyingType)!!)
Expand Down

0 comments on commit 6b27278

Please sign in to comment.