diff options
author | calderwoodra <calderwoodra@google.com> | 2017-12-08 20:52:56 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2017-12-08 20:53:51 -0800 |
commit | 73b51d5771b31c932a589abc9bb0fe64c52fe102 (patch) | |
tree | 3845e7aad9e502bf5a91eb8705c8005f06990105 /java/com/android/dialer/contactsfragment/ContactsAdapter.java | |
parent | 20ebcdca46e6be68050cd44087f0f768f5dae5c6 (diff) |
Implemented adding a new favorites contact flow NUI.
This change consists of mainly 3 things:
- Update contacts fragment to meet AddFavoriteActivity requirements
- Implement AddFavoriteActivity
- Passing the contact back to SpeedDialFragment
Bug: 36841782
Test: SpeedDialIntegrationTest
PiperOrigin-RevId: 178461265
Change-Id: Ib3a13eae311acf6ce10a94df4f2c95b9af120cff
Diffstat (limited to 'java/com/android/dialer/contactsfragment/ContactsAdapter.java')
-rw-r--r-- | java/com/android/dialer/contactsfragment/ContactsAdapter.java | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/java/com/android/dialer/contactsfragment/ContactsAdapter.java b/java/com/android/dialer/contactsfragment/ContactsAdapter.java index 8f2120cd7..44abe29da 100644 --- a/java/com/android/dialer/contactsfragment/ContactsAdapter.java +++ b/java/com/android/dialer/contactsfragment/ContactsAdapter.java @@ -29,8 +29,8 @@ import android.view.ViewGroup; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.contactphoto.ContactPhotoManager; -import com.android.dialer.contactsfragment.ContactsFragment.ClickAction; import com.android.dialer.contactsfragment.ContactsFragment.Header; +import com.android.dialer.contactsfragment.ContactsFragment.OnContactSelectedListener; import com.android.dialer.lettertile.LetterTileDrawable; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -50,7 +50,7 @@ final class ContactsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder private final ArrayMap<ContactViewHolder, Integer> holderMap = new ArrayMap<>(); private final Context context; private final @Header int header; - private final @ClickAction int clickAction; + private final OnContactSelectedListener onContactSelectedListener; // List of contact sublist headers private String[] headers = new String[0]; @@ -59,10 +59,11 @@ final class ContactsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder // Cursor with list of contacts private Cursor cursor; - ContactsAdapter(Context context, @Header int header, @ClickAction int clickAction) { + ContactsAdapter( + Context context, @Header int header, OnContactSelectedListener onContactSelectedListener) { this.context = context; this.header = header; - this.clickAction = clickAction; + this.onContactSelectedListener = Assert.isNotNull(onContactSelectedListener); } void updateCursor(Cursor cursor) { @@ -92,7 +93,8 @@ final class ContactsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder LayoutInflater.from(context).inflate(R.layout.add_contact_row, parent, false)); case CONTACT_VIEW_TYPE: return new ContactViewHolder( - LayoutInflater.from(context).inflate(R.layout.contact_row, parent, false), clickAction); + LayoutInflater.from(context).inflate(R.layout.contact_row, parent, false), + onContactSelectedListener); case UNKNOWN_VIEW_TYPE: default: throw Assert.createIllegalStateFailException("Invalid view type: " + viewType); @@ -133,7 +135,7 @@ final class ContactsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder // it to the previous element and only show the anchored header if the row elements fall into // the same sublists. boolean showHeader = position == 0 || !header.equals(getHeaderString(position - 1)); - contactViewHolder.bind(header, name, contactUri, showHeader); + contactViewHolder.bind(header, name, contactUri, getContactId(cursor), showHeader); } /** @@ -190,11 +192,15 @@ final class ContactsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder } private static Uri getContactUri(Cursor cursor) { - long contactId = cursor.getLong(ContactsCursorLoader.CONTACT_ID); + long contactId = getContactId(cursor); String lookupKey = cursor.getString(ContactsCursorLoader.CONTACT_LOOKUP_KEY); return Contacts.getLookupUri(contactId, lookupKey); } + private static long getContactId(Cursor cursor) { + return cursor.getLong(ContactsCursorLoader.CONTACT_ID); + } + String getHeaderString(int position) { if (header != Header.NONE) { if (position == 0) { |