-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDispatchQueue.java
More file actions
79 lines (67 loc) · 1.91 KB
/
DispatchQueue.java
File metadata and controls
79 lines (67 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package io.audd.example.utility;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import java.util.concurrent.CountDownLatch;
public class DispatchQueue extends Thread {
private volatile Handler handler = null;
private CountDownLatch syncLatch = new CountDownLatch(1);
class C03501 extends Handler {
C03501() {
}
public void handleMessage(Message msg) {
DispatchQueue.this.handleMessage(msg);
}
}
public DispatchQueue(String threadName) {
setName(threadName);
start();
}
public void sendMessage(Message msg, int delay) {
try {
this.syncLatch.await();
if (delay <= 0) {
this.handler.sendMessage(msg);
} else {
this.handler.sendMessageDelayed(msg, (long) delay);
}
} catch (Throwable th) {
}
}
public void cancelRunnable(Runnable runnable) {
try {
this.syncLatch.await();
this.handler.removeCallbacks(runnable);
} catch (Throwable th) {
}
}
public void postRunnable(Runnable runnable) {
postRunnable(runnable, 0);
}
public void postRunnable(Runnable runnable, long delay) {
try {
this.syncLatch.await();
if (delay <= 0) {
this.handler.post(runnable);
} else {
this.handler.postDelayed(runnable, delay);
}
} catch (Throwable th) {
}
}
public void cleanupQueue() {
try {
this.syncLatch.await();
this.handler.removeCallbacksAndMessages(null);
} catch (Throwable th) {
}
}
public void handleMessage(Message inputMessage) {
}
public void run() {
Looper.prepare();
this.handler = new C03501();
this.syncLatch.countDown();
Looper.loop();
}
}