Permalink
Browse files

Fix issue #107 - Compare the device address for double click checking

  • Loading branch information...
thejeshgn committed May 5, 2017
1 parent 24eb85a commit 87092d3cf07c0164c96b7d7fd48a289b54aee5df
Showing with 5 additions and 1 deletion.
  1. +5 −1 app/src/main/java/net/sylvek/itracing2/BluetoothLEService.java
@@ -65,6 +65,8 @@
private UUID lastUuid;
private String lastAddress;
private Runnable r;
private Handler handler = new Handler();
@@ -183,17 +185,19 @@ public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteris
final long delayDoubleClick = Preferences.getDoubleButtonDelay(getApplicationContext());
final long now = SystemClock.elapsedRealtime();
if (lastChange + delayDoubleClick > now && characteristic.getUuid().equals(lastUuid)) {
if (lastChange + delayDoubleClick > now && characteristic.getUuid().equals(lastUuid) && gatt.getDevice().getAddress().equals(lastAddress)) {
Log.d(TAG, "onCharacteristicChanged() - double click");
lastChange = 0;
lastUuid = null;
lastAddress = "";
handler.removeCallbacks(r);
for (String action : Preferences.getActionDoubleButton(getApplicationContext(), address)) {
sendAction(Preferences.Source.double_click, action);
}
} else {
lastChange = now;
lastUuid = characteristic.getUuid();
lastAddress = gatt.getDevice().getAddress();
r = new Runnable() {
@Override
public void run() {

0 comments on commit 87092d3

Please sign in to comment.