Hide footer when we hit the end of a search

Change-Id: Iec082a9f9560819c034f91706229b1efb7303ba2
This commit is contained in:
Ben Komalo 2011-06-28 17:24:54 -07:00
parent 6b256f1fa1
commit 1f6acaf396
2 changed files with 21 additions and 6 deletions

View File

@ -1039,16 +1039,27 @@ public class MessageListFragment extends ListFragment
}
private void determineFooterMode() {
// TODO: Do something different for searches?
// We could, for example, indicate how many remain to be loaded, etc...
mListFooterMode = LIST_FOOTER_MODE_NONE;
if ((mMailbox == null) || (mMailbox.mType == Mailbox.TYPE_OUTBOX)
if ((mMailbox == null)
|| (mMailbox.mType == Mailbox.TYPE_OUTBOX)
|| (mMailbox.mType == Mailbox.TYPE_DRAFTS)) {
return; // No footer
}
if (!mIsEasAccount || (mMailbox.mType == Mailbox.TYPE_SEARCH)) {
// IMAP, POP has "load more"
if (mMailbox.mType == Mailbox.TYPE_SEARCH) {
// Determine how many results have been loaded.
Cursor c = mListAdapter.getCursor();
if (c == null || c.isClosed()) {
// Unknown yet - don't do anything.
return;
}
int total = ((SearchResultsCursor) c).getResultsCount();
int loaded = c.getCount();
if (loaded < total) {
mListFooterMode = LIST_FOOTER_MODE_MORE;
}
} else if (!mIsEasAccount) {
// IMAP, POP has "load more" for regular mailboxes.
mListFooterMode = LIST_FOOTER_MODE_MORE;
}
}

View File

@ -363,6 +363,10 @@ import java.util.Set;
mResultsCount = resultsCount;
}
/**
* @return the total number of results that match the given search query. Note that
* there may not be that many items loaded in the cursor yet.
*/
public int getResultsCount() {
return mResultsCount;
}