2011-12-06 16:44:08 -08:00
|
|
|
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
2012-05-21 04:12:37 -07:00
|
|
|
* 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/. */
|
2011-12-06 16:44:08 -08:00
|
|
|
|
|
|
|
package org.mozilla.gecko;
|
|
|
|
|
|
|
|
import org.mozilla.gecko.gfx.FloatSize;
|
|
|
|
|
2012-07-27 17:53:54 -07:00
|
|
|
import org.json.JSONArray;
|
|
|
|
import org.json.JSONException;
|
|
|
|
import org.json.JSONObject;
|
|
|
|
|
2011-12-06 16:44:08 -08:00
|
|
|
import android.content.Context;
|
2012-07-27 23:13:34 -07:00
|
|
|
import android.content.res.Resources;
|
2011-12-06 16:44:08 -08:00
|
|
|
import android.util.AttributeSet;
|
2012-07-27 17:53:54 -07:00
|
|
|
import android.util.Log;
|
2012-03-06 13:56:16 -08:00
|
|
|
import android.util.Pair;
|
|
|
|
import android.view.LayoutInflater;
|
2011-12-06 16:44:08 -08:00
|
|
|
import android.view.View;
|
2012-03-06 13:56:16 -08:00
|
|
|
import android.view.ViewGroup;
|
2011-12-06 16:44:08 -08:00
|
|
|
import android.view.animation.Animation;
|
|
|
|
import android.view.animation.AnimationUtils;
|
2012-03-06 11:56:42 -08:00
|
|
|
import android.view.inputmethod.InputMethodManager;
|
2012-07-27 17:53:54 -07:00
|
|
|
import android.widget.AdapterView;
|
2012-03-21 14:08:04 -07:00
|
|
|
import android.widget.AdapterView.OnItemClickListener;
|
2011-12-06 16:44:08 -08:00
|
|
|
import android.widget.ArrayAdapter;
|
2012-04-18 15:35:36 -07:00
|
|
|
import android.widget.ImageView;
|
2011-12-06 16:44:08 -08:00
|
|
|
import android.widget.ListView;
|
2012-04-18 15:35:36 -07:00
|
|
|
import android.widget.RelativeLayout;
|
2011-12-06 16:44:08 -08:00
|
|
|
import android.widget.TextView;
|
|
|
|
|
2012-07-22 00:18:14 -07:00
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Collection;
|
|
|
|
|
2012-03-21 14:08:04 -07:00
|
|
|
public class FormAssistPopup extends RelativeLayout implements GeckoEventListener {
|
2011-12-06 16:44:08 -08:00
|
|
|
private Context mContext;
|
2012-07-22 00:18:14 -07:00
|
|
|
private Animation mAnimation;
|
2011-12-06 16:44:08 -08:00
|
|
|
|
2012-03-21 14:08:04 -07:00
|
|
|
private ListView mAutoCompleteList;
|
|
|
|
private RelativeLayout mValidationMessage;
|
|
|
|
private TextView mValidationMessageText;
|
2012-04-18 15:35:36 -07:00
|
|
|
private ImageView mValidationMessageArrow;
|
|
|
|
private ImageView mValidationMessageArrowInverted;
|
2012-03-21 14:08:04 -07:00
|
|
|
|
|
|
|
private static int sAutoCompleteMinWidth = 0;
|
|
|
|
private static int sAutoCompleteRowHeight = 0;
|
|
|
|
private static int sValidationMessageHeight = 0;
|
2012-04-18 15:35:36 -07:00
|
|
|
private static int sValidationTextMarginTop = 0;
|
|
|
|
private static RelativeLayout.LayoutParams sValidationTextLayoutNormal;
|
|
|
|
private static RelativeLayout.LayoutParams sValidationTextLayoutInverted;
|
2011-12-06 16:44:08 -08:00
|
|
|
|
2012-03-21 14:08:04 -07:00
|
|
|
private static final String LOGTAG = "FormAssistPopup";
|
2012-03-06 11:56:44 -08:00
|
|
|
|
2012-07-22 00:18:14 -07:00
|
|
|
// The blocklist is so short that ArrayList is probably cheaper than HashSet.
|
|
|
|
private static final Collection<String> sInputMethodBlocklist = Arrays.asList(new String[] {
|
|
|
|
InputMethods.METHOD_GOOGLE_JAPANESE_INPUT, // bug 775850
|
|
|
|
InputMethods.METHOD_OPENWNN_PLUS, // bug 768108
|
|
|
|
InputMethods.METHOD_SIMEJI, // bug 768108
|
|
|
|
InputMethods.METHOD_SWYPE, // bug 755909
|
|
|
|
InputMethods.METHOD_SWYPE_BETA, // bug 755909
|
|
|
|
});
|
|
|
|
|
2012-03-06 11:56:41 -08:00
|
|
|
public FormAssistPopup(Context context, AttributeSet attrs) {
|
2011-12-06 16:44:08 -08:00
|
|
|
super(context, attrs);
|
|
|
|
mContext = context;
|
|
|
|
|
|
|
|
mAnimation = AnimationUtils.loadAnimation(context, R.anim.grow_fade_in);
|
|
|
|
mAnimation.setDuration(75);
|
|
|
|
|
|
|
|
setFocusable(false);
|
|
|
|
|
2012-03-06 11:56:42 -08:00
|
|
|
GeckoAppShell.registerGeckoEventListener("FormAssist:AutoComplete", this);
|
2012-03-06 11:56:44 -08:00
|
|
|
GeckoAppShell.registerGeckoEventListener("FormAssist:ValidationMessage", this);
|
2012-03-06 11:56:43 -08:00
|
|
|
GeckoAppShell.registerGeckoEventListener("FormAssist:Hide", this);
|
2012-03-06 11:56:42 -08:00
|
|
|
}
|
|
|
|
|
2012-07-13 07:17:03 -07:00
|
|
|
void destroy() {
|
|
|
|
GeckoAppShell.unregisterGeckoEventListener("FormAssist:AutoComplete", this);
|
|
|
|
GeckoAppShell.unregisterGeckoEventListener("FormAssist:ValidationMessage", this);
|
|
|
|
GeckoAppShell.unregisterGeckoEventListener("FormAssist:Hide", this);
|
|
|
|
}
|
|
|
|
|
2012-03-06 11:56:42 -08:00
|
|
|
public void handleMessage(String event, JSONObject message) {
|
|
|
|
try {
|
|
|
|
if (event.equals("FormAssist:AutoComplete")) {
|
2012-03-06 11:56:43 -08:00
|
|
|
handleAutoCompleteMessage(message);
|
2012-03-06 11:56:44 -08:00
|
|
|
} else if (event.equals("FormAssist:ValidationMessage")) {
|
|
|
|
handleValidationMessage(message);
|
2012-03-06 11:56:43 -08:00
|
|
|
} else if (event.equals("FormAssist:Hide")) {
|
2012-03-06 11:56:43 -08:00
|
|
|
handleHideMessage(message);
|
2012-03-06 11:56:42 -08:00
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
Log.e(LOGTAG, "Exception handling message \"" + event + "\":", e);
|
|
|
|
}
|
2011-12-06 16:44:08 -08:00
|
|
|
}
|
|
|
|
|
2012-03-06 11:56:43 -08:00
|
|
|
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() {
|
2012-03-06 11:56:44 -08:00
|
|
|
showAutoCompleteSuggestions(suggestions, rect, zoom);
|
2012-03-06 11:56:43 -08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2012-03-06 11:56:44 -08:00
|
|
|
private void handleValidationMessage(JSONObject message) throws JSONException {
|
|
|
|
final String validationMessage = message.getString("validationMessage");
|
|
|
|
final JSONArray rect = message.getJSONArray("rect");
|
|
|
|
final double zoom = message.getDouble("zoom");
|
|
|
|
GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
|
|
|
|
public void run() {
|
|
|
|
showValidationMessage(validationMessage, rect, zoom);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2012-03-06 11:56:43 -08:00
|
|
|
private void handleHideMessage(JSONObject message) {
|
|
|
|
GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
|
|
|
|
public void run() {
|
|
|
|
hide();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2012-03-06 11:56:44 -08:00
|
|
|
private void showAutoCompleteSuggestions(JSONArray suggestions, JSONArray rect, double zoom) {
|
2012-03-21 14:08:04 -07:00
|
|
|
if (mAutoCompleteList == null) {
|
|
|
|
LayoutInflater inflater = LayoutInflater.from(mContext);
|
|
|
|
mAutoCompleteList = (ListView) inflater.inflate(R.layout.autocomplete_list, null);
|
|
|
|
|
|
|
|
mAutoCompleteList.setOnItemClickListener(new OnItemClickListener() {
|
|
|
|
public void onItemClick(AdapterView<?> parentView, View view, int position, long id) {
|
|
|
|
// Use the value stored with the autocomplete view, not the label text,
|
|
|
|
// since they can be different.
|
|
|
|
TextView textView = (TextView) view;
|
|
|
|
String value = (String) textView.getTag();
|
2012-07-19 11:00:07 -07:00
|
|
|
broadcastGeckoEvent("FormAssist:AutoComplete", value);
|
2012-03-21 14:08:04 -07:00
|
|
|
hide();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
addView(mAutoCompleteList);
|
|
|
|
}
|
|
|
|
|
2012-03-06 13:56:16 -08:00
|
|
|
AutoCompleteListAdapter adapter = new AutoCompleteListAdapter(mContext, R.layout.autocomplete_list_item);
|
|
|
|
adapter.populateSuggestionsList(suggestions);
|
2012-03-21 14:08:04 -07:00
|
|
|
mAutoCompleteList.setAdapter(adapter);
|
2012-03-06 11:56:44 -08:00
|
|
|
|
2012-03-21 14:08:04 -07:00
|
|
|
positionAndShowPopup(rect, zoom, true);
|
2012-03-06 11:56:44 -08:00
|
|
|
}
|
2011-12-06 16:44:08 -08:00
|
|
|
|
2012-03-06 11:56:44 -08:00
|
|
|
private void showValidationMessage(String validationMessage, JSONArray rect, double zoom) {
|
2012-03-21 14:08:04 -07:00
|
|
|
if (mValidationMessage == null) {
|
|
|
|
LayoutInflater inflater = LayoutInflater.from(mContext);
|
|
|
|
mValidationMessage = (RelativeLayout) inflater.inflate(R.layout.validation_message, null);
|
|
|
|
|
|
|
|
addView(mValidationMessage);
|
|
|
|
mValidationMessageText = (TextView) mValidationMessage.findViewById(R.id.validation_message_text);
|
2012-04-18 15:35:36 -07:00
|
|
|
|
2012-07-27 23:13:34 -07:00
|
|
|
sValidationTextMarginTop = (int) (mContext.getResources().getDimension(R.dimen.validation_message_margin_top));
|
2012-04-18 15:35:36 -07:00
|
|
|
|
|
|
|
sValidationTextLayoutNormal = new RelativeLayout.LayoutParams(mValidationMessageText.getLayoutParams());
|
|
|
|
sValidationTextLayoutNormal.setMargins(0, sValidationTextMarginTop, 0, 0);
|
|
|
|
|
|
|
|
sValidationTextLayoutInverted = new RelativeLayout.LayoutParams(sValidationTextLayoutNormal);
|
|
|
|
sValidationTextLayoutInverted.setMargins(0, 0, 0, 0);
|
|
|
|
|
|
|
|
mValidationMessageArrow = (ImageView) mValidationMessage.findViewById(R.id.validation_message_arrow);
|
|
|
|
mValidationMessageArrowInverted = (ImageView) mValidationMessage.findViewById(R.id.validation_message_arrow_inverted);
|
2012-03-21 14:08:04 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
mValidationMessageText.setText(validationMessage);
|
|
|
|
|
|
|
|
// We need to set the text as selected for the marquee text to work.
|
|
|
|
mValidationMessageText.setSelected(true);
|
2011-12-06 16:44:08 -08:00
|
|
|
|
2012-03-21 14:08:04 -07:00
|
|
|
positionAndShowPopup(rect, zoom, false);
|
2012-03-06 11:56:44 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Returns true if the popup is successfully shown, false otherwise
|
2012-03-21 14:08:04 -07:00
|
|
|
private boolean positionAndShowPopup(JSONArray rect, double zoom, boolean isAutoComplete) {
|
2012-03-06 11:56:44 -08:00
|
|
|
// Don't show the form assist popup when using fullscreen VKB
|
|
|
|
InputMethodManager imm =
|
|
|
|
(InputMethodManager) GeckoApp.mAppContext.getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
|
if (imm.isFullscreenMode())
|
|
|
|
return false;
|
|
|
|
|
2012-02-03 14:10:49 -08:00
|
|
|
if (!isShown()) {
|
2012-03-21 14:08:04 -07:00
|
|
|
setVisibility(VISIBLE);
|
2012-02-03 14:10:49 -08:00
|
|
|
startAnimation(mAnimation);
|
|
|
|
}
|
2011-12-06 16:44:08 -08:00
|
|
|
|
2012-03-21 14:08:04 -07:00
|
|
|
// Hide/show the appropriate popup contents
|
|
|
|
if (mAutoCompleteList != null)
|
|
|
|
mAutoCompleteList.setVisibility(isAutoComplete ? VISIBLE : GONE);
|
|
|
|
if (mValidationMessage != null)
|
|
|
|
mValidationMessage.setVisibility(isAutoComplete ? GONE : VISIBLE);
|
|
|
|
|
|
|
|
if (sAutoCompleteMinWidth == 0) {
|
2012-07-27 23:13:34 -07:00
|
|
|
Resources res = mContext.getResources();
|
|
|
|
sAutoCompleteMinWidth = (int) (res.getDimension(R.dimen.autocomplete_min_width));
|
|
|
|
sAutoCompleteRowHeight = (int) (res.getDimension(R.dimen.autocomplete_row_height));
|
|
|
|
sValidationMessageHeight = (int) (res.getDimension(R.dimen.validation_message_height));
|
2012-03-21 14:08:04 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// These values correspond to the input box for which we want to
|
|
|
|
// display the FormAssistPopup.
|
2011-12-06 16:44:08 -08:00
|
|
|
int left = 0;
|
|
|
|
int top = 0;
|
|
|
|
int width = 0;
|
|
|
|
int height = 0;
|
|
|
|
|
|
|
|
try {
|
|
|
|
left = (int) (rect.getDouble(0) * zoom);
|
|
|
|
top = (int) (rect.getDouble(1) * zoom);
|
|
|
|
width = (int) (rect.getDouble(2) * zoom);
|
|
|
|
height = (int) (rect.getDouble(3) * zoom);
|
|
|
|
} catch (JSONException e) { }
|
|
|
|
|
2012-03-21 14:08:00 -07:00
|
|
|
int popupWidth = RelativeLayout.LayoutParams.FILL_PARENT;
|
2012-03-21 14:07:57 -07:00
|
|
|
int popupLeft = left < 0 ? 0 : left;
|
2011-12-06 16:44:08 -08:00
|
|
|
|
Backout d2ee4c12c0b3 (bug 777351), 5aa6f94160dd (bug 777351), b47c470168fc (bug 777351), 5fb303ba52f7 (bug 777351), be81e4c3d928 (bug 777351), abc5b9a922dc (bug 777075), 8f1fc980f1f1 (bug 777075), 0b194a7f47d4 (bug 777075), d10df9bfef60 (bug 777075), 65393fe32cce (bug 777075), b52dc1df2fde (bug 777075), 8aeda525c094 (bug 777075) for Android native R1 failures on a CLOSED TREE
2012-08-01 10:42:05 -07:00
|
|
|
FloatSize viewport = GeckoApp.mAppContext.getLayerController().getViewportSize();
|
2011-12-06 16:44:08 -08:00
|
|
|
|
2012-03-21 14:08:04 -07:00
|
|
|
// For autocomplete suggestions, if the input is smaller than the screen-width,
|
|
|
|
// shrink the popup's width. Otherwise, keep it as FILL_PARENT.
|
|
|
|
if (isAutoComplete && (left + width) < viewport.width) {
|
2012-03-21 14:07:57 -07:00
|
|
|
popupWidth = left < 0 ? left + width : width;
|
2012-01-27 12:10:45 -08:00
|
|
|
|
2012-03-21 14:08:04 -07:00
|
|
|
// Ensure the popup has a minimum width.
|
|
|
|
if (popupWidth < sAutoCompleteMinWidth) {
|
|
|
|
popupWidth = sAutoCompleteMinWidth;
|
2012-01-27 12:10:45 -08:00
|
|
|
|
2012-03-21 14:08:04 -07:00
|
|
|
// Move the popup to the left if there isn't enough room for it.
|
|
|
|
if ((popupLeft + popupWidth) > viewport.width)
|
|
|
|
popupLeft = (int) (viewport.width - popupWidth);
|
|
|
|
}
|
2012-01-27 12:10:45 -08:00
|
|
|
}
|
2011-12-06 16:44:08 -08:00
|
|
|
|
2012-03-21 14:08:04 -07:00
|
|
|
int popupHeight;
|
|
|
|
if (isAutoComplete)
|
|
|
|
popupHeight = sAutoCompleteRowHeight * mAutoCompleteList.getAdapter().getCount();
|
|
|
|
else
|
|
|
|
popupHeight = sValidationMessageHeight;
|
|
|
|
|
2012-03-21 14:08:00 -07:00
|
|
|
int popupTop = top + height;
|
2012-02-03 14:10:49 -08:00
|
|
|
|
2012-04-18 15:35:36 -07:00
|
|
|
if (!isAutoComplete) {
|
|
|
|
mValidationMessageText.setLayoutParams(sValidationTextLayoutNormal);
|
|
|
|
mValidationMessageArrow.setVisibility(VISIBLE);
|
|
|
|
mValidationMessageArrowInverted.setVisibility(GONE);
|
|
|
|
}
|
|
|
|
|
2012-03-21 14:08:04 -07:00
|
|
|
// If the popup doesn't fit below the input box, shrink its height, or
|
|
|
|
// see if we can place it above the input instead.
|
2012-03-21 14:07:57 -07:00
|
|
|
if ((popupTop + popupHeight) > viewport.height) {
|
2012-03-21 14:08:04 -07:00
|
|
|
// Find where the maximum space is, and put the popup there.
|
2012-03-21 14:07:57 -07:00
|
|
|
if ((viewport.height - popupTop) > top) {
|
2012-03-21 14:08:04 -07:00
|
|
|
// Shrink the height to fit it below the input box.
|
2012-03-21 14:07:57 -07:00
|
|
|
popupHeight = (int) (viewport.height - popupTop);
|
2012-02-03 14:10:49 -08:00
|
|
|
} else {
|
2012-03-21 14:07:57 -07:00
|
|
|
if (popupHeight < top) {
|
2012-03-21 14:08:04 -07:00
|
|
|
// No shrinking needed to fit on top.
|
2012-03-21 14:07:57 -07:00
|
|
|
popupTop = (top - popupHeight);
|
2012-02-03 14:10:49 -08:00
|
|
|
} else {
|
2012-03-21 14:08:04 -07:00
|
|
|
// Shrink to available space on top.
|
2012-03-21 14:07:57 -07:00
|
|
|
popupTop = 0;
|
|
|
|
popupHeight = top;
|
2012-02-03 14:10:49 -08:00
|
|
|
}
|
2012-04-18 15:35:36 -07:00
|
|
|
|
|
|
|
if (!isAutoComplete) {
|
|
|
|
mValidationMessageText.setLayoutParams(sValidationTextLayoutInverted);
|
|
|
|
mValidationMessageArrow.setVisibility(GONE);
|
|
|
|
mValidationMessageArrowInverted.setVisibility(VISIBLE);
|
|
|
|
}
|
2012-02-03 14:10:49 -08:00
|
|
|
}
|
|
|
|
}
|
2011-12-06 16:44:08 -08:00
|
|
|
|
2012-03-21 14:08:00 -07:00
|
|
|
RelativeLayout.LayoutParams layoutParams =
|
|
|
|
new RelativeLayout.LayoutParams(popupWidth, popupHeight);
|
|
|
|
layoutParams.setMargins(popupLeft, popupTop, 0, 0);
|
|
|
|
setLayoutParams(layoutParams);
|
2011-12-06 16:44:08 -08:00
|
|
|
requestLayout();
|
2012-03-06 11:56:44 -08:00
|
|
|
|
|
|
|
return true;
|
2011-12-06 16:44:08 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void hide() {
|
|
|
|
if (isShown()) {
|
2012-03-21 14:08:04 -07:00
|
|
|
setVisibility(GONE);
|
2012-07-19 11:00:07 -07:00
|
|
|
broadcastGeckoEvent("FormAssist:Hidden", null);
|
2011-12-06 16:44:08 -08:00
|
|
|
}
|
|
|
|
}
|
2012-03-06 13:56:16 -08:00
|
|
|
|
2012-07-22 00:18:14 -07:00
|
|
|
void onInputMethodChanged(String newInputMethod) {
|
|
|
|
boolean blocklisted = sInputMethodBlocklist.contains(newInputMethod);
|
|
|
|
broadcastGeckoEvent("FormAssist:Blocklisted", String.valueOf(blocklisted));
|
2012-07-19 11:00:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
private static void broadcastGeckoEvent(String eventName, String eventData) {
|
|
|
|
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent(eventName, eventData));
|
|
|
|
}
|
|
|
|
|
2012-03-06 13:56:16 -08:00
|
|
|
private class AutoCompleteListAdapter extends ArrayAdapter<Pair<String, String>> {
|
|
|
|
private LayoutInflater mInflater;
|
|
|
|
private int mTextViewResourceId;
|
|
|
|
|
|
|
|
public AutoCompleteListAdapter(Context context, int textViewResourceId) {
|
|
|
|
super(context, textViewResourceId);
|
|
|
|
|
|
|
|
mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
|
|
mTextViewResourceId = textViewResourceId;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This method takes an array of autocomplete suggestions with label/value properties
|
|
|
|
// and adds label/value Pair objects to the array that backs the adapter.
|
|
|
|
public void populateSuggestionsList(JSONArray suggestions) {
|
|
|
|
try {
|
|
|
|
for (int i = 0; i < suggestions.length(); i++) {
|
2012-03-20 10:52:19 -07:00
|
|
|
JSONObject suggestion = suggestions.getJSONObject(i);
|
2012-03-06 13:56:16 -08:00
|
|
|
String label = suggestion.getString("label");
|
|
|
|
String value = suggestion.getString("value");
|
|
|
|
add(new Pair<String, String>(label, value));
|
|
|
|
}
|
|
|
|
} catch (JSONException e) {
|
2012-07-23 12:04:28 -07:00
|
|
|
Log.e(LOGTAG, "JSONException", e);
|
2012-03-06 13:56:16 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public View getView(int position, View convertView, ViewGroup parent) {
|
|
|
|
if (convertView == null)
|
|
|
|
convertView = mInflater.inflate(mTextViewResourceId, null);
|
|
|
|
|
|
|
|
Pair<String, String> item = getItem(position);
|
|
|
|
TextView itemView = (TextView) convertView;
|
|
|
|
|
|
|
|
// Set the text with the suggestion label
|
|
|
|
itemView.setText(item.first);
|
|
|
|
|
|
|
|
// Set a tag with the suggestion value
|
|
|
|
itemView.setTag(item.second);
|
|
|
|
|
|
|
|
return convertView;
|
|
|
|
}
|
|
|
|
}
|
2011-12-06 16:44:08 -08:00
|
|
|
}
|