From a523f2f88a9c51c9503ea4854a2f41a84f861cef Mon Sep 17 00:00:00 2001 From: Damian Krolik Date: Fri, 10 Sep 2021 13:06:13 +0200 Subject: [PATCH] [nrf noup] Fix issue with spawning multiple DNS-SD queries In some Android SDK versions spawning a DNS-SD query when a previous one is still in progress results in an error. Change the device address update condition so that two identical queries are not sent on entering the sensor clusters screen, not to generate a failure. --- .../clusterclient/SensorClientFragment.kt | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/SensorClientFragment.kt b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/SensorClientFragment.kt index 23d6f21026..b6b51fb042 100644 --- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/SensorClientFragment.kt +++ b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/SensorClientFragment.kt @@ -7,6 +7,7 @@ import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.view.inputmethod.EditorInfo import android.widget.AdapterView import android.widget.ArrayAdapter import android.widget.Toast @@ -42,15 +43,11 @@ class SensorClientFragment : Fragment() { savedInstanceState: Bundle? ): View { return inflater.inflate(R.layout.sensor_client_fragment, container, false).apply { - deviceIdEd.addTextChangedListener(object : TextWatcher { - override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { - if (s.isNullOrEmpty()) - return - updateAddress(s.toString()) - } - override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) = Unit - override fun afterTextChanged(s: Editable?) = Unit - }) + deviceIdEd.setOnEditorActionListener { textView, actionId, event -> + if (actionId == EditorInfo.IME_ACTION_DONE) + updateAddress(textView.text.toString()) + actionId == EditorInfo.IME_ACTION_DONE + } clusterNameSpinner.adapter = makeClusterNamesAdapter() clusterNameSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { override fun onNothingSelected(parent: AdapterView<*>?) = Unit