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:
parent
6fc054daa6
commit
4c0e5c0d0a
@ -20,7 +20,6 @@ import android.content.Context;
|
|||||||
import android.content.Loader;
|
import android.content.Loader;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.CursorWrapper;
|
import android.database.CursorWrapper;
|
||||||
import android.database.MatrixCursor;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -289,28 +288,10 @@ import java.util.Set;
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Cursor loadInBackground() {
|
public Cursor loadInBackground() {
|
||||||
final Cursor returnCursor;
|
// Build the where cause (which can't be done on the UI thread.)
|
||||||
|
setSelection(Message.buildMessageListSelection(mContext, mMailboxId));
|
||||||
// Only perform a load if the selected mailbox can hold messages
|
// Then do a query to get the cursor
|
||||||
// box can be null on the combined view where we use negative mailbox ids.
|
return loadExtras(super.loadInBackground());
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Cursor loadExtras(Cursor baseCursor) {
|
private Cursor loadExtras(Cursor baseCursor) {
|
||||||
|
Loading…
Reference in New Issue
Block a user