package com.braintreepayments.api.dropin.adapters;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.braintreepayments.api.dropin.R;
import com.braintreepayments.api.dropin.utils.PaymentMethodType;
import com.braintreepayments.api.interfaces.PaymentMethodNonceCreatedListener;
import com.braintreepayments.api.models.PaymentMethodNonce;

import java.util.List;

public class VaultedPaymentMethodsAdapter extends RecyclerView.Adapter<VaultedPaymentMethodsAdapter.ViewHolder> {

    private PaymentMethodNonceCreatedListener mSelectedListener;
    private List<PaymentMethodNonce> mPaymentMethodNonces;

    public VaultedPaymentMethodsAdapter(PaymentMethodNonceCreatedListener listener,
            List<PaymentMethodNonce> paymentMethodNonces) {
        mSelectedListener = listener;
        mPaymentMethodNonces = paymentMethodNonces;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.bt_vaulted_payment_method_card,
                parent, false));
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        final PaymentMethodNonce paymentMethodNonce = mPaymentMethodNonces.get(position);

        holder.icon.setImageResource(PaymentMethodType.forType(paymentMethodNonce).getVaultedDrawable());
        holder.title.setText(paymentMethodNonce.getTypeLabel());
        holder.description.setText(paymentMethodNonce.getDescription());

        holder.itemView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                mSelectedListener.onPaymentMethodNonceCreated(paymentMethodNonce);
            }
        });
    }

    @Override
    public int getItemCount() {
        return mPaymentMethodNonces.size();
    }

    static class ViewHolder extends RecyclerView.ViewHolder {

        public ImageView icon;
        public TextView title;
        public TextView description;

        ViewHolder(View view) {
            super(view);

            icon = (ImageView) view.findViewById(R.id.bt_payment_method_icon);
            title = (TextView) view.findViewById(R.id.bt_payment_method_title);
            description = (TextView) view.findViewById(R.id.bt_payment_method_description);
        }
    }
}

@@ -1467,25 +1467,24 @@
 ition);%0A
-%0A
         
 holder.i
@@ -1479,37 +1479,46 @@
     
-holder.icon.setImageResource(
+PaymentMethodType paymentMethodType = 
 Paym
@@ -1558,16 +1558,73 @@
 odNonce)
+;%0A%0A        holder.icon.setImageResource(paymentMethodType
 .getVaul
@@ -1685,26 +1685,29 @@
 thod
-Nonc
+Typ
 e.get
-TypeLabel
+LocalizedName
 ());

Use localized name for payment method titles