mirror of
https://github.com/moparisthebest/k-9
synced 2025-01-11 13:49:15 -05:00
Don't use MessageViewFragment before it's initialized
The previous code worked fine on Android 4.2. But the lifecycle on older Android versions (tested with 2.2) seems to be slightly different. This should fix the problem.
This commit is contained in:
parent
b02e338b49
commit
1f5ca9eeaa
@ -889,7 +889,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
* Set visibility of menu items related to the message view
|
||||
*/
|
||||
|
||||
if (mMessageViewFragment == null) {
|
||||
if (mMessageViewFragment == null || !mMessageViewFragment.isInitialized()) {
|
||||
menu.findItem(R.id.delete).setVisible(false);
|
||||
menu.findItem(R.id.single_message_options).setVisible(false);
|
||||
menu.findItem(R.id.archive).setVisible(false);
|
||||
|
@ -91,6 +91,13 @@ public class MessageViewFragment extends SherlockFragment implements OnClickList
|
||||
|
||||
private MessageViewFragmentListener mFragmentListener;
|
||||
|
||||
/**
|
||||
* {@code true} after {@link #onCreate(Bundle)} has been executed. This is used by
|
||||
* {@code MessageList.configureMenu()} to make sure the fragment has been initialized before
|
||||
* it is used.
|
||||
*/
|
||||
private boolean mInitialized = false;
|
||||
|
||||
|
||||
class MessageViewHandler extends Handler {
|
||||
|
||||
@ -153,6 +160,7 @@ public class MessageViewFragment extends SherlockFragment implements OnClickList
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
mController = MessagingController.getInstance(getActivity().getApplication());
|
||||
mInitialized = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -808,4 +816,8 @@ public class MessageViewFragment extends SherlockFragment implements OnClickList
|
||||
public void messageHeaderViewAvailable(MessageHeader messageHeaderView);
|
||||
public void updateMenu();
|
||||
}
|
||||
|
||||
public boolean isInitialized() {
|
||||
return mInitialized ;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user