diff options
author | Eric Erfanian <erfanian@google.com> | 2017-06-05 13:35:02 -0700 |
---|---|---|
committer | Eric Erfanian <erfanian@google.com> | 2017-06-07 20:44:54 +0000 |
commit | 91ce7d2a476bd04fe525049a37a2f8b2824e9724 (patch) | |
tree | b9bbc285430ffb5363a70eb27e382c38f5a85b7a /java/com/android/dialer/contactsfragment/ContactsAdapter.java | |
parent | 75233ff03785f24789b32039ac2c208805b7e506 (diff) |
Update AOSP Dialer source from internal google3 repository at
cl/158012278.
Test: make, treehugger
This CL updates the AOSP Dialer source with all the changes that have
gone into the private google3 repository. This includes all the
changes from cl/152373142 (4/06/2017) to cl/158012278 (6/05/2017).
This goal of these drops is to keep the AOSP source in sync with the
internal google3 repository. Currently these sync are done by hand
with very minor modifications to the internal source code.
See the Android.mk file for list of modifications.
Our current goal is to do frequent drops (daily if possible) and
eventually switched to an automated process.
Change-Id: I4d3f14b5140e2e51bead9497bc118a205b3ebe76
Diffstat (limited to 'java/com/android/dialer/contactsfragment/ContactsAdapter.java')
-rw-r--r-- | java/com/android/dialer/contactsfragment/ContactsAdapter.java | 49 |
1 files changed, 17 insertions, 32 deletions
diff --git a/java/com/android/dialer/contactsfragment/ContactsAdapter.java b/java/com/android/dialer/contactsfragment/ContactsAdapter.java index 4692eff5d..309e034cc 100644 --- a/java/com/android/dialer/contactsfragment/ContactsAdapter.java +++ b/java/com/android/dialer/contactsfragment/ContactsAdapter.java @@ -23,10 +23,10 @@ import android.provider.ContactsContract.Contacts; import android.support.v4.util.ArrayMap; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; +import android.view.View; import android.view.ViewGroup; -import android.widget.TextView; import com.android.contacts.common.ContactPhotoManager; -import com.android.dialer.common.Assert; +import com.android.contacts.common.lettertiles.LetterTileDrawable; /** List adapter for the union of all contacts associated with every account on the device. */ final class ContactsAdapter extends RecyclerView.Adapter<ContactViewHolder> { @@ -70,7 +70,7 @@ final class ContactsAdapter extends RecyclerView.Adapter<ContactViewHolder> { getPhotoId(cursor), getPhotoUri(cursor), name, - 0); + LetterTileDrawable.TYPE_DEFAULT); String photoDescription = context.getString(com.android.contacts.common.R.string.description_quick_contact_for, name); @@ -79,17 +79,23 @@ final class ContactsAdapter extends RecyclerView.Adapter<ContactViewHolder> { // Always show the view holder's header if it's the first item in the list. Otherwise, compare // it to the previous element and only show the anchored header if the row elements fall into // the same sublists. - if (position == 0) { - contactViewHolder.bind(header, name, contactUri, true); - } else { - boolean showHeader = !header.equals(getHeaderString(position - 1)); - contactViewHolder.bind(header, name, contactUri, showHeader); - } + boolean showHeader = position == 0 || !header.equals(getHeaderString(position - 1)); + contactViewHolder.bind(header, name, contactUri, showHeader); + } + + @Override + public void onViewRecycled(ContactViewHolder contactViewHolder) { + super.onViewRecycled(contactViewHolder); + holderMap.remove(contactViewHolder); } public void refreshHeaders() { for (ContactViewHolder holder : holderMap.keySet()) { - onBindViewHolder(holder, holderMap.get(holder)); + int position = holderMap.get(holder); + boolean showHeader = + position == 0 || !getHeaderString(position).equals(getHeaderString(position - 1)); + int visibility = showHeader ? View.VISIBLE : View.INVISIBLE; + holder.getHeaderView().setVisibility(visibility); } } @@ -98,27 +104,6 @@ final class ContactsAdapter extends RecyclerView.Adapter<ContactViewHolder> { return cursor == null ? 0 : cursor.getCount(); } - public String getHeader(int position) { - return getHolderAt(position).getHeader(); - } - - public TextView getHeaderView(int position) { - return getHolderAt(position).getHeaderView(); - } - - public void setHeaderVisibility(int position, int visibility) { - getHolderAt(position).getHeaderView().setVisibility(visibility); - } - - private ContactViewHolder getHolderAt(int position) { - for (ContactViewHolder holder : holderMap.keySet()) { - if (holderMap.get(holder) == position) { - return holder; - } - } - throw Assert.createIllegalStateFailException("No holder for position: " + position); - } - private static String getDisplayName(Cursor cursor) { return cursor.getString(ContactsCursorLoader.CONTACT_DISPLAY_NAME); } @@ -138,7 +123,7 @@ final class ContactsAdapter extends RecyclerView.Adapter<ContactViewHolder> { return Contacts.getLookupUri(contactId, lookupKey); } - private String getHeaderString(int position) { + public String getHeaderString(int position) { int index = -1; int sum = 0; while (sum <= position) { |