application cycle verwijderd, structuur input listener aangepast en event manager netter gemaakt.

This commit is contained in:
Bram Veenboer
2011-04-27 20:03:08 +00:00
parent 12467a043e
commit a268f91023
7 changed files with 58 additions and 66 deletions

View File

@@ -5,15 +5,15 @@ import java.util.ArrayList;
import pm.Application;
import pm.Device;
import pm.Main;
import pm.application.ApplicationCycle;
import pm.event.task.Stopper;
import pm.util.ArrayCycle;
import pm.value.Target;
public class EventManager {
protected static ArrayList<EventListener> eventListenerList;
protected static ApplicationCycle applicationCycle;
protected static ArrayCycle<Application> applicationCycle;
public static void initialise(ApplicationCycle applicationCycle) {
public static void initialise(ArrayCycle<Application> applicationCycle) {
eventListenerList = new ArrayList<EventListener>();
EventManager.applicationCycle = applicationCycle;
}
@@ -30,8 +30,7 @@ public class EventManager {
public static void add(EventListener self, Task task) {
if (task instanceof Stopper) {
Stopper stopper = (Stopper) task;
stopper.stop();
((Stopper) task).stop();
} else {
Target target = task.getTarget();
switch (target) {
@@ -43,7 +42,7 @@ public class EventManager {
applicationCycle.current().add(task);
}
break;
default:
default: {
for (EventListener eventListener : eventListenerList) {
switch (target) {
case ALL:
@@ -66,11 +65,16 @@ public class EventManager {
break;
}
}
}
}
}
}
public static void add(Task task) {
add(null, task);
}
private static void add(Task task) {
if (!task.getTarget().equals(Target.SELF)) {
add(null, task);
}