Bug 730710 - Add a GeckoEventResponder interface to allow event listeners to respond to events as well. r=blassey

This commit is contained in:
Kartikaya Gupta 2012-02-27 10:13:36 -05:00
Родитель 16fe0c30f9
Коммит 451c69109e
3 изменённых файлов: 32 добавлений и 6 удалений

Просмотреть файл

@ -1626,15 +1626,26 @@ public class GeckoAppShell
if (mEventListeners == null)
return "";
if (!mEventListeners.containsKey(type))
return "";
ArrayList<GeckoEventListener> listeners = mEventListeners.get(type);
Iterator<GeckoEventListener> items = listeners.iterator();
while (items.hasNext()) {
items.next().handleMessage(type, geckoObject);
if (listeners == null)
return "";
String response = null;
for (GeckoEventListener listener : listeners) {
listener.handleMessage(type, geckoObject);
if (listener instanceof GeckoEventResponder) {
String newResponse = ((GeckoEventResponder)listener).getResponse();
if (response != null && newResponse != null) {
Log.e(LOGTAG, "Received two responses for message of type " + type);
}
response = newResponse;
}
}
if (response != null)
return response;
} catch (Exception e) {
Log.i(LOGTAG, "handleGeckoMessage throws " + e);
}

Просмотреть файл

@ -0,0 +1,14 @@
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* ***** BEGIN LICENSE BLOCK *****
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* ***** END LICENSE BLOCK ***** */
package org.mozilla.gecko;
public interface GeckoEventResponder extends GeckoEventListener {
public String getResponse();
}

Просмотреть файл

@ -86,6 +86,7 @@ FENNEC_JAVA_FILES = \
GeckoConnectivityReceiver.java \
GeckoEvent.java \
GeckoEventListener.java \
GeckoEventResponder.java \
GeckoInputConnection.java \
GeckoPreferences.java \
GeckoProfile.java \