MedicionListAdapter

com.uva.rafael.tfg_goniometer.view.adapters

## Class MedicionListAdapter

- java.lang.Object
- - android.support.v7.widget.RecyclerView.Adapter<MedicionListAdapter.ViewHolder>
  - - com.uva.rafael.tfg_goniometer.view.adapters.MedicionListAdapter

-     public class MedicionListAdapter
      extends android.support.v7.widget.RecyclerView.Adapter<MedicionListAdapter.ViewHolder>

  Este es el `RecyclerView.Adapter` asociado al `RecyclerView` de `UltimasMedicionesFragment`.

  En concreto, se encarga de mostrar toda la informacion relativa a las ultimas 10 mediciones que ha almacenado el usuario en la Base de Datos, y notificar a `UltimasMedicionesPresenter` cuando el usuario pulse sobre el boton para borrar la medicion en alguna de ellas.

  Version:
    1.0
  Author:
    Rafael Matamoros Luque
  See Also:
    `UltimasMedicionesPresenter`, `RecyclerView.ViewHolder`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `(package private) static class` | `MedicionListAdapter.ViewHolder`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MedicionListAdapter(java.util.ArrayList<java.util.ArrayList<java.lang.String>> medicionesList, UltimasMedicionesPresenter presenter)` Constructor principal del `RecyclerView.Adapter` para el `RecyclerView`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `getItemCount()` Returns the total number of items in the data set held by the adapter.
    `void` | `onBindViewHolder(MedicionListAdapter.ViewHolder holder, int position)` Called by RecyclerView to display the data at the specified position.
    `MedicionListAdapter.ViewHolder` | `onCreateViewHolder(android.view.ViewGroup parent, int viewType)` Metodo llamado para instanciar cada uno de los elementos del `RecyclerView.Adapter` con su layout asociada (R.layout.medicion_miniatura, en este caso).

    - ### Methods inherited from class android.support.v7.widget.RecyclerView.Adapter

      `bindViewHolder, createViewHolder, getItemId, getItemViewType, hasObservers, hasStableIds, notifyDataSetChanged, notifyItemChanged, notifyItemChanged, notifyItemInserted, notifyItemMoved, notifyItemRangeChanged, notifyItemRangeChanged, notifyItemRangeInserted, notifyItemRangeRemoved, notifyItemRemoved, onAttachedToRecyclerView, onBindViewHolder, onDetachedFromRecyclerView, onFailedToRecycleView, onViewAttachedToWindow, onViewDetachedFromWindow, onViewRecycled, registerAdapterDataObserver, setHasStableIds, unregisterAdapterDataObserver`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### MedicionListAdapter

          public MedicionListAdapter(java.util.ArrayList<java.util.ArrayList<java.lang.String>> medicionesList,
                                     UltimasMedicionesPresenter presenter)

      Constructor principal del `RecyclerView.Adapter` para el `RecyclerView`
      Parameters:
        `medicionesList` - Listado de mediciones a mostrar
        `presenter` - Presentador asociado con este `RecyclerView.Adapter`

  - ### Method Detail

    - #### onCreateViewHolder

          public MedicionListAdapter.ViewHolder onCreateViewHolder(android.view.ViewGroup parent,
                                                                   int viewType)

      Metodo llamado para instanciar cada uno de los elementos del `RecyclerView.Adapter` con su layout asociada (R.layout.medicion_miniatura, en este caso).
      Specified by:
        `onCreateViewHolder` in class `android.support.v7.widget.RecyclerView.Adapter<MedicionListAdapter.ViewHolder>`
      Parameters:
        `parent` - The ViewGroup into which the new View will be added after it is bound to an adapter position.
        `viewType` - The view type of the new View.
      Returns:
        A new ViewHolder that holds a View of the given view type.
      See Also:
        `RecyclerView.Adapter.getItemViewType(int)`, `onBindViewHolder(ViewHolder, int)`

    - #### onBindViewHolder

          public void onBindViewHolder(MedicionListAdapter.ViewHolder holder,
                                       int position)

      Called by RecyclerView to display the data at the specified position. This method should update the contents of the `RecyclerView.ViewHolder.itemView` to reflect the item at the given position.

      En concreto, se encarga de mostrar toda la informacion relativa a las ultimas 10 mediciones que ha almacenado el usuario en la Base de Datos, ademas de añadir un evento de tipo `OnClickListener` al boton para borrar la medicion, para notificar al Presentador cuando el usuario lo pulse.

      Specified by:
        `onBindViewHolder` in class `android.support.v7.widget.RecyclerView.Adapter<MedicionListAdapter.ViewHolder>`
      Parameters:
        `holder` - The ViewHolder which should be updated to represent the contents of the item at the given position in the data set.
        `position` - The position of the item within the adapter's data set.

    - #### getItemCount

          public int getItemCount()

      Returns the total number of items in the data set held by the adapter.
      Specified by:
        `getItemCount` in class `android.support.v7.widget.RecyclerView.Adapter<MedicionListAdapter.ViewHolder>`
      Returns:
        The total number of items in this adapter.