Back to project page android-pdfview.
The source code is released under:
GNU General Public License
If you think the Android project android-pdfview listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.vudroid.core.events; //w w w. ja v a 2s . c o m import java.lang.reflect.Method; public abstract class SafeEvent<T> implements Event<T> { private final Class<?> listenerType; protected SafeEvent() { listenerType = getListenerType(); } private Class<?> getListenerType() { for (Method method : getClass().getMethods()) { if ("dispatchSafely".equals(method.getName()) && !method.isSynthetic()) { return method.getParameterTypes()[0]; } } throw new RuntimeException("Couldn't find dispatchSafely method"); } @SuppressWarnings({"unchecked"}) public final void dispatchOn(Object listener) { if (listenerType.isAssignableFrom(listener.getClass())) { dispatchSafely((T) listener); } } public abstract void dispatchSafely(T listener); }