From dd5d8561cdf3365a5d4149b5abf6904db7c50b65 Mon Sep 17 00:00:00 2001 From: m0viefreak Date: Fri, 15 Feb 2013 09:41:27 +0100 Subject: [PATCH] message view / list: fix NPE when list is empty This happened for example in a starred-message-only view when un-starting the last message. This led to isFirst() and isLast() causing a NullPointerException when trying to update the previous / next buttons. --- src/com/fsck/k9/fragment/MessageListFragment.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/fsck/k9/fragment/MessageListFragment.java b/src/com/fsck/k9/fragment/MessageListFragment.java index c48ec2a23..a14c11b18 100644 --- a/src/com/fsck/k9/fragment/MessageListFragment.java +++ b/src/com/fsck/k9/fragment/MessageListFragment.java @@ -2873,11 +2873,11 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick } public boolean isFirst(MessageReference messageReference) { - return messageReference.equals(getReferenceForPosition(0)); + return mAdapter.isEmpty() || messageReference.equals(getReferenceForPosition(0)); } public boolean isLast(MessageReference messageReference) { - return messageReference.equals(getReferenceForPosition(mAdapter.getCount() - 1)); + return mAdapter.isEmpty() || messageReference.equals(getReferenceForPosition(mAdapter.getCount() - 1)); } private MessageReference getReferenceForPosition(int position) {