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

Commit de6e2ca7 authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Ensure that the column is valid before querying.

Bug: 3303147
Change-Id: Ieec93317c5a2e924d3ee3108b61577b636943160
parent 4061c9aa
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
@@ -78,15 +78,15 @@ class SuggestionsAdapter extends ResourceCursorAdapter implements OnClickListene
    // URL color
    private ColorStateList mUrlColor;

    // Cached column indexes, updated when the cursor changes.
    private int mText1Col;
    private int mText2Col;
    private int mText2UrlCol;
    private int mIconName1Col;
    private int mIconName2Col;
    private int mFlagsCol;
    static final int INVALID_INDEX = -1;

    static final int NONE = -1;
    // Cached column indexes, updated when the cursor changes.
    private int mText1Col = INVALID_INDEX;
    private int mText2Col = INVALID_INDEX;
    private int mText2UrlCol = INVALID_INDEX;
    private int mIconName1Col = INVALID_INDEX;
    private int mIconName2Col = INVALID_INDEX;
    private int mFlagsCol = INVALID_INDEX;

    private final Runnable mStartSpinnerRunnable;
    private final Runnable mStopSpinnerRunnable;
@@ -308,7 +308,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter implements OnClickListene
        ChildViewCache views = (ChildViewCache) view.getTag();

        int flags = 0;
        if (mFlagsCol != -1) {
        if (mFlagsCol != INVALID_INDEX) {
            flags = cursor.getInt(mFlagsCol);
        }
        if (views.mText1 != null) {
@@ -391,7 +391,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter implements OnClickListene
    }

    private Drawable getIcon1(Cursor cursor) {
        if (mIconName1Col < 0) {
        if (mIconName1Col == INVALID_INDEX) {
            return null;
        }
        String value = cursor.getString(mIconName1Col);
@@ -403,7 +403,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter implements OnClickListene
    }

    private Drawable getIcon2(Cursor cursor) {
        if (mIconName2Col < 0) {
        if (mIconName2Col == INVALID_INDEX) {
            return null;
        }
        String value = cursor.getString(mIconName2Col);
@@ -687,7 +687,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter implements OnClickListene
    }

    private static String getStringOrNull(Cursor cursor, int col) {
        if (col == NONE) {
        if (col == INVALID_INDEX) {
            return null;
        }
        try {