Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 92f461ea authored by Karl Rosaen's avatar Karl Rosaen
Browse files

add some more defensiveness to SuggestionsAdapter to avoid system process crashes.

parent 0b1a255f
Loading
Loading
Loading
Loading
+14 −8
Original line number Diff line number Diff line
@@ -136,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;
@@ -196,6 +198,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter {
            callCursorPreClose(mCursor);
        }

        try {
            super.changeCursor(c);
            if (c != null) {
                mFormatCol = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_FORMAT);
@@ -205,6 +208,9 @@ class SuggestionsAdapter extends ResourceCursorAdapter {
                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);
        }
    }

    /**