Report search result total to UI
Change-Id: Ic88e7594b98548a96c8c6f96d2f8a585e539f520
This commit is contained in:
parent
ebb79619e8
commit
55d0e821ea
@ -40,6 +40,10 @@ public class SearchParams implements Parcelable {
|
|||||||
// If zero, specifies a "new" search; otherwise, asks for a continuation of the previous
|
// If zero, specifies a "new" search; otherwise, asks for a continuation of the previous
|
||||||
// query(ies) starting with the mOffset'th match (0 based)
|
// query(ies) starting with the mOffset'th match (0 based)
|
||||||
public int mOffset = DEFAULT_OFFSET;
|
public int mOffset = DEFAULT_OFFSET;
|
||||||
|
// The total number of results for this search
|
||||||
|
public int mTotalCount = 0;
|
||||||
|
// The id of the "search" mailbox being used
|
||||||
|
public long mSearchMailboxId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Error codes returned by the searchMessages API
|
* Error codes returned by the searchMessages API
|
||||||
@ -54,6 +58,12 @@ public class SearchParams implements Parcelable {
|
|||||||
mFilter = filter;
|
mFilter = filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SearchParams(long mailboxId, String filter, long searchMailboxId) {
|
||||||
|
mMailboxId = mailboxId;
|
||||||
|
mFilter = filter;
|
||||||
|
mSearchMailboxId = searchMailboxId;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (o == this) {
|
if (o == this) {
|
||||||
|
@ -2072,12 +2072,15 @@ outer:
|
|||||||
} else {
|
} else {
|
||||||
sb.append(',');
|
sb.append(',');
|
||||||
}
|
}
|
||||||
String val = map.get(column);
|
String val = null;
|
||||||
// If we don't have the column, be permissive, returning "0 AS <column>", and warn
|
// First look at values; this is an override of default behavior
|
||||||
if (val == null) {
|
if (values.containsKey(column)) {
|
||||||
if (values.containsKey(column)) {
|
val = "'" + values.getAsString(column) + "' AS " + column;
|
||||||
val = "'" + values.getAsString(column) + "' AS " + column;
|
} else {
|
||||||
} else {
|
// Now, get the standard value for the column from our projection map
|
||||||
|
val = map.get(column);
|
||||||
|
// If we don't have the column, return "NULL AS <column>", and warn
|
||||||
|
if (val == null) {
|
||||||
Log.w(TAG, "UIProvider column not found, returning NULL: " + column);
|
Log.w(TAG, "UIProvider column not found, returning NULL: " + column);
|
||||||
val = "NULL AS " + column;
|
val = "NULL AS " + column;
|
||||||
}
|
}
|
||||||
@ -2162,8 +2165,15 @@ outer:
|
|||||||
* @param uiProjection as passed from UnifiedEmail
|
* @param uiProjection as passed from UnifiedEmail
|
||||||
* @return the SQLite query to be executed on the EmailProvider database
|
* @return the SQLite query to be executed on the EmailProvider database
|
||||||
*/
|
*/
|
||||||
private String genQueryMailbox(String[] uiProjection) {
|
private String genQueryMailbox(String[] uiProjection, String id) {
|
||||||
StringBuilder sb = genSelect(sFolderListMap, uiProjection);
|
long mailboxId = Long.parseLong(id);
|
||||||
|
ContentValues values = EMPTY_CONTENT_VALUES;
|
||||||
|
if (mSearchParams != null && mailboxId == mSearchParams.mSearchMailboxId) {
|
||||||
|
// This is the current search mailbox; use the total count
|
||||||
|
values = new ContentValues();
|
||||||
|
values.put(UIProvider.FolderColumns.TOTAL_COUNT, mSearchParams.mTotalCount);
|
||||||
|
}
|
||||||
|
StringBuilder sb = genSelect(sFolderListMap, uiProjection, values);
|
||||||
sb.append(" FROM " + Mailbox.TABLE_NAME + " WHERE " + MailboxColumns.ID + "=?");
|
sb.append(" FROM " + Mailbox.TABLE_NAME + " WHERE " + MailboxColumns.ID + "=?");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
@ -2367,7 +2377,7 @@ outer:
|
|||||||
notifyUri = UIPROVIDER_ATTACHMENT_NOTIFIER.buildUpon().appendPath(id).build();
|
notifyUri = UIPROVIDER_ATTACHMENT_NOTIFIER.buildUpon().appendPath(id).build();
|
||||||
break;
|
break;
|
||||||
case UI_FOLDER:
|
case UI_FOLDER:
|
||||||
c = db.rawQuery(genQueryMailbox(uiProjection), new String[] {id});
|
c = db.rawQuery(genQueryMailbox(uiProjection, id), new String[] {id});
|
||||||
notifyUri = UIPROVIDER_MAILBOX_NOTIFIER.buildUpon().appendPath(id).build();
|
notifyUri = UIPROVIDER_MAILBOX_NOTIFIER.buildUpon().appendPath(id).build();
|
||||||
break;
|
break;
|
||||||
case UI_ACCOUNT:
|
case UI_ACCOUNT:
|
||||||
@ -2800,6 +2810,10 @@ outer:
|
|||||||
Log.d(TAG, "[Notify UI: " + notifyUri + "]");
|
Log.d(TAG, "[Notify UI: " + notifyUri + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void notifyUI(Uri uri, long id) {
|
||||||
|
notifyUI(uri, Long.toString(id));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Support for services and service notifications
|
* Support for services and service notifications
|
||||||
*/
|
*/
|
||||||
@ -2888,12 +2902,13 @@ outer:
|
|||||||
if (filter == null) {
|
if (filter == null) {
|
||||||
throw new IllegalArgumentException("No query parameter in search query");
|
throw new IllegalArgumentException("No query parameter in search query");
|
||||||
}
|
}
|
||||||
mSearchParams = new SearchParams(inbox.mId, filter);
|
|
||||||
|
|
||||||
// Find/create our search mailbox
|
// Find/create our search mailbox
|
||||||
Mailbox searchMailbox = getSearchMailbox(accountId);
|
Mailbox searchMailbox = getSearchMailbox(accountId);
|
||||||
final long searchMailboxId = searchMailbox.mId;
|
final long searchMailboxId = searchMailbox.mId;
|
||||||
|
|
||||||
|
mSearchParams = new SearchParams(inbox.mId, filter, searchMailboxId);
|
||||||
|
|
||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
if (mSearchParams.mOffset == 0) {
|
if (mSearchParams.mOffset == 0) {
|
||||||
// Delete existing contents of search mailbox
|
// Delete existing contents of search mailbox
|
||||||
@ -2916,7 +2931,11 @@ outer:
|
|||||||
mServiceCallback, accountId);
|
mServiceCallback, accountId);
|
||||||
if (service != null) {
|
if (service != null) {
|
||||||
try {
|
try {
|
||||||
service.searchMessages(accountId, mSearchParams, searchMailboxId);
|
// Save away the total count
|
||||||
|
mSearchParams.mTotalCount = service.searchMessages(accountId,
|
||||||
|
mSearchParams, searchMailboxId);
|
||||||
|
Log.d(TAG, "TotalCount to UI: " + mSearchParams.mTotalCount);
|
||||||
|
notifyUI(UIPROVIDER_MAILBOX_NOTIFIER, searchMailboxId);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e("searchMessages", "RemoteException", e);
|
Log.e("searchMessages", "RemoteException", e);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user