Message list: Hide CAB when in back stack.

Because isViewCreated() is used by updateSelectionMode() which is called from
onDestroyView(), we can't use getView() to determine if the CAB should be
shown.

Change-Id: I8d868998031115800766000fb0128f1d1d3541cd
This commit is contained in:
Makoto Onuki 2011-06-07 17:55:06 -07:00
parent 96e44859cf
commit ab2dba417a
1 changed files with 8 additions and 1 deletions

View File

@ -105,6 +105,7 @@ public class MessageListFragment extends ListFragment
// UI Support
private Activity mActivity;
private Callback mCallback = EmptyCallback.INSTANCE;
private boolean mIsViewCreated;
private View mListFooterView;
private TextView mListFooterText;
@ -356,6 +357,7 @@ public class MessageListFragment extends ListFragment
View root = inflater.inflate(R.layout.message_list_fragment,null);
mListPanel = root.findViewById(R.id.list_panel);
mNoMessagesPanel = root.findViewById(R.id.no_messages_panel);
mIsViewCreated = true;
return root;
}
@ -364,7 +366,11 @@ public class MessageListFragment extends ListFragment
* {@link #onCreateView} and {@link #onDestroyView}.
*/
private boolean isViewCreated() {
return getView() != null;
// Note that we don't use "getView() != null". This method is used in updateSelectionMode()
// to determine if CAB shold be shown. But because it's called from onDestroyView(), at
// this point the fragment still has views but we want to hide CAB, we can't use
// getView() here.
return mIsViewCreated;
}
@Override
@ -441,6 +447,7 @@ public class MessageListFragment extends ListFragment
if (Logging.DEBUG_LIFECYCLE && Email.DEBUG) {
Log.d(Logging.LOG_TAG, this + " onDestroyView");
}
mIsViewCreated = false; // Clear this first for updateSelectionMode(). See isViewCreated().
UiUtilities.uninstallFragment(this);
updateSelectionMode();
super.onDestroyView();