Skip to content
Snippets Groups Projects
Commit dcc6f76c authored by Sebastian's avatar Sebastian
Browse files

Use postValue() instead of setValue() on live data

Those calls can happen from the RPC layer now, which are not on the UI
thread.
parent 121caab8
No related branches found
No related tags found
No related merge requests found
......@@ -261,7 +261,7 @@ abstract class AbstractLanService implements LanService {
LOG.info("Failed to accept connection: " + e);
}
});
localAddress.setValue(ipString(serverSocket.getInetAddress()));
localAddress.postValue(ipString(serverSocket.getInetAddress()));
return getLocalSocketAddress();
}
......
......@@ -106,11 +106,11 @@ class LsdServiceImpl extends AbstractLanService implements LsdService {
return;
}
LOG.info("Starting advertising");
advertisingStatus.setValue(STARTING);
advertisingStatus.postValue(STARTING);
InetSocketAddress socketAddress = acquireResources();
if (socketAddress == null) {
LOG.info("Failed to start advertising");
advertisingStatus.setValue(STOPPED);
advertisingStatus.postValue(STOPPED);
return;
}
if (executor == null || multicastSocket == null) throw new AssertionError();
......@@ -118,7 +118,7 @@ class LsdServiceImpl extends AbstractLanService implements LsdService {
advertisingTask = executor.scheduleAtFixedRate(
() -> sendAdvertisingPacket(multicastSocket, socketAddress), 0,
ADVERTISING_INTERVAL_MS, MILLISECONDS);
advertisingStatus.setValue(STARTED);
advertisingStatus.postValue(STARTED);
}
@Override
......@@ -129,11 +129,11 @@ class LsdServiceImpl extends AbstractLanService implements LsdService {
return;
}
LOG.info("Stopping advertising");
advertisingStatus.setValue(STOPPING);
advertisingStatus.postValue(STOPPING);
requireNonNull(advertisingTask).cancel(false);
advertisingTask = null;
releaseResources();
advertisingStatus.setValue(STOPPED);
advertisingStatus.postValue(STOPPED);
}
@Override
......@@ -144,14 +144,14 @@ class LsdServiceImpl extends AbstractLanService implements LsdService {
return;
}
LOG.info("Starting discovery");
discoveryStatus.setValue(STARTING);
discoveryStatus.postValue(STARTING);
InetSocketAddress socketAddress = acquireResources();
if (socketAddress == null) {
LOG.info("Failed to start discovery");
discoveryStatus.setValue(STOPPED);
discoveryStatus.postValue(STOPPED);
return;
}
discoveryStatus.setValue(STARTED);
discoveryStatus.postValue(STARTED);
}
@Override
......@@ -162,9 +162,9 @@ class LsdServiceImpl extends AbstractLanService implements LsdService {
return;
}
LOG.info("Stopping discovery");
discoveryStatus.setValue(STOPPING);
discoveryStatus.postValue(STOPPING);
releaseResources();
discoveryStatus.setValue(STOPPED);
discoveryStatus.postValue(STOPPED);
}
@Nullable
......@@ -275,7 +275,7 @@ class LsdServiceImpl extends AbstractLanService implements LsdService {
.build();
}
peersByAddress.put(address, updated);
peers.setValue(new ArrayList<>(peersByAddress.values()));
peers.postValue(new ArrayList<>(peersByAddress.values()));
}
@WorkerThread
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment