1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-25 00:58:50 -05:00

Merge pull request #265 from jca02266/master

If there is no message, it should return to a MessageList.
This commit is contained in:
cketti 2013-02-18 20:32:16 -08:00
commit 1a034d3e59
2 changed files with 17 additions and 11 deletions

View File

@ -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() {

View File

@ -2882,22 +2882,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) {