Bug 704879 - (4.5/6) Refactor message handling code into separate private messages. r=lucasr

This commit is contained in:
Margaret Leibovic 2012-03-06 11:56:43 -08:00
parent d586835f41
commit d15e231c7e

View File

@ -98,30 +98,38 @@ public class FormAssistPopup extends ListView implements GeckoEventListener {
public void handleMessage(String event, JSONObject message) {
try {
if (event.equals("FormAssist:AutoComplete")) {
final JSONArray suggestions = message.getJSONArray("suggestions");
final JSONArray rect = message.getJSONArray("rect");
final double zoom = message.getDouble("zoom");
GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
public void run() {
// Don't show autocomplete popup when using fullscreen // VKB
InputMethodManager imm =
(InputMethodManager) GeckoApp.mAppContext.getSystemService(Context.INPUT_METHOD_SERVICE);
if (!imm.isFullscreenMode())
show(suggestions, rect, zoom);
}
});
handleAutoCompleteMessage(message);
} else if (event.equals("FormAssist:Hide")) {
GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
public void run() {
hide();
}
});
handleHideMessage(message);
}
} catch (Exception e) {
Log.e(LOGTAG, "Exception handling message \"" + event + "\":", e);
}
}
private void handleAutoCompleteMessage(JSONObject message) throws JSONException {
final JSONArray suggestions = message.getJSONArray("suggestions");
final JSONArray rect = message.getJSONArray("rect");
final double zoom = message.getDouble("zoom");
GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
public void run() {
// Don't show autocomplete popup when using fullscreen VKB
InputMethodManager imm =
(InputMethodManager) GeckoApp.mAppContext.getSystemService(Context.INPUT_METHOD_SERVICE);
if (!imm.isFullscreenMode())
show(suggestions, rect, zoom);
}
});
}
private void handleHideMessage(JSONObject message) {
GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
public void run() {
hide();
}
});
}
public void show(JSONArray suggestions, JSONArray rect, double zoom) {
ArrayAdapter<String> adapter = new ArrayAdapter<String>(mContext, R.layout.autocomplete_list_item);
for (int i = 0; i < suggestions.length(); i++) {