/** Update the view to reflect the new folder status. */ public boolean updateStatus(final ConversationCursor cursor) { if (cursor == null) { updateLoadingStatus(true); return true; } boolean showFooter = true; final Bundle extras = cursor.getExtras(); final int cursorStatus = extras.getInt(UIProvider.CursorExtraKeys.EXTRA_STATUS); mErrorStatus = extras.containsKey(UIProvider.CursorExtraKeys.EXTRA_ERROR) ? extras.getInt(UIProvider.CursorExtraKeys.EXTRA_ERROR) : UIProvider.LastSyncResult.SUCCESS; final int totalCount = extras.getInt(UIProvider.CursorExtraKeys.EXTRA_TOTAL_COUNT); /// M: Get the value from extra final boolean allMessagesLoadFinish = extras.getBoolean(UIProvider.CursorExtraKeys.EXTRA_MESSAGES_LOAD_FINISH, false); if (UIProvider.CursorStatus.isWaitingForResults(cursorStatus)) { updateLoadingStatus(true); } else if (mErrorStatus != UIProvider.LastSyncResult.SUCCESS) { mNetworkError.setVisibility(View.VISIBLE); mErrorText.setText(Utils.getSyncStatusText(getContext(), mErrorStatus)); mLoading.setVisibility(View.GONE); mLoadMore.setVisibility(View.GONE); // Only show the "Retry" button for I/O errors; it won't help for // internal errors. mErrorActionButton.setVisibility( mErrorStatus != UIProvider.LastSyncResult.SECURITY_ERROR ? View.VISIBLE : View.GONE); final int actionTextResourceId; switch (mErrorStatus) { case UIProvider.LastSyncResult.CONNECTION_ERROR: actionTextResourceId = R.string.retry; break; case UIProvider.LastSyncResult.AUTH_ERROR: actionTextResourceId = R.string.signin; break; case UIProvider.LastSyncResult.SECURITY_ERROR: actionTextResourceId = R.string.retry; mNetworkError.setVisibility(View.GONE); break; // Currently we do nothing for security errors. case UIProvider.LastSyncResult.STORAGE_ERROR: actionTextResourceId = R.string.info; break; case UIProvider.LastSyncResult.INTERNAL_ERROR: actionTextResourceId = R.string.report; break; default: actionTextResourceId = R.string.retry; mNetworkError.setVisibility(View.GONE); break; } mErrorActionButton.setText(actionTextResourceId); } else if (mLoadMoreUri != null && cursor.getCount() < totalCount /** * M: filter some dirty update callback, default when cursor count little than total count. * load more view will show, in fact in the initial step of remote search the loader * complete result is 0 before run search on server, which will cause loading status * stopped. It make user confused, 'It should loading instead of load more' @} */ && cursor.getCount() > 0) { /** @} */ LogUtils.d( LogTag.getLogTag(), " LoadMore finished folder [%s], totalCount %d, cursor count %d", mLoadMoreUri, totalCount, cursor.getCount()); if (allMessagesLoadFinish) { /// M: When all messages load finish, load more do not need to display. showFooter = false; } else { updateLoadingStatus(false); } } else { showFooter = false; } return showFooter; }