mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-28 21:06:50 +01:00
Only refresh when deletion of device was confirmed
This commit is contained in:
parent
5e63b7ce04
commit
b890242c4f
@ -300,11 +300,12 @@ public class ControlCenter extends GBActivity {
|
||||
return true;
|
||||
case R.id.controlcenter_delete_device:
|
||||
if (selectedDevice != null) {
|
||||
showDeleteDeviceDialog(selectedDevice);
|
||||
if (confirmDeleteDevice(selectedDevice)) {
|
||||
selectedDevice = null;
|
||||
Intent refreshIntent = new Intent(DeviceManager.ACTION_REFRESH_DEVICELIST);
|
||||
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(refreshIntent);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return super.onContextItemSelected(item);
|
||||
@ -350,7 +351,8 @@ public class ControlCenter extends GBActivity {
|
||||
startActivity(new Intent(this, DiscoveryActivity.class));
|
||||
}
|
||||
|
||||
private void showDeleteDeviceDialog(final GBDevice gbDevice) {
|
||||
private boolean confirmDeleteDevice(final GBDevice gbDevice) {
|
||||
final boolean[] result = new boolean[1];
|
||||
new AlertDialog.Builder(this)
|
||||
.setCancelable(true)
|
||||
.setTitle(R.string.controlcenter_delete_device)
|
||||
@ -359,6 +361,7 @@ public class ControlCenter extends GBActivity {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
deleteDevice(gbDevice);
|
||||
result[0] = true;
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener() {
|
||||
@ -368,6 +371,7 @@ public class ControlCenter extends GBActivity {
|
||||
}
|
||||
})
|
||||
.show();
|
||||
return result[0];
|
||||
}
|
||||
|
||||
private void deleteDevice(final GBDevice gbDevice) {
|
||||
|
Loading…
Reference in New Issue
Block a user