Class TaskItemAdapter


  • public class TaskItemAdapter
    extends androidx.recyclerview.widget.RecyclerView.Adapter<TaskItemAdapter.TaskViewHolder>
    Adapter to interface between data in TaskItems and recyclerview in DayItem
    Author:
    Evan Voogd
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      class  TaskItemAdapter.TaskViewHolder
      Holder that interfaces between the adapter and the task_item views
      • Nested classes/interfaces inherited from class androidx.recyclerview.widget.RecyclerView.Adapter

        androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationPolicy
    • Constructor Summary

      Constructors 
      Constructor Description
      TaskItemAdapter​(java.util.List<TaskItem> taskItemList, ClickListener listener, int day, TextView header, Activity activity)
      Constructs an adapter for a given DayItem's task recyclerview
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getItemCount()
      Gets the number of tasks for this day
      void onBindViewHolder​(TaskItemAdapter.TaskViewHolder holder, int position)
      Sets the name of the the item in the recyclerview to that of it's TaskItem representation
      TaskItemAdapter.TaskViewHolder onCreateViewHolder​(ViewGroup parent, int viewType)
      Initialize an individual layout for the DayItem's recyclerview
      • Methods inherited from class androidx.recyclerview.widget.RecyclerView.Adapter

        bindViewHolder, createViewHolder, findRelativeAdapterPositionIn, getItemId, getItemViewType, getStateRestorationPolicy, hasObservers, hasStableIds, notifyDataSetChanged, notifyItemChanged, notifyItemChanged, notifyItemInserted, notifyItemMoved, notifyItemRangeChanged, notifyItemRangeChanged, notifyItemRangeInserted, notifyItemRangeRemoved, notifyItemRemoved, onAttachedToRecyclerView, onBindViewHolder, onDetachedFromRecyclerView, onFailedToRecycleView, onViewAttachedToWindow, onViewDetachedFromWindow, onViewRecycled, registerAdapterDataObserver, setHasStableIds, setStateRestorationPolicy, unregisterAdapterDataObserver
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • mTaskItemList

        public final java.util.List<TaskItem> mTaskItemList
      • mDay

        private final int mDay
      • mContext

        private final Context mContext
      • mActivity

        private final Activity mActivity
    • Constructor Detail

      • TaskItemAdapter

        public TaskItemAdapter​(java.util.List<TaskItem> taskItemList,
                               ClickListener listener,
                               int day,
                               TextView header,
                               Activity activity)
        Constructs an adapter for a given DayItem's task recyclerview
        Parameters:
        taskItemList - the list of tasks for this day
        listener - ClickListener to handle button clicks
        day - Index into taskSchedule representing this day
        header - Header for task list for this day
    • Method Detail

      • onCreateViewHolder

        @NonNull
        public TaskItemAdapter.TaskViewHolder onCreateViewHolder​(@NonNull
                                                                 ViewGroup parent,
                                                                 int viewType)
        Initialize an individual layout for the DayItem's recyclerview
        Specified by:
        onCreateViewHolder in class androidx.recyclerview.widget.RecyclerView.Adapter<TaskItemAdapter.TaskViewHolder>
        Parameters:
        parent - ViewGroup associated with the parent recyclerview
        viewType - not used, required by override
        Returns:
        TaskViewHolder associated with the new layout
        See Also:
        RecyclerView.Adapter.getItemViewType(int), RecyclerView.Adapter.onBindViewHolder(ViewHolder, int)
      • onBindViewHolder

        public void onBindViewHolder​(@NonNull
                                     TaskItemAdapter.TaskViewHolder holder,
                                     int position)
        Sets the name of the the item in the recyclerview to that of it's TaskItem representation
        Specified by:
        onBindViewHolder in class androidx.recyclerview.widget.RecyclerView.Adapter<TaskItemAdapter.TaskViewHolder>
        Parameters:
        holder - TaskViewHolder that represents the item to be changed
        position - Index in the taskItemList to be represented
      • getItemCount

        public int getItemCount()
        Gets the number of tasks for this day
        Specified by:
        getItemCount in class androidx.recyclerview.widget.RecyclerView.Adapter<TaskItemAdapter.TaskViewHolder>
        Returns:
        The number of tasks for this day