public boolean dispatchEvent(Event evt) throws EventException { // We need to use the internal APIs to modify and access the event status EventImpl eventImpl = (EventImpl) evt; if (!eventImpl.isInitialized()) { throw new EventException(EventException.UNSPECIFIED_EVENT_TYPE_ERR, "Event not initialized"); } else if ((eventImpl.getType() == null) || eventImpl.getType().equals("")) { throw new EventException(EventException.UNSPECIFIED_EVENT_TYPE_ERR, "Unspecified even type"); } // Initialize event status eventImpl.setTarget(mNodeTarget); // TODO: At this point, to support event capturing and bubbling, we should // establish the chain of EventTargets from the top of the tree to this // event's target. // TODO: CAPTURING_PHASE skipped // Handle AT_TARGET // Invoke handleEvent of non-capturing listeners on this EventTarget. eventImpl.setEventPhase(Event.AT_TARGET); eventImpl.setCurrentTarget(mNodeTarget); if (!eventImpl.isPropogationStopped() && (mListenerEntries != null)) { for (int i = 0; i < mListenerEntries.size(); i++) { EventListenerEntry listenerEntry = mListenerEntries.get(i); if (!listenerEntry.mUseCapture && listenerEntry.mType.equals(eventImpl.getType())) { try { listenerEntry.mListener.handleEvent(eventImpl); } catch (Exception e) { // Any exceptions thrown inside an EventListener will // not stop propagation of the event Log.w(TAG, "Catched EventListener exception", e); } } } } if (eventImpl.getBubbles()) { // TODO: BUBBLING_PHASE skipped } return eventImpl.isPreventDefault(); }