Prevent a NPE in ImapService search handling
b/11339972 Change-Id: Ief34e6e1fd59d029847dc8525a34f20ea9de26b1
This commit is contained in:
parent
bf39d1166c
commit
7dad461e9e
|
@ -5337,7 +5337,7 @@ public class EmailProvider extends ContentProvider {
|
|||
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
// TODO: Handle searching for more...
|
||||
// This handles an initial search query. More results are loaded using uiFolderLoadMore.
|
||||
private Cursor uiSearch(Uri uri, String[] projection) {
|
||||
LogUtils.d(TAG, "runSearchQuery in search %s", uri);
|
||||
final long accountId = Long.parseLong(uri.getLastPathSegment());
|
||||
|
@ -5364,6 +5364,8 @@ public class EmailProvider extends ContentProvider {
|
|||
|
||||
final Context context = getContext();
|
||||
if (mSearchParams.mOffset == 0) {
|
||||
// TODO: This conditional is unnecessary, just two lines earlier we created
|
||||
// mSearchParams using a constructor that never sets mOffset.
|
||||
LogUtils.d(TAG, "deleting existing search results.");
|
||||
|
||||
// Delete existing contents of search mailbox
|
||||
|
|
|
@ -1443,10 +1443,13 @@ public class ImapService extends Service {
|
|||
sSearchResults.put(accountId, sortableMessages);
|
||||
}
|
||||
} else {
|
||||
// It seems odd for this to happen, but if the previous query returned zero results,
|
||||
// but the UI somehow still attempted to load more, then sSearchResults will have
|
||||
// a null value for this account. We need to handle this below.
|
||||
sortableMessages = sSearchResults.get(accountId);
|
||||
}
|
||||
|
||||
final int numSearchResults = sortableMessages.length;
|
||||
final int numSearchResults = (sortableMessages != null ? sortableMessages.length : 0);
|
||||
final int numToLoad =
|
||||
Math.min(numSearchResults - searchParams.mOffset, searchParams.mLimit);
|
||||
destMailbox.updateMessageCount(context, numSearchResults);
|
||||
|
|
Loading…
Reference in New Issue