Skip to content

Commit

Permalink
use encodeToByteArray and decodeToString
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLiuZhuoCheng committed Nov 18, 2021
1 parent 68ac805 commit 18c3558
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ import chip.devicecontroller.ClusterInfoMapping
import com.google.chip.chiptool.ChipClient
import com.google.chip.chiptool.GenericChipDeviceListener
import com.google.chip.chiptool.R
import java.nio.charset.Charset
import java.nio.charset.StandardCharsets.UTF_16
import java.nio.charset.StandardCharsets.UTF_8
import kotlinx.android.synthetic.main.cluster_callback_item.view.clusterCallbackDataTv
import kotlinx.android.synthetic.main.cluster_callback_item.view.clusterCallbackNameTv
import kotlinx.android.synthetic.main.cluster_callback_item.view.clusterCallbackTypeTv
Expand Down Expand Up @@ -98,7 +95,7 @@ class ClusterDetailFragment : Fragment() {
return when (type) {
Int::class.java -> data.toInt()
Boolean::class.java -> data.toBoolean()
ByteArray::class.java -> data.toByteArray()
ByteArray::class.java -> data.encodeToByteArray()
Long::class.java -> data.toLong()
else -> data
}
Expand Down Expand Up @@ -210,7 +207,7 @@ class ClusterDetailFragment : Fragment() {
inflater.inflate(R.layout.cluster_callback_item, null, false) as ConstraintLayout
callbackItem.clusterCallbackNameTv.text = variableNameType.name
callbackItem.clusterCallbackDataTv.text = if (response.javaClass == ByteArray::class.java) {
(response as ByteArray).contentToString()
(response as ByteArray).decodeToString()
} else {
response.toString()
}
Expand Down

0 comments on commit 18c3558

Please sign in to comment.