AnimationListener

This commit is contained in:
ngb
2022-07-11 14:41:45 +02:00
parent bc791a9dc3
commit 855d67c873
2 changed files with 37 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
package schule.ngb.zm.anim;
import schule.ngb.zm.events.EventDispatcher;
public class Animation {
EventDispatcher<Animation, AnimationListener> eventDispatcher;
private EventDispatcher<Animation, AnimationListener> initializeEventDispatcher() {
if( eventDispatcher == null ) {
eventDispatcher = new EventDispatcher<>();
eventDispatcher.registerEventType("start", ( a, l ) -> l.animationStarted(a));
eventDispatcher.registerEventType("stop", ( a, l ) -> l.animationStopped(a));
}
return eventDispatcher;
}
public void addListener( AnimationListener listener ) {
initializeEventDispatcher().addListener(listener);
}
public void removeListener( AnimationListener listener ) {
initializeEventDispatcher().removeListener(listener);
}
}

View File

@@ -0,0 +1,11 @@
package schule.ngb.zm.anim;
import schule.ngb.zm.events.Listener;
public interface AnimationListener extends Listener<Animation> {
void animationStarted( Animation anim );
void animationStopped( Animation anim );
}