From 0a7cc99d9db45c6c4ba929acf5b57e22d826c82a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 18 May 2021 23:26:12 -0700 Subject: [PATCH] altosdroid: Skip clicks on BT device entries that are too short Maybe these are some kind of extra object? In any case, nothing that we care about, so just ignore the click. Signed-off-by: Keith Packard --- .../org/altusmetrum/AltosDroid/DeviceListActivity.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/altosdroid/app/src/main/java/org/altusmetrum/AltosDroid/DeviceListActivity.java b/altosdroid/app/src/main/java/org/altusmetrum/AltosDroid/DeviceListActivity.java index 1c3e1dba..60fba9d3 100644 --- a/altosdroid/app/src/main/java/org/altusmetrum/AltosDroid/DeviceListActivity.java +++ b/altosdroid/app/src/main/java/org/altusmetrum/AltosDroid/DeviceListActivity.java @@ -152,11 +152,16 @@ public class DeviceListActivity extends Activity { // The on-click listener for all devices in the ListViews private OnItemClickListener mDeviceClickListener = new OnItemClickListener() { public void onItemClick(AdapterView av, View v, int arg2, long arg3) { + // Get the device MAC address, which is the last 17 chars in the View + String info = ((TextView) v).getText().toString(); + + /* Ignore clicks on items that are too short */ + if (info.length() <= 17) + return; + // Cancel discovery because it's costly and we're about to connect mBtAdapter.cancelDiscovery(); - // Get the device MAC address, which is the last 17 chars in the View - String info = ((TextView) v).getText().toString(); String address = info.substring(info.length() - 17); int newline = info.indexOf('\n'); -- 2.30.2