Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ff6adf9a authored by Andrew Lee's avatar Andrew Lee
Browse files

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
parent d32de0ab
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -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();
        if (mScrollToTop) {

        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) {
            // 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() {