From bb48628db6fd444460df61be7afa7fb633f47f50 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Tue, 12 May 2015 14:17:28 -0700 Subject: Indicate whether CallLogAdapter is for Recents. Bug: 20924950 Change-Id: I6163565ec508d245afd83112927d636a4a50f27e --- src/com/android/dialer/calllog/CallLogAdapter.java | 13 +++++++------ src/com/android/dialer/calllog/CallLogFragment.java | 12 +++++++----- src/com/android/dialerbind/ObjectFactory.java | 7 ++++++- .../src/com/android/dialer/calllog/CallLogAdapterTest.java | 2 +- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index ee83c2e48..6b24c0a4f 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -90,7 +90,7 @@ public class CallLogAdapter extends GroupingListAdapter protected ContactInfoCache mContactInfoCache; - private boolean mShowCallHistoryListItem = false; + private boolean mIsShowingRecentsTab; /** * Tracks the currently expanded call log row. @@ -184,13 +184,14 @@ public class CallLogAdapter extends GroupingListAdapter Context context, CallFetcher callFetcher, ContactInfoHelper contactInfoHelper, + boolean isShowingRecentsTab, OnReportButtonClickListener onReportButtonClickListener) { super(context); mContext = context; mCallFetcher = callFetcher; mContactInfoHelper = contactInfoHelper; - + mIsShowingRecentsTab = isShowingRecentsTab; mOnReportButtonClickListener = onReportButtonClickListener; mContactInfoCache = new ContactInfoCache( @@ -425,19 +426,19 @@ public class CallLogAdapter extends GroupingListAdapter @Override public int getItemCount() { - return super.getItemCount() + (mShowCallHistoryListItem ? 1 : 0); + return super.getItemCount() + (isShowingRecentsTab() ? 1 : 0); } @Override public int getItemViewType(int position) { - if (position == getItemCount() - 1 && mShowCallHistoryListItem) { + if (position == getItemCount() - 1 && isShowingRecentsTab()) { return VIEW_TYPE_SHOW_CALL_HISTORY_LIST_ITEM; } return super.getItemViewType(position); } - public void setShowCallHistoryListItem(boolean show) { - mShowCallHistoryListItem = show; + protected boolean isShowingRecentsTab() { + return mIsShowingRecentsTab; } /** diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java index 02970f66c..4948176c1 100644 --- a/src/com/android/dialer/calllog/CallLogFragment.java +++ b/src/com/android/dialer/calllog/CallLogFragment.java @@ -281,11 +281,13 @@ public class CallLogFragment extends Fragment mRecyclerView.setLayoutManager(mLayoutManager); String currentCountryIso = GeoUtil.getCurrentCountryIso(getActivity()); - mAdapter = ObjectFactory.newCallLogAdapter(getActivity(), this, - new ContactInfoHelper(getActivity(), currentCountryIso), this); - if (mLogLimit != NO_LOG_LIMIT || mDateLimit != NO_DATE_LIMIT) { - mAdapter.setShowCallHistoryListItem(true); - } + boolean isShowingRecentsTab = mLogLimit != NO_LOG_LIMIT || mDateLimit != NO_DATE_LIMIT; + mAdapter = ObjectFactory.newCallLogAdapter( + getActivity(), + this, + new ContactInfoHelper(getActivity(), currentCountryIso), + isShowingRecentsTab, + this); mRecyclerView.setAdapter(mAdapter); mVoicemailStatusHelper = new VoicemailStatusHelperImpl(); diff --git a/src/com/android/dialerbind/ObjectFactory.java b/src/com/android/dialerbind/ObjectFactory.java index dfacd3f6d..be4eeec42 100644 --- a/src/com/android/dialerbind/ObjectFactory.java +++ b/src/com/android/dialerbind/ObjectFactory.java @@ -48,9 +48,14 @@ public class ObjectFactory { Context context, CallFetcher callFetcher, ContactInfoHelper contactInfoHelper, + boolean isShowingRecentsTab, OnReportButtonClickListener onReportButtonClickListener) { return new CallLogAdapter( - context, callFetcher, contactInfoHelper, onReportButtonClickListener); + context, + callFetcher, + contactInfoHelper, + isShowingRecentsTab, + onReportButtonClickListener); } public static DialogFragment getReportDialogFragment(String number) { diff --git a/tests/src/com/android/dialer/calllog/CallLogAdapterTest.java b/tests/src/com/android/dialer/calllog/CallLogAdapterTest.java index 70d63c9ac..5f09cb74b 100644 --- a/tests/src/com/android/dialer/calllog/CallLogAdapterTest.java +++ b/tests/src/com/android/dialer/calllog/CallLogAdapterTest.java @@ -204,7 +204,7 @@ public class CallLogAdapterTest extends AndroidTestCase { private static final class TestCallLogAdapter extends CallLogAdapter { public TestCallLogAdapter(Context context, CallFetcher callFetcher, ContactInfoHelper contactInfoHelper) { - super(context, callFetcher, contactInfoHelper, null); + super(context, callFetcher, contactInfoHelper, false, null); mContactInfoCache = new TestContactInfoCache( contactInfoHelper, mOnContactInfoChangedListener); } -- cgit v1.2.3