From ff6adf9a746a6199729a9e227396929667496306 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Tue, 7 Apr 2015 14:40:36 -0700 Subject: Separate empty view logic from ListView. Don't rely on setting the empty list on the ListView for controlling visibility of the list view and empty view. Save the reference and control this in the call log fragment. This removes a dependency on ListView-specific functionality which is not found in the RecyclerView. Bug: 19372817 Change-Id: I0a7e2e2366e258013ddbe30bd2ee7efb38349421 --- src/com/android/dialer/calllog/CallLogFragment.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java index cc2ce9cc9..2410b6079 100644 --- a/src/com/android/dialer/calllog/CallLogFragment.java +++ b/src/com/android/dialer/calllog/CallLogFragment.java @@ -87,6 +87,7 @@ public class CallLogFragment extends ListFragment private VoicemailStatusHelper mVoicemailStatusHelper; private View mStatusMessageView; + private View mEmptyListView; private TextView mStatusMessageText; private TextView mStatusMessageAction; private KeyguardManager mKeyguardManager; @@ -220,8 +221,13 @@ public class CallLogFragment extends ListFragment mAdapter.changeCursor(cursor); // This will update the state of the "Clear call log" menu item. getActivity().invalidateOptionsMenu(); + + final ListView listView = getListView(); + boolean showListView = cursor.getCount() > 0; + listView.setVisibility(showListView ? View.VISIBLE : View.GONE); + mEmptyListView.setVisibility(!showListView ? View.VISIBLE : View.GONE); + if (mScrollToTop) { - final ListView listView = getListView(); // The smooth-scroll animation happens over a fixed time period. // As a result, if it scrolls through a large portion of the list, // each frame will jump so far from the previous one that the user @@ -294,7 +300,7 @@ public class CallLogFragment extends ListFragment @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); - getListView().setEmptyView(view.findViewById(R.id.empty_list_view)); + mEmptyListView = view.findViewById(R.id.empty_list_view); getListView().setItemsCanFocus(true); maybeAddFooterView(); @@ -414,7 +420,7 @@ public class CallLogFragment extends ListFragment + filterType); } DialerUtils.configureEmptyListView( - getListView().getEmptyView(), R.drawable.empty_call_log, messageId, getResources()); + mEmptyListView, R.drawable.empty_call_log, messageId, getResources()); } CallLogAdapter getAdapter() { -- cgit v1.2.3