diff options
-rw-r--r-- | java/com/android/dialer/searchfragment/remote/RemoteContactsCursor.java | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/java/com/android/dialer/searchfragment/remote/RemoteContactsCursor.java b/java/com/android/dialer/searchfragment/remote/RemoteContactsCursor.java index e6f3c2607..5d80a452c 100644 --- a/java/com/android/dialer/searchfragment/remote/RemoteContactsCursor.java +++ b/java/com/android/dialer/searchfragment/remote/RemoteContactsCursor.java @@ -118,12 +118,19 @@ public final class RemoteContactsCursor extends MergeCursor implements SearchCur int position = getPosition(); // proceed backwards until we reach the header row, which contains the directory ID. while (moveToPrevious()) { - int id = getInt(getColumnIndex(COLUMN_DIRECTORY_ID)); - if (id != -1) { - // return the cursor to it's original position/state - moveToPosition(position); - return id; + int columnIndex = getColumnIndex(COLUMN_DIRECTORY_ID); + if (columnIndex == -1) { + continue; } + + int id = getInt(columnIndex); + if (id == -1) { + continue; + } + + // return the cursor to it's original position/state + moveToPosition(position); + return id; } throw Assert.createIllegalStateFailException("No directory id for contact at: " + position); } |