diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-12-09 06:26:25 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-12-09 06:26:25 +0000 |
commit | aab6dc9f075fd8576ffc78c1f983b8fb1d3e77fa (patch) | |
tree | 3845e7aad9e502bf5a91eb8705c8005f06990105 /java/com/android/dialer/contactsfragment/ContactViewHolder.java | |
parent | 20ebcdca46e6be68050cd44087f0f768f5dae5c6 (diff) | |
parent | 73b51d5771b31c932a589abc9bb0fe64c52fe102 (diff) |
Merge "Implemented adding a new favorites contact flow NUI."
Diffstat (limited to 'java/com/android/dialer/contactsfragment/ContactViewHolder.java')
-rw-r--r-- | java/com/android/dialer/contactsfragment/ContactViewHolder.java | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/java/com/android/dialer/contactsfragment/ContactViewHolder.java b/java/com/android/dialer/contactsfragment/ContactViewHolder.java index 0597c2a7e..2730c0d38 100644 --- a/java/com/android/dialer/contactsfragment/ContactViewHolder.java +++ b/java/com/android/dialer/contactsfragment/ContactViewHolder.java @@ -18,7 +18,6 @@ package com.android.dialer.contactsfragment; import android.content.Context; import android.net.Uri; -import android.provider.ContactsContract.QuickContact; import android.support.v7.widget.RecyclerView; import android.text.TextUtils; import android.view.View; @@ -26,7 +25,7 @@ import android.view.View.OnClickListener; import android.widget.QuickContactBadge; import android.widget.TextView; import com.android.dialer.common.Assert; -import com.android.dialer.contactsfragment.ContactsFragment.ClickAction; +import com.android.dialer.contactsfragment.ContactsFragment.OnContactSelectedListener; import com.android.dialer.logging.InteractionEvent; import com.android.dialer.logging.Logger; @@ -37,20 +36,20 @@ final class ContactViewHolder extends RecyclerView.ViewHolder implements OnClick private final TextView name; private final QuickContactBadge photo; private final Context context; - private final @ClickAction int clickAction; + private final OnContactSelectedListener onContactSelectedListener; private String headerText; private Uri contactUri; + private long contactId; - ContactViewHolder(View itemView, @ClickAction int clickAction) { + ContactViewHolder(View itemView, OnContactSelectedListener onContactSelectedListener) { super(itemView); - Assert.checkArgument(clickAction != ClickAction.INVALID, "Invalid click action."); + this.onContactSelectedListener = Assert.isNotNull(onContactSelectedListener); context = itemView.getContext(); itemView.findViewById(R.id.click_target).setOnClickListener(this); header = itemView.findViewById(R.id.header); name = itemView.findViewById(R.id.contact_name); photo = itemView.findViewById(R.id.photo); - this.clickAction = clickAction; } /** @@ -61,9 +60,11 @@ final class ContactViewHolder extends RecyclerView.ViewHolder implements OnClick * @param contactUri to be shown by the contact card on photo click. * @param showHeader if header view should be shown {@code True}, {@code False} otherwise. */ - public void bind(String headerText, String displayName, Uri contactUri, boolean showHeader) { + public void bind( + String headerText, String displayName, Uri contactUri, long contactId, boolean showHeader) { Assert.checkArgument(!TextUtils.isEmpty(displayName)); this.contactUri = contactUri; + this.contactId = contactId; this.headerText = headerText; name.setText(displayName); @@ -89,20 +90,6 @@ final class ContactViewHolder extends RecyclerView.ViewHolder implements OnClick @Override public void onClick(View v) { - switch (clickAction) { - case ClickAction.OPEN_CONTACT_CARD: - Logger.get(context) - .logInteraction(InteractionEvent.Type.OPEN_QUICK_CONTACT_FROM_CONTACTS_FRAGMENT_ITEM); - QuickContact.showQuickContact( - photo.getContext(), - photo, - contactUri, - QuickContact.MODE_LARGE, - null /* excludeMimes */); - break; - case ClickAction.INVALID: - default: - throw Assert.createIllegalStateFailException("Invalid click action."); - } + onContactSelectedListener.onContactSelected(photo, contactUri, contactId); } } |