Update UI in response to WiFi enabling, not Bonjour discovery enabling.

The Bonjour stuff takes a while to start, and isn't strictly neccesary
in order to swap over WiFi. Rather, it is more of a convenience. Also,
it was causing the UI to appear to lag quite a lot. This way, the WiFi
swap gets setup almost instantly, and is available to swap - therefore
the UI seems much more responsive.
This commit is contained in:
Peter Serwylo 2015-09-12 20:32:43 +10:00
parent 90ede44790
commit 198cc7357c

View File

@ -295,6 +295,10 @@ public class StartSwapView extends ScrollView implements SwapWorkflowActivity.In
int textResource = getManager().isBonjourDiscoverable() ? R.string.swap_visible_wifi : R.string.swap_not_visible_wifi; int textResource = getManager().isBonjourDiscoverable() ? R.string.swap_visible_wifi : R.string.swap_not_visible_wifi;
textWifiVisible.setText(textResource); textWifiVisible.setText(textResource);
// Note that this is only listening for the WifiSwap, whereas we start both the WifiSwap
// and the Bonjour service at the same time. Technically swap will work fine without
// Bonjour, and that is more of a convenience. Thus, we should show feedback once wifi
// is ready, even if Bonjour is not yet.
// TODO: Unregister receiver correctly... // TODO: Unregister receiver correctly...
LocalBroadcastManager.getInstance(getContext()).registerReceiver(new BroadcastReceiver() { LocalBroadcastManager.getInstance(getContext()).registerReceiver(new BroadcastReceiver() {
@Override @Override
@ -318,7 +322,7 @@ public class StartSwapView extends ScrollView implements SwapWorkflowActivity.In
} }
uiUpdateWifiNetwork(); uiUpdateWifiNetwork();
} }
}, new IntentFilter(SwapService.BONJOUR_STATE_CHANGE)); }, new IntentFilter(SwapService.WIFI_STATE_CHANGE));
viewWifiNetwork.setOnClickListener(new OnClickListener() { viewWifiNetwork.setOnClickListener(new OnClickListener() {
@Override @Override