/**
  * Initializes an {@link AccountObserver} object that receives a call to {@link
  * #onChanged(Account)} when the controller changes the account.
  *
  * @param controller
  */
 public Account initialize(AccountController controller) {
   if (controller == null) {
     LogUtils.wtf(LOG_TAG, "AccountObserver initialized with null controller!");
   }
   mController = controller;
   mController.registerAccountObserver(this);
   return mController.getAccount();
 }
 /**
  * Initializes an {@link RecentFolderObserver} object that receives a call to {@link #onChanged()}
  * when the controller changes the recent folder.
  *
  * @param controller
  */
 public RecentFolderList initialize(RecentFolderController controller) {
   if (controller == null) {
     LogUtils.wtf(LOG_TAG, "RecentFolderObserver initialized with null controller!");
   }
   mController = controller;
   mController.registerRecentFolderObserver(this);
   return mController.getRecentFolders();
 }
 @Override
 public void handleMessage(Message message) {
   assert (message.what == EMAIL);
   final String subtitleText;
   if (mAccount != null) {
     // Display the account name (email address).
     subtitleText = mAccount.name;
   } else {
     subtitleText = null;
     LogUtils.wtf(LOG_TAG, "MABV.handleMessage() has a null account!");
   }
   setSubtitle(subtitleText);
   super.handleMessage(message);
 }
 public int getOptionsMenuId() {
   switch (mMode) {
     case ViewMode.UNKNOWN:
       return R.menu.conversation_list_menu;
     case ViewMode.CONVERSATION:
       return R.menu.conversation_actions;
     case ViewMode.CONVERSATION_LIST:
       return R.menu.conversation_list_menu;
     case ViewMode.SEARCH_RESULTS_LIST:
       return R.menu.conversation_list_search_results_actions;
     case ViewMode.SEARCH_RESULTS_CONVERSATION:
       return R.menu.conversation_actions;
     case ViewMode.WAITING_FOR_ACCOUNT_INITIALIZATION:
       return R.menu.wait_mode_actions;
   }
   LogUtils.wtf(LOG_TAG, "Menu requested for unknown view mode");
   return R.menu.conversation_list_menu;
 }
 @Override
 public void onActivityCreated(Bundle savedInstanceState) {
   super.onActivityCreated(savedInstanceState);
   final Activity activity = getActivity();
   if (!(activity instanceof ControllableActivity)) {
     LogUtils.wtf(
         LOG_TAG,
         "ConversationViewFragment expects only a ControllableActivity to"
             + "create it. Cannot proceed.");
   }
   if (activity == null || activity.isFinishing()) {
     // Activity is finishing, just bail.
     return;
   }
   mActivity = (ControllableActivity) activity;
   mContext = activity.getApplicationContext();
   mWebViewClient.setActivity(activity);
   mAccount = mAccountObserver.initialize(mActivity.getAccountController());
   mWebViewClient.setAccount(mAccount);
 }