blob: bf4d6e8c29ac0e32f672872cc95a73cd3fa43cb0 (
plain)
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
|
package de.pixart.messenger.utils;
public class ReplacingSerialSingleThreadExecutor extends SerialSingleThreadExecutor {
public ReplacingSerialSingleThreadExecutor(String name) {
super(name, false);
}
public ReplacingSerialSingleThreadExecutor(boolean prepareLooper) {
super(ReplacingSerialSingleThreadExecutor.class.getName(), prepareLooper);
}
@Override
public synchronized void execute(final Runnable r) {
tasks.clear();
if (active != null && active instanceof Cancellable) {
((Cancellable) active).cancel();
}
super.execute(r);
}
public synchronized void cancelRunningTasks() {
tasks.clear();
if (active != null && active instanceof Cancellable) {
((Cancellable) active).cancel();
}
}
}
|