content: package com.androidavanzado.prueba;
  
  import android.support.v7.widget.RecyclerView;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ImageView;
  import android.widget.TextView;
  
  import java.util.List;
  
  public class MyNotaRecyclerViewAdapter extends RecyclerView.Adapter<MyNotaRecyclerViewAdapter.ViewHolder> {
  
      private final List<Nota> mValues;
      private final NotasInteractionListener mListener;
  
      public MyNotaRecyclerViewAdapter(List<Nota> items, NotasInteractionListener listener) {
          mValues = items;
          mListener = listener;
      }
  
      @Override
      public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View view = LayoutInflater.from(parent.getContext())
                  .inflate(R.layout.fragment_nota, parent, false);
          return new ViewHolder(view);
      }
  
      @Override
      public void onBindViewHolder(final ViewHolder holder, int position) {
          holder.mItem = mValues.get(position);
          holder.tvTitulo.setText(holder.mItem.getTitulo());
          holder.tvContenido.setText(holder.mItem.getContenido());
  
          if(holder.mItem.isFavorita()) {
              holder.ivFavorita.setImageResource(R.drawable.ic_star_black_24dp);
          }
  
          holder.ivFavorita.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  if (null != mListener) {
                      // Notify the active callbacks interface (the activity, if the
                      // fragment is attached to one) that an item has been selected.
                      mListener.favoritaNotaClick(holder.mItem);
                  }
              }
          });
      }
  
      @Override
      public int getItemCount() {
          return mValues.size();
      }
  
      public class ViewHolder extends RecyclerView.ViewHolder {
          public final View mView;
          public final TextView tvTitulo;
          public final TextView tvContenido;
          public final ImageView ivFavorita;
          public Nota mItem;
  
          public ViewHolder(View view) {
              super(view);
              mView = view;
              tvTitulo = view.findViewById(R.id.textViewTitulo);
              tvContenido = view.findViewById(R.id.textViewContenido);
              ivFavorita = view.findViewById(R.id.imageViewFavorita);
          }
  
          @Override
          public String toString() {
              return super.toString() + " '" + tvTitulo.getText() + "'";
          }
      }
  }
  