Class HealthDataAdapter

java.lang.Object
android.widget.BaseAdapter
android.widget.ArrayAdapter<HealthData>
com.example.cardiotracker.HealthDataAdapter
All Implemented Interfaces:
android.widget.Adapter, android.widget.Filterable, android.widget.ListAdapter, android.widget.SpinnerAdapter, android.widget.ThemedSpinnerAdapter

public class HealthDataAdapter extends android.widget.ArrayAdapter<HealthData>
The HealthDataAdapter is a custom ArrayAdapter used to populate a ListView with HealthData objects. It handles the creation of the list item views and displays the health data information in the appropriate views.
  • Field Summary

    Fields inherited from interface android.widget.Adapter

    IGNORE_ITEM_VIEW_TYPE, NO_SELECTION
  • Constructor Summary

    Constructors
    Constructor
    Description
    HealthDataAdapter(android.content.Context context, List<HealthData> dataList)
    Constructs a HealthDataAdapter with the given context and data list.
  • Method Summary

    Modifier and Type
    Method
    Description
    private String
    Formats the given time string into the desired format.
    android.view.View
    getView(int position, android.view.View convertView, android.view.ViewGroup parent)
    Gets a View that displays the data at the specified position in the data list.

    Methods inherited from class android.widget.ArrayAdapter

    add, addAll, addAll, clear, createFromResource, getAutofillOptions, getContext, getCount, getDropDownView, getDropDownViewTheme, getFilter, getItem, getItemId, getPosition, insert, notifyDataSetChanged, remove, setDropDownViewResource, setDropDownViewTheme, setNotifyOnChange, sort

    Methods inherited from class android.widget.BaseAdapter

    areAllItemsEnabled, getItemViewType, getViewTypeCount, hasStableIds, isEmpty, isEnabled, notifyDataSetInvalidated, registerDataSetObserver, setAutofillOptions, unregisterDataSetObserver

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface android.widget.Adapter

    getItemViewType, getViewTypeCount, hasStableIds, isEmpty, registerDataSetObserver, unregisterDataSetObserver
  • Constructor Details

    • HealthDataAdapter

      public HealthDataAdapter(android.content.Context context, List<HealthData> dataList)
      Constructs a HealthDataAdapter with the given context and data list.
      Parameters:
      context - the context of the adapter
      dataList - the list of HealthData objects to be displayed
  • Method Details

    • getView

      public android.view.View getView(int position, android.view.View convertView, android.view.ViewGroup parent)
      Gets a View that displays the data at the specified position in the data list.
      Specified by:
      getView in interface android.widget.Adapter
      Overrides:
      getView in class android.widget.ArrayAdapter<HealthData>
      Parameters:
      position - the position of the item within the adapter's data set
      convertView - the old view to reuse, if possible
      parent - the parent ViewGroup containing the convertView
      Returns:
      the View corresponding to the data at the specified position
    • formatTime

      private String formatTime(String time)
      Formats the given time string into the desired format.
      Parameters:
      time - the time string to be formatted
      Returns:
      the formatted time string