/** * Remove the unread count and show the account name, if required. * * @param now true if you want the change to happen immediately. False if you want to enforce it * happens later. */ private void removeUnreadCount(boolean now) { if (now) { // Remove all previous messages which might change the subtitle mHandler.removeMessages(SubtitleHandler.EMAIL); // Update the subtitle: clear it or show account name. mHandler.sendEmptyMessage(SubtitleHandler.EMAIL); } else { if (!mHandler.hasMessages(SubtitleHandler.EMAIL)) { // In a short while, show the account name in its place. mHandler.sendEmptyMessageDelayed(SubtitleHandler.EMAIL, ACCOUNT_DELAY_MS); } } }
@Override public void onViewModeChanged(int newMode) { mMode = newMode; mActivity.invalidateOptionsMenu(); mHandler.removeMessages(SubtitleHandler.EMAIL); // Check if we are either on a phone, or in Conversation mode on tablet. For these, the // recent folders is enabled. switch (mMode) { case ViewMode.UNKNOWN: break; case ViewMode.CONVERSATION_LIST: showNavList(); break; case ViewMode.SEARCH_RESULTS_CONVERSATION: mActionBar.setDisplayHomeAsUpEnabled(true); setEmptyMode(); break; case ViewMode.CONVERSATION: case ViewMode.AD: closeSearchField(); mActionBar.setDisplayHomeAsUpEnabled(true); setEmptyMode(); break; case ViewMode.WAITING_FOR_ACCOUNT_INITIALIZATION: // We want the user to be able to switch accounts while waiting for an account // to sync. showNavList(); break; } }
public void onDestroy() { if (mFolderObserver != null) { mFolderObserver.unregisterAndDestroy(); mFolderObserver = null; } mAccountObserver.unregisterAndDestroy(); mHandler.removeMessages(SubtitleHandler.EMAIL); }