From 56d8a49d5bcdd21d51d47ccb6a1736eaf63cfd3c Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Fri, 30 Sep 2016 19:20:04 +0200 Subject: [PATCH] only disconnect device when confirming delete dialog --- .../gadgetbridge/activities/ControlCenter.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ControlCenter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ControlCenter.java index d78a743e..cb9081b0 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ControlCenter.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ControlCenter.java @@ -300,7 +300,6 @@ public class ControlCenter extends GBActivity { return true; case R.id.controlcenter_delete_device: if (selectedDevice != null) { - GBApplication.deviceService().disconnect(); showDeleteDeviceDialog(selectedDevice); selectedDevice = null; refreshPairedDevices(); @@ -372,6 +371,10 @@ public class ControlCenter extends GBActivity { private void deleteDevice(final GBDevice gbDevice) { LOG.info("will try to delete device: " + gbDevice.getName()); + if (gbDevice.isConnected() || gbDevice.isConnected()) { + GBApplication.deviceService().disconnect(); + } + GBApplication.deviceService().disconnect(); try (DBHandler dbHandler = GBApplication.acquireDB()) { DaoSession session = dbHandler.getDaoSession(); Device device = DBHelper.getDevice(gbDevice, session);