mirror of
https://github.com/moparisthebest/k-9
synced 2025-02-07 10:40:11 -05:00
Make next/prev buttons track their state again.
This commit is contained in:
parent
5c779f05ab
commit
499e20ef76
@ -921,6 +921,18 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
if (mDisplayMode != DisplayMode.MESSAGE_VIEW) {
|
||||
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);
|
||||
|
||||
final 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);
|
||||
next.setEnabled(canDoNext);
|
||||
next.getIcon().setAlpha(canDoNext ? 255 : 127);
|
||||
}
|
||||
// Set title of menu item to switch to dark/light theme
|
||||
MenuItem toggleTheme = menu.findItem(R.id.toggle_message_view_theme);
|
||||
@ -1063,6 +1075,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
showMessageView();
|
||||
}
|
||||
}
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2838,6 +2838,24 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
openMessageAtPosition(position + 1);
|
||||
}
|
||||
|
||||
public boolean isFirst(MessageReference messageReference) {
|
||||
return messageReference.equals(getReferenceForPosition(0));
|
||||
}
|
||||
|
||||
public boolean isLast(MessageReference messageReference) {
|
||||
return messageReference.equals(getReferenceForPosition(mAdapter.getCount() - 1));
|
||||
}
|
||||
|
||||
private MessageReference getReferenceForPosition(int position) {
|
||||
Cursor cursor = (Cursor) mAdapter.getItem(position);
|
||||
MessageReference ref = new MessageReference();
|
||||
ref.accountUuid = cursor.getString(ACCOUNT_UUID_COLUMN);
|
||||
ref.folderName = cursor.getString(FOLDER_NAME_COLUMN);
|
||||
ref.uid = cursor.getString(UID_COLUMN);
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
||||
private void openMessageAtPosition(int position) {
|
||||
// Scroll message into view if necessary
|
||||
int listViewPosition = adapterToListViewPosition(position);
|
||||
@ -2847,11 +2865,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
mListView.setSelection(listViewPosition);
|
||||
}
|
||||
|
||||
Cursor cursor = (Cursor) mAdapter.getItem(position);
|
||||
MessageReference ref = new MessageReference();
|
||||
ref.accountUuid = cursor.getString(ACCOUNT_UUID_COLUMN);
|
||||
ref.folderName = cursor.getString(FOLDER_NAME_COLUMN);
|
||||
ref.uid = cursor.getString(UID_COLUMN);
|
||||
MessageReference ref = getReferenceForPosition(position);
|
||||
|
||||
// For some reason the mListView.setSelection() above won't do anything when we call
|
||||
// onOpenMessage() (and consequently mAdapter.notifyDataSetChanged()) right away. So we
|
||||
|
Loading…
Reference in New Issue
Block a user