diff options
Diffstat (limited to 'core/java/android/app/SuggestionsAdapter.java')
-rw-r--r-- | core/java/android/app/SuggestionsAdapter.java | 45 |
1 files changed, 17 insertions, 28 deletions
diff --git a/core/java/android/app/SuggestionsAdapter.java b/core/java/android/app/SuggestionsAdapter.java index 593b7b7..4a00e48 100644 --- a/core/java/android/app/SuggestionsAdapter.java +++ b/core/java/android/app/SuggestionsAdapter.java @@ -27,6 +27,7 @@ import android.content.res.Resources; import android.database.Cursor; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; +import android.graphics.drawable.DrawableContainer; import android.graphics.drawable.StateListDrawable; import android.net.Uri; import android.os.Bundle; @@ -135,6 +136,8 @@ class SuggestionsAdapter extends ResourceCursorAdapter { private int mPreviousLength = 0; public long getPostingDelay(CharSequence constraint) { + if (constraint == null) return 0; + long delay = constraint.length() < mPreviousLength ? DELETE_KEY_POST_DELAY : 0; mPreviousLength = constraint.length(); return delay; @@ -191,37 +194,21 @@ class SuggestionsAdapter extends ResourceCursorAdapter { public void changeCursor(Cursor c) { if (DBG) Log.d(LOG_TAG, "changeCursor(" + c + ")"); - if (mCursor != null) { - callCursorPreClose(mCursor); - } - - super.changeCursor(c); - if (c != null) { - mFormatCol = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_FORMAT); - mText1Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_1); - mText2Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_2); - mIconName1Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_ICON_1); - mIconName2Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_ICON_2); - mBackgroundColorCol = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_BACKGROUND_COLOR); + try { + super.changeCursor(c); + if (c != null) { + mFormatCol = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_FORMAT); + mText1Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_1); + mText2Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_2); + mIconName1Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_ICON_1); + mIconName2Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_ICON_2); + mBackgroundColorCol = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_BACKGROUND_COLOR); + } + } catch (Exception e) { + Log.e(LOG_TAG, "error changing cursor and caching columns", e); } } - /** - * Handle sending and receiving information associated with - * {@link DialogCursorProtocol#PRE_CLOSE}. - * - * @param cursor The cursor to call. - */ - private void callCursorPreClose(Cursor cursor) { - if (!mGlobalSearchMode) return; - final Bundle request = new Bundle(); - request.putInt(DialogCursorProtocol.METHOD, DialogCursorProtocol.PRE_CLOSE); - request.putInt(DialogCursorProtocol.PRE_CLOSE_SEND_MAX_DISPLAY_POS, mMaxDisplayed); - final Bundle response = cursor.respond(request); - - mMaxDisplayed = -1; - } - @Override public void notifyDataSetChanged() { if (DBG) Log.d(LOG_TAG, "notifyDataSetChanged"); @@ -267,7 +254,9 @@ class SuggestionsAdapter extends ResourceCursorAdapter { final Bundle request = new Bundle(1); request.putInt(DialogCursorProtocol.METHOD, DialogCursorProtocol.CLICK); request.putInt(DialogCursorProtocol.CLICK_SEND_POSITION, position); + request.putInt(DialogCursorProtocol.CLICK_SEND_MAX_DISPLAY_POS, mMaxDisplayed); final Bundle response = cursor.respond(request); + mMaxDisplayed = -1; mListItemToSelect = response.getInt( DialogCursorProtocol.CLICK_RECEIVE_SELECTED_POS, SuggestionsAdapter.NONE); } |