mirror of
https://github.com/moparisthebest/k-9
synced 2025-01-12 22:28:10 -05:00
Avoid IndexOutOfRangeException.
If there is no next message, it should return to a MessageList.
This commit is contained in:
parent
9287d97626
commit
7da4c7cc1b
@ -1356,14 +1356,12 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showNextMessageOrReturn() {
|
public void showNextMessageOrReturn() {
|
||||||
if (K9.messageViewReturnToList()) {
|
if (K9.messageViewReturnToList() || !showNextMessage()) {
|
||||||
if (mDisplayMode == DisplayMode.SPLIT_VIEW) {
|
if (mDisplayMode == DisplayMode.SPLIT_VIEW) {
|
||||||
showMessageViewPlaceHolder();
|
showMessageViewPlaceHolder();
|
||||||
} else {
|
} else {
|
||||||
showMessageList();
|
showMessageList();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
showNextMessage();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1377,18 +1375,24 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
|||||||
mActionBarSubject.setMessageHeader(header);
|
mActionBarSubject.setMessageHeader(header);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showNextMessage() {
|
private boolean showNextMessage() {
|
||||||
MessageReference ref = mMessageViewFragment.getMessageReference();
|
MessageReference ref = mMessageViewFragment.getMessageReference();
|
||||||
if (ref != null) {
|
if (ref != null) {
|
||||||
mMessageListFragment.openNext(ref);
|
if (mMessageListFragment.openNext(ref)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showPreviousMessage() {
|
private boolean showPreviousMessage() {
|
||||||
MessageReference ref = mMessageViewFragment.getMessageReference();
|
MessageReference ref = mMessageViewFragment.getMessageReference();
|
||||||
if (ref != null) {
|
if (ref != null) {
|
||||||
mMessageListFragment.openPrevious(ref);
|
if (mMessageListFragment.openPrevious(ref)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showMessageList() {
|
private void showMessageList() {
|
||||||
|
@ -2854,22 +2854,24 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openPrevious(MessageReference messageReference) {
|
public boolean openPrevious(MessageReference messageReference) {
|
||||||
int position = getPosition(messageReference);
|
int position = getPosition(messageReference);
|
||||||
if (position <= 0) {
|
if (position <= 0) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
openMessageAtPosition(position - 1);
|
openMessageAtPosition(position - 1);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openNext(MessageReference messageReference) {
|
public boolean openNext(MessageReference messageReference) {
|
||||||
int position = getPosition(messageReference);
|
int position = getPosition(messageReference);
|
||||||
if (position < 0 || position == mAdapter.getCount() - 1) {
|
if (position < 0 || position == mAdapter.getCount() - 1) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
openMessageAtPosition(position + 1);
|
openMessageAtPosition(position + 1);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFirst(MessageReference messageReference) {
|
public boolean isFirst(MessageReference messageReference) {
|
||||||
|
Loading…
Reference in New Issue
Block a user