Skip to content

Commit

Permalink
skip merge with master
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLiuZhuoCheng committed Nov 11, 2021
1 parent 7362798 commit f01bced
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import com.google.chip.chiptool.R
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
import kotlinx.android.synthetic.main.cluster_detail_fragment.callbackList
import kotlinx.android.synthetic.main.cluster_detail_fragment.view.callbackList
import kotlinx.android.synthetic.main.cluster_detail_fragment.view.clusterAutoCompleteTv
import kotlinx.android.synthetic.main.cluster_detail_fragment.view.commandAutoCompleteTv
Expand Down Expand Up @@ -69,7 +68,12 @@ class ClusterDetailFragment : Fragment() {
return inflater.inflate(R.layout.cluster_detail_fragment, container, false).apply {
deviceController.setCompletionListener(GenericChipDeviceListener())
commandAutoCompleteTv.visibility = View.GONE
clusterAutoCompleteSetup(clusterAutoCompleteTv, commandAutoCompleteTv, parameterList)
clusterAutoCompleteSetup(
clusterAutoCompleteTv,
commandAutoCompleteTv,
parameterList,
callbackList
)
commandAutoCompleteSetup(commandAutoCompleteTv, inflater, parameterList, callbackList)
invokeCommand.setOnClickListener {
callbackList.removeAllViews()
Expand Down Expand Up @@ -105,7 +109,8 @@ class ClusterDetailFragment : Fragment() {
private fun clusterAutoCompleteSetup(
clusterAutoComplete: AutoCompleteTextView,
commandAutoComplete: AutoCompleteTextView,
parameterList: LinearLayout
parameterList: LinearLayout,
callbackList: LinearLayout
) {
val clusterNameList = constructHint(clusterMap)
val clusterAdapter =
Expand Down Expand Up @@ -176,37 +181,37 @@ class ClusterDetailFragment : Fragment() {
callbackList: LinearLayout
) {
responseValues.forEach { (variableNameType, response) ->
if (response.javaClass.isPrimitive) {
val callback =
inflater.inflate(R.layout.cluster_callback_item, null, false) as ConstraintLayout
callback.clusterCallbackNameTv.text = variableNameType.name
callback.clusterCallbackDataTv.text = response.toString()
callback.clusterCallbackTypeTv.text = variableNameType.type
callbackList.addView(callback)
} else if (response is List<*>) {
if (response is List<*>) {
if (response.size == 0) {
val emptyCallback =
inflater.inflate(R.layout.cluster_callback_item, null, false) as ConstraintLayout
emptyCallback.clusterCallbackNameTv.text = "Result is empty"
callbackList.addView(emptyCallback)
} else {
response.forEach {
response.forEachIndexed { index, it ->
val objectCallback =
inflater.inflate(R.layout.cluster_callback_item, null, false) as ConstraintLayout
objectCallback.clusterCallbackNameTv.text = variableNameType.name
val objectString = it.toString()
objectCallback.clusterCallbackDataTv.text = it!!.javaClass.toString().split('$').last()
objectCallback.clusterCallbackNameTv.text = variableNameType.name + "[$index]"
val callbackClassName = it!!.javaClass.toString().split('$').last()
objectCallback.clusterCallbackDataTv.text = callbackClassName
objectCallback.clusterCallbackDataTv.setOnClickListener {
AlertDialog.Builder(requireContext())
.setTitle(variableNameType.name)
.setMessage(objectString)
.setTitle(callbackClassName)
.setMessage(it.toString())
.create()
.show()
}
objectCallback.clusterCallbackTypeTv.text = variableNameType.type
objectCallback.clusterCallbackTypeTv.text = "List<$callbackClassName>"
callbackList.addView(objectCallback)
}
}
} else {
val callback =
inflater.inflate(R.layout.cluster_callback_item, null, false) as ConstraintLayout
callback.clusterCallbackNameTv.text = variableNameType.name
callback.clusterCallbackDataTv.text = response.toString()
callback.clusterCallbackTypeTv.text = variableNameType.type
callbackList.addView(callback)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


package com.google.chip.chiptool.clusterclient.clusterinteraction

import android.os.Bundle
Expand All @@ -13,8 +15,6 @@ import com.google.chip.chiptool.ChipClient
import com.google.chip.chiptool.GenericChipDeviceListener
import com.google.chip.chiptool.R
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.cancel
import com.google.chip.chiptool.clusterclient.AddressUpdateFragment
import kotlinx.android.synthetic.main.cluster_interaction_fragment.view.endpointList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@

<TextView
android:id="@+id/clusterCallbackNameTv"
android:layout_width="80dp"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:padding="8dp"
android:minWidth="48dp"
android:minWidth="90dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/clusterCallbackDataTv"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />


<TextView
android:id="@+id/clusterCallbackDataTv"
android:layout_width="0dp"
Expand All @@ -26,8 +27,6 @@
app:layout_constraintEnd_toStartOf="@id/clusterCallbackTypeTv"
app:layout_constraintStart_toEndOf="@id/clusterCallbackNameTv"
app:layout_constraintTop_toTopOf="parent" />


<TextView
android:id="@+id/clusterCallbackTypeTv"
android:textStyle="bold"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/callbackList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_below="@+id/invokeCommand"
android:orientation="vertical" />
<LinearLayout
android:id="@+id/callbackList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_below="@+id/invokeCommand"
android:orientation="vertical" />
</ScrollView>
</LinearLayout>

0 comments on commit f01bced

Please sign in to comment.