am 4b73385e: Merge "Prevent a NPE in ImapService search handling" into jb-ub-mail-ur10

* commit '4b73385ecbdae7857331a2a0b6f71c18ccd94b97':
  Prevent a NPE in ImapService search handling
This commit is contained in:
Yu Ping Hu 2013-10-24 15:59:19 -07:00 committed by Android Git Automerger
commit e232140461
2 changed files with 7 additions and 2 deletions
src/com/android/email

View File

@ -5369,7 +5369,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());
@ -5396,6 +5396,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

View File

@ -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);