From 075817ff689b7dd12b137bd625f5807df1a29d5a Mon Sep 17 00:00:00 2001 From: Ben Komalo Date: Wed, 21 Sep 2011 15:03:41 -0700 Subject: [PATCH] Try to avoid cases when we flicker "No messages" Bug: 5205196 Change-Id: Ide4b9ebc02c294ee3c031cc0b69ecba32877e2eb --- .../email/activity/MessageListFragment.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/com/android/email/activity/MessageListFragment.java b/src/com/android/email/activity/MessageListFragment.java index 39e3c1200..dab6c956e 100644 --- a/src/com/android/email/activity/MessageListFragment.java +++ b/src/com/android/email/activity/MessageListFragment.java @@ -1231,7 +1231,6 @@ public class MessageListFragment extends ListFragment message.setText(R.string.search_slow_warning_message); root.addView(mWarningContainer); } - } /** @@ -1326,6 +1325,14 @@ public class MessageListFragment extends ListFragment if (mIsFirstLoad) { UiUtilities.setVisibilitySafe(mWarningContainer, View.GONE); mListPanel.setVisibility(View.VISIBLE); + + // Setting the adapter will automatically transition from "Loading" to showing + // the list, which could show "No messages". Avoid showing that on the first sync, + // if we know we're still potentially loading more. + if (!isEmptyAndLoading(cursor)) { + setListAdapter(mListAdapter); + } + } else if ((getListAdapter() == null) && !isEmptyAndLoading(cursor)) { setListAdapter(mListAdapter); } @@ -1339,6 +1346,16 @@ public class MessageListFragment extends ListFragment mIsFirstLoad = false; } + /** + * Determines whether or not the list is empty, but we're still potentially loading data. + * This represents an ambiguous state where we may not want to show "No messages", since + * it may still just be loading. + */ + private boolean isEmptyAndLoading(Cursor cursor) { + return (cursor.getCount() == 0) + && mRefreshManager.isMessageListRefreshing(mMailbox.mId); + } + @Override public void onLoaderReset(Loader loader) { if (Logging.DEBUG_LIFECYCLE && Email.DEBUG) {