Class TaskItemAdapter
- java.lang.Object
-
- androidx.recyclerview.widget.RecyclerView.Adapter<TaskItemAdapter.TaskViewHolder>
-
- com.evanv.taskapp.ui.main.recycler.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
-
Field Summary
Fields Modifier and Type Field Description private Activity
mActivity
private Context
mContext
private int
mDay
private ClickListener
mListener
java.util.List<TaskItem>
mTaskItemList
-
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 dayvoid
onBindViewHolder(TaskItemAdapter.TaskViewHolder holder, int position)
Sets the name of the the item in the recyclerview to that of it's TaskItem representationTaskItemAdapter.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
-
-
-
-
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
-
mListener
private final ClickListener mListener
-
-
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 daylistener
- ClickListener to handle button clicksday
- Index into taskSchedule representing this dayheader
- 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 classandroidx.recyclerview.widget.RecyclerView.Adapter<TaskItemAdapter.TaskViewHolder>
- Parameters:
parent
- ViewGroup associated with the parent recyclerviewviewType
- 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 classandroidx.recyclerview.widget.RecyclerView.Adapter<TaskItemAdapter.TaskViewHolder>
- Parameters:
holder
- TaskViewHolder that represents the item to be changedposition
- Index in the taskItemList to be represented
-
getItemCount
public int getItemCount()
Gets the number of tasks for this day- Specified by:
getItemCount
in classandroidx.recyclerview.widget.RecyclerView.Adapter<TaskItemAdapter.TaskViewHolder>
- Returns:
- The number of tasks for this day
-
-