1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-23 18:02:15 -05:00

Fix NullPointerException

This commit is contained in:
cketti 2013-02-06 00:39:45 +01:00
parent ac9259a0e3
commit e59d23ca0e
2 changed files with 21 additions and 12 deletions

View File

@ -922,15 +922,17 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
menu.findItem(R.id.next_message).setVisible(false);
menu.findItem(R.id.previous_message).setVisible(false);
} else {
final MessageReference ref = mMessageViewFragment.getMessageReference();
final boolean canDoPrev = mMessageListFragment != null && !mMessageListFragment.isFirst(ref);
final boolean canDoNext = mMessageListFragment != null && !mMessageListFragment.isLast(ref);
MessageReference ref = mMessageViewFragment.getMessageReference();
boolean initialized = (mMessageListFragment != null &&
mMessageListFragment.isLoadFinished());
boolean canDoPrev = (initialized && !mMessageListFragment.isFirst(ref));
boolean canDoNext = (initialized && !mMessageListFragment.isLast(ref));
final MenuItem prev = menu.findItem(R.id.previous_message);
MenuItem prev = menu.findItem(R.id.previous_message);
prev.setEnabled(canDoPrev);
prev.getIcon().setAlpha(canDoPrev ? 255 : 127);
final MenuItem next = menu.findItem(R.id.next_message);
MenuItem next = menu.findItem(R.id.next_message);
next.setEnabled(canDoNext);
next.getIcon().setAlpha(canDoNext ? 255 : 127);
}

View File

@ -2915,6 +2915,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
boolean startSearch(Account account, String folderName);
void remoteSearchStarted();
void goBack();
void updateMenu();
}
public void onReverseSort() {
@ -3230,18 +3231,24 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
resetActionMode();
computeBatchDirection();
if (mSavedListState != null) {
boolean loadFinished = true;
for (int i = 0; i < mCursorValid.length; i++) {
loadFinished &= mCursorValid[i];
}
if (loadFinished) {
if (isLoadFinished()) {
if (mSavedListState != null) {
mHandler.restoreListPosition();
}
mFragmentListener.updateMenu();
}
}
public boolean isLoadFinished() {
boolean loadFinished = true;
for (int i = 0; i < mCursorValid.length; i++) {
loadFinished &= mCursorValid[i];
}
return loadFinished;
}
private void cleanupSelected(Cursor cursor) {
if (mSelected.size() == 0) {
return;