mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-20 11:33:06 +00:00
Properly fix the timer crash
This commit is contained in:
parent
93bf28b87d
commit
44366db4d5
@ -23,7 +23,6 @@ public class MdnsDiscoveryAgent {
|
||||
|
||||
private JmDNS resolver;
|
||||
private HashMap<InetAddress, MdnsComputer> computers;
|
||||
private Timer discoveryTimer;
|
||||
private MdnsDiscoveryListener listener;
|
||||
private HashSet<String> pendingResolution;
|
||||
private boolean stop;
|
||||
@ -102,10 +101,11 @@ public class MdnsDiscoveryAgent {
|
||||
|
||||
public void startDiscovery(final int discoveryIntervalMs) {
|
||||
stop = false;
|
||||
discoveryTimer = new Timer();
|
||||
discoveryTimer.schedule(new TimerTask() {
|
||||
final Timer t = new Timer();
|
||||
t.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (MdnsDiscoveryAgent.this) {
|
||||
// Close the old resolver
|
||||
if (resolver != null) {
|
||||
try {
|
||||
@ -117,10 +117,7 @@ public class MdnsDiscoveryAgent {
|
||||
// Stop if requested
|
||||
if (stop) {
|
||||
// There will be no further timer invocations now
|
||||
if (discoveryTimer != null) {
|
||||
discoveryTimer.cancel();
|
||||
discoveryTimer = null;
|
||||
}
|
||||
t.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -143,6 +140,7 @@ public class MdnsDiscoveryAgent {
|
||||
resolver.getServiceInfo(SERVICE_TYPE, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 0, discoveryIntervalMs);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user