Remove unneeded (and harmful) test in MessagesAdapter

* This fixes the case in which messages are being loaded upon
  initial sync, but do NOT appear in the message list (at least
  until leaving and re-entering the app/mailbox)
* The problem was that MessagesAdapter was checking the state
  of the HOLDS_MAIL flag, which might not have been set at the
  time the Inbox was created; it turns out that the check is
  not necessary, so we remove it here

Bug: 5008696
Change-Id: I009ddf7d82d938758b99c855dfd0271596c5248a
This commit is contained in:
Marc Blank 2011-07-12 16:49:48 -07:00
parent 6fc054daa6
commit 4c0e5c0d0a

View File

@ -20,7 +20,6 @@ import android.content.Context;
import android.content.Loader;
import android.database.Cursor;
import android.database.CursorWrapper;
import android.database.MatrixCursor;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
@ -289,28 +288,10 @@ import java.util.Set;
@Override
public Cursor loadInBackground() {
final Cursor returnCursor;
// Only perform a load if the selected mailbox can hold messages
// box can be null on the combined view where we use negative mailbox ids.
final boolean canHaveMessages;
if (mMailboxId < 0) {
// Combined mailboxes can always have messages.
canHaveMessages = true;
} else {
Mailbox box = Mailbox.restoreMailboxWithId(mContext, mMailboxId);
canHaveMessages = (box != null) && (box.mFlags & Mailbox.FLAG_HOLDS_MAIL) != 0;
}
if (canHaveMessages) {
// Build the where cause (which can't be done on the UI thread.)
setSelection(Message.buildMessageListSelection(mContext, mMailboxId));
// Then do a query to get the cursor
returnCursor = super.loadInBackground();
} else {
// return an empty cursor
returnCursor = new MatrixCursor(getProjection());
}
return loadExtras(returnCursor);
// Build the where cause (which can't be done on the UI thread.)
setSelection(Message.buildMessageListSelection(mContext, mMailboxId));
// Then do a query to get the cursor
return loadExtras(super.loadInBackground());
}
private Cursor loadExtras(Cursor baseCursor) {