Fix crash during device discovery
This commit is contained in:
parent
43f95aee9c
commit
3bb1a228ec
|
@ -82,7 +82,7 @@ public class ControlCenter extends GBActivity {
|
||||||
};
|
};
|
||||||
|
|
||||||
private void refreshBusyState(GBDevice dev) {
|
private void refreshBusyState(GBDevice dev) {
|
||||||
if (dev.isBusy()) {
|
if (dev != null && dev.isBusy()) {
|
||||||
swipeLayout.setRefreshing(true);
|
swipeLayout.setRefreshing(true);
|
||||||
} else {
|
} else {
|
||||||
boolean wasBusy = swipeLayout.isRefreshing();
|
boolean wasBusy = swipeLayout.isRefreshing();
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -86,12 +87,13 @@ public class DeviceManager {
|
||||||
if (selectedDevice == null) {
|
if (selectedDevice == null) {
|
||||||
selectedDevice = dev;
|
selectedDevice = dev;
|
||||||
} else {
|
} else {
|
||||||
if (!selectedDevice.equals(dev)) {
|
if (selectedDevice.equals(dev)) {
|
||||||
|
selectedDevice = dev; // equality vs identity!
|
||||||
|
} else {
|
||||||
if (selectedDevice.isConnected() && dev.isConnected()) {
|
if (selectedDevice.isConnected() && dev.isConnected()) {
|
||||||
LOG.warn("multiple connected devices -- this is currently not really supported");
|
LOG.warn("multiple connected devices -- this is currently not really supported");
|
||||||
selectedDevice = dev; // use the last one that changed
|
selectedDevice = dev; // use the last one that changed
|
||||||
}
|
} else if (!selectedDevice.isConnected()) {
|
||||||
if (!selectedDevice.isConnected()) {
|
|
||||||
selectedDevice = dev; // use the last one that changed
|
selectedDevice = dev; // use the last one that changed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,6 +120,7 @@ public class DeviceManager {
|
||||||
return Collections.unmodifiableList(deviceList);
|
return Collections.unmodifiableList(deviceList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public GBDevice getSelectedDevice() {
|
public GBDevice getSelectedDevice() {
|
||||||
return selectedDevice;
|
return selectedDevice;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue