Changed the DelayTimer to use Runnable instead of it's own

This commit is contained in:
nathan 2015-12-17 02:05:23 +01:00
parent 72a4380383
commit bffa46cd27

View File

@ -22,12 +22,12 @@ public
class DelayTimer { class DelayTimer {
private final String name; private final String name;
private final boolean isDaemon; private final boolean isDaemon;
private final Callback listener; private final Runnable listener;
private Timer timer; private Timer timer;
private long delay; private long delay;
public public
DelayTimer(Callback listener) { DelayTimer(Runnable listener) {
this(null, true, listener); this(null, true, listener);
} }
@ -39,7 +39,7 @@ class DelayTimer {
* @param listener the callback listener to execute * @param listener the callback listener to execute
*/ */
public public
DelayTimer(String name, boolean isDaemon, Callback listener) { DelayTimer(String name, boolean isDaemon, Runnable listener) {
this.name = name; this.name = name;
this.listener = listener; this.listener = listener;
this.isDaemon = isDaemon; this.isDaemon = isDaemon;
@ -85,14 +85,14 @@ class DelayTimer {
@Override @Override
public public
void run() { void run() {
DelayTimer.this.listener.execute(); DelayTimer.this.listener.run();
DelayTimer.this.cancel(); DelayTimer.this.cancel();
} }
}; };
this.timer.schedule(t, delay); this.timer.schedule(t, delay);
} }
else { else {
this.listener.execute(); this.listener.run();
this.timer = null; this.timer = null;
} }
} }
@ -101,10 +101,4 @@ class DelayTimer {
long getDelay() { long getDelay() {
return this.delay; return this.delay;
} }
public
interface Callback {
public
void execute();
}
} }