From 69705be50fc4c84b35df88c879dd9a4b4de655b3 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Mon, 4 May 2015 17:24:01 -0700 Subject: Add "show call history" list item. + Add new VIEW_TYPE to the CallLogAdapter. + Reintroduce boolean on CallLogAdapter to specify if a call history list item should be shown. + Add new ViewHolder and layout for footer. + Some minor styling tweaks and cleanups. Bug: 20108202 Change-Id: Ie4a86bff9e53cfd69ef8b061af048f40f4358579 --- src/com/android/dialer/calllog/CallLogAdapter.java | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/com/android/dialer/calllog/CallLogAdapter.java') diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index f2a84c99f..8e22834e5 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -78,6 +78,8 @@ public class CallLogAdapter extends GroupingListAdapter public void onReportButtonClick(String number); } + private static final int VIEW_TYPE_SHOW_CALL_HISTORY_LIST_ITEM = 10; + /** Constant used to indicate no row is expanded. */ private static final long NONE_EXPANDED = -1; @@ -89,6 +91,8 @@ public class CallLogAdapter extends GroupingListAdapter protected ContactInfoCache mContactInfoCache; + private boolean mShowCallHistoryListItem = false; + /** * Tracks the currently expanded call log row. */ @@ -254,6 +258,9 @@ public class CallLogAdapter extends GroupingListAdapter @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + if (viewType == VIEW_TYPE_SHOW_CALL_HISTORY_LIST_ITEM) { + return ShowCallHistoryViewHolder.create(mContext, parent); + } return createCallLogEntryViewHolder(parent); } @@ -287,6 +294,10 @@ public class CallLogAdapter extends GroupingListAdapter * @param count the number of entries in the current item, greater than 1 if it is a group */ public void onBindViewHolder(ViewHolder viewHolder, int position) { + if (getItemViewType(position) == VIEW_TYPE_SHOW_CALL_HISTORY_LIST_ITEM) { + return; + } + Cursor c = (Cursor) getItem(position); if (c == null) { return; @@ -414,6 +425,23 @@ public class CallLogAdapter extends GroupingListAdapter } } + @Override + public int getItemCount() { + return super.getItemCount() + (mShowCallHistoryListItem ? 1 : 0); + } + + @Override + public int getItemViewType(int position) { + if (position == getItemCount() - 1 && mShowCallHistoryListItem) { + return VIEW_TYPE_SHOW_CALL_HISTORY_LIST_ITEM; + } + return super.getItemViewType(position); + } + + public void setShowCallHistoryListItem(boolean show) { + mShowCallHistoryListItem = show; + } + /** * Retrieves the day group of the previous call in the call log. Used to determine if the day * group has changed and to trigger display of the day group text. -- cgit v1.2.3