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 JmDNS resolver;
|
||||||
private HashMap<InetAddress, MdnsComputer> computers;
|
private HashMap<InetAddress, MdnsComputer> computers;
|
||||||
private Timer discoveryTimer;
|
|
||||||
private MdnsDiscoveryListener listener;
|
private MdnsDiscoveryListener listener;
|
||||||
private HashSet<String> pendingResolution;
|
private HashSet<String> pendingResolution;
|
||||||
private boolean stop;
|
private boolean stop;
|
||||||
@ -102,10 +101,11 @@ public class MdnsDiscoveryAgent {
|
|||||||
|
|
||||||
public void startDiscovery(final int discoveryIntervalMs) {
|
public void startDiscovery(final int discoveryIntervalMs) {
|
||||||
stop = false;
|
stop = false;
|
||||||
discoveryTimer = new Timer();
|
final Timer t = new Timer();
|
||||||
discoveryTimer.schedule(new TimerTask() {
|
t.schedule(new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
synchronized (MdnsDiscoveryAgent.this) {
|
||||||
// Close the old resolver
|
// Close the old resolver
|
||||||
if (resolver != null) {
|
if (resolver != null) {
|
||||||
try {
|
try {
|
||||||
@ -117,10 +117,7 @@ public class MdnsDiscoveryAgent {
|
|||||||
// Stop if requested
|
// Stop if requested
|
||||||
if (stop) {
|
if (stop) {
|
||||||
// There will be no further timer invocations now
|
// There will be no further timer invocations now
|
||||||
if (discoveryTimer != null) {
|
t.cancel();
|
||||||
discoveryTimer.cancel();
|
|
||||||
discoveryTimer = null;
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,6 +140,7 @@ public class MdnsDiscoveryAgent {
|
|||||||
resolver.getServiceInfo(SERVICE_TYPE, name);
|
resolver.getServiceInfo(SERVICE_TYPE, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}, 0, discoveryIntervalMs);
|
}, 0, discoveryIntervalMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user