Newer
Older
CactusClient / src / framework / subject / MySubject.java
s-iwatani on 15 May 2018 543 bytes 途中
package framework.subject;

import android.view.InputEvent;

import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;

import framework.listener.MyListener;

public abstract class MySubject {
    protected Set<MyListener> listenerSet = new CopyOnWriteArraySet<MyListener>();

    public void addListener(MyListener listener) {
        listenerSet.add(listener);
    }

    protected void notifyListeners(InputEvent event) {
        for (MyListener listener : listenerSet) {
            listener.onEvent(event);
        }
    }
}