1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-06 01:25:36 -05:00

Avoid CursorIndexOutOfBoundsException when deleting a message

Deleting a message creates an entry in EmailProviderCache so
EmailProviderCacheCursor can skip the Cursor row during the time
it takes to update the database.
Previously EmailProviderCacheCursor.isLast() returned the wrong
result when the last row in the wrapped Cursor was hidden. This
lead to the crash in MergeCursor.

Fixes issue 5820
This commit is contained in:
cketti 2013-08-23 04:13:20 +02:00
parent b5f31af402
commit aab998d17f

View File

@ -19,6 +19,12 @@ public class EmailProviderCacheCursor extends CursorWrapper {
private int mMessageIdColumn; private int mMessageIdColumn;
private int mFolderIdColumn; private int mFolderIdColumn;
private int mThreadRootColumn; private int mThreadRootColumn;
/**
* The cursor's current position.
*
* Note: This is only used when {@link #mHiddenRows} isn't empty.
*/
private int mPosition; private int mPosition;
@ -126,4 +132,13 @@ public class EmailProviderCacheCursor extends CursorWrapper {
return mPosition; return mPosition;
} }
@Override
public boolean isLast() {
if (mHiddenRows.isEmpty()) {
return super.isLast();
}
return (mPosition == getCount() - 1);
}
} }