FileDocCategorySizeDatePackage
PointerEventDispatcher.javaAPI DocAndroid 5.1 API3254Thu Mar 12 22:22:42 GMT 2015com.android.server.wm

PointerEventDispatcher

public class PointerEventDispatcher extends android.view.InputEventReceiver

Fields Summary
ArrayList
mListeners
android.view.WindowManagerPolicy.PointerEventListener[]
mListenersArray
Constructors Summary
public PointerEventDispatcher(android.view.InputChannel inputChannel)


       
        super(inputChannel, UiThread.getHandler().getLooper());
    
Methods Summary
public voidonInputEvent(android.view.InputEvent event)

        try {
            if (event instanceof MotionEvent
                    && (event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) {
                final MotionEvent motionEvent = (MotionEvent)event;
                PointerEventListener[] listeners;
                synchronized (mListeners) {
                    if (mListenersArray == null) {
                        mListenersArray = new PointerEventListener[mListeners.size()];
                        mListeners.toArray(mListenersArray);
                    }
                    listeners = mListenersArray;
                }
                for (int i = 0; i < listeners.length; ++i) {
                    listeners[i].onPointerEvent(motionEvent);
                }
            }
        } finally {
            finishInputEvent(event, false);
        }
    
public voidregisterInputEventListener(android.view.WindowManagerPolicy.PointerEventListener listener)
Add the specified listener to the list.

param
listener The listener to add.

        synchronized (mListeners) {
            if (mListeners.contains(listener)) {
                throw new IllegalStateException("registerInputEventListener: trying to register" +
                        listener + " twice.");
            }
            mListeners.add(listener);
            mListenersArray = null;
        }
    
public voidunregisterInputEventListener(android.view.WindowManagerPolicy.PointerEventListener listener)
Remove the specified listener from the list.

param
listener The listener to remove.

        synchronized (mListeners) {
            if (!mListeners.contains(listener)) {
                throw new IllegalStateException("registerInputEventListener: " + listener +
                        " not registered.");
            }
            mListeners.remove(listener);
            mListenersArray = null;
        }