summaryrefslogtreecommitdiffstats
path: root/core/java/android/app/SuggestionsAdapter.java
diff options
context:
space:
mode:
authorMike LeBeau <mlebeau@android.com>2009-06-01 21:53:09 +0100
committerMike LeBeau <mlebeau@android.com>2009-06-01 21:53:09 +0100
commitae9760b62c400e3e7009d4a7b85e9524a5cd44fc (patch)
tree3e205a0f7183c166d96f60b76535150d23468656 /core/java/android/app/SuggestionsAdapter.java
parent11b1675a9348adabd9370ac01ae9c614ca4af384 (diff)
downloadframeworks_base-ae9760b62c400e3e7009d4a7b85e9524a5cd44fc.zip
frameworks_base-ae9760b62c400e3e7009d4a7b85e9524a5cd44fc.tar.gz
frameworks_base-ae9760b62c400e3e7009d4a7b85e9524a5cd44fc.tar.bz2
Add framework support for scrolling to the "More results..." list item
when it is clicked.
Diffstat (limited to 'core/java/android/app/SuggestionsAdapter.java')
-rw-r--r--core/java/android/app/SuggestionsAdapter.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/core/java/android/app/SuggestionsAdapter.java b/core/java/android/app/SuggestionsAdapter.java
index aeb96b4..4406f8e 100644
--- a/core/java/android/app/SuggestionsAdapter.java
+++ b/core/java/android/app/SuggestionsAdapter.java
@@ -50,6 +50,11 @@ class SuggestionsAdapter extends ResourceCursorAdapter {
// so we can correctly display (or not display) the 'working' spinner in the search dialog.
public static final String IS_WORKING = "isWorking";
+ // The value used to tell a cursor to display the corpus selectors, if this is global
+ // search. Also returns the index of the more results item to allow the SearchDialog
+ // to tell the ListView to scroll to that list item.
+ public static final String SHOW_CORPUS_SELECTORS = "showCorpusSelectors";
+
private static final boolean DBG = false;
private static final String LOG_TAG = "SuggestionsAdapter";
@@ -68,6 +73,13 @@ class SuggestionsAdapter extends ResourceCursorAdapter {
private int mIconBitmap1Col;
private int mIconBitmap2Col;
+ // This value is stored in SuggestionsAdapter by the SearchDialog to indicate whether
+ // a particular list item should be selected upon the next call to notifyDataSetChanged.
+ // This is used to indicate the index of the "More results..." list item so that when
+ // the data set changes after a click of "More results...", we can correctly tell the
+ // ListView to scroll to the right line item. It gets reset to -1 every time it is consumed.
+ private int mListItemToSelect = -1;
+
public SuggestionsAdapter(Context context, SearchDialog searchDialog, SearchableInfo searchable,
WeakHashMap<String, Drawable> outsideDrawablesCache, boolean globalSearchMode) {
super(context,
@@ -134,6 +146,19 @@ class SuggestionsAdapter extends ResourceCursorAdapter {
public void notifyDataSetChanged() {
super.notifyDataSetChanged();
updateWorking();
+ if (mListItemToSelect != -1) {
+ mSearchDialog.setListSelection(mListItemToSelect);
+ mListItemToSelect = -1;
+ }
+ }
+
+ /**
+ * Specifies the list item to select upon next call of {@link #notifyDataSetChanged()},
+ * in order to let us scroll the "More results..." list item to the top of the screen
+ * (or as close as it can get) when clicked.
+ */
+ public void setListItemToSelect(int index) {
+ mListItemToSelect = index;
}
/**