public class NacCardAdapter extends androidx.recyclerview.widget.RecyclerView.Adapter<NacCardHolder> implements android.view.View.OnClickListener, android.view.View.OnCreateContextMenuListener, android.view.MenuItem.OnMenuItemClickListener, androidx.recyclerview.widget.RecyclerView.OnItemTouchListener, NacAlarm.OnAlarmChangeListener, NacCardHolder.OnCardCollapsedListener, NacCardHolder.OnCardExpandedListener, NacCardHolder.OnDeleteClickedListener, NacCardTouchHelper.Adapter
| Modifier and Type | Class and Description |
|---|---|
static interface |
NacCardAdapter.OnUseNfcChangeListener
Definition for the use NFC change listener.
|
static class |
NacCardAdapter.Undo
Undo an alarm card.
|
| Constructor and Description |
|---|
NacCardAdapter(android.content.Context context) |
| Modifier and Type | Method and Description |
|---|---|
void |
addAlarm()
Create a new alarm and add it to the list.
|
void |
addAlarm(NacAlarm alarm) |
void |
addAlarm(NacAlarm alarm,
int index)
Add an alarm to the given index in the list.
|
boolean |
atMaxAlarmCapacity() |
void |
build()
Build the alarm list.
|
void |
copyAlarm(int index)
Copy the alarm at the given index.
|
void |
deleteAlarm(int index)
Delete the alarm at the given index.
|
int |
findAlarm(NacAlarm alarm) |
NacAlarm |
getAlarm(int index) |
java.util.List<NacAlarm> |
getAlarms() |
NacCardHolder |
getCardHolder(NacAlarm alarm) |
int |
getItemCount() |
long |
getItemId(int position) |
NacAlarm |
getNextAlarm() |
NacUpcomingAlarmNotification |
getNotification() |
protected NacCardAdapter.OnUseNfcChangeListener |
getOnUseNfcChangeListener() |
java.util.List<NacAlarm> |
getSortedAlarms() |
int |
getUniqueId()
Determine a unique integer ID number to use for newly created alarms.
|
void |
highlight(NacAlarm alarm)
Highlight an alarm card.
|
void |
notifyDeleteAlarm(int index)
Delete an alarm and notify any registered observers.
|
void |
notifyInsertAlarm(NacAlarm alarm,
int index)
Insert an alarm and notify any registered observers.
|
void |
onAlarmChange(NacAlarm alarm)
Called when the alarm has been changed.
|
void |
onBindViewHolder(NacCardHolder card,
int position)
Setup the alarm card.
|
void |
onCardCollapsed(NacCardHolder holder,
NacAlarm alarm)
Called when the alarm card is collapsed.
|
void |
onCardExpanded(NacCardHolder holder,
NacAlarm alarm)
Called when the alarm card is expanded.
|
void |
onClick(android.view.View view)
Capture the click event on the delete button, and delete the card it
belongs to.
|
void |
onCreateContextMenu(android.view.ContextMenu menu,
android.view.View view,
android.view.ContextMenu.ContextMenuInfo menuInfo)
Create the context menu.
|
NacCardHolder |
onCreateViewHolder(android.view.ViewGroup parent,
int viewType)
Create the view holder.
|
void |
onDeleteClicked(int position)
Delete button was clicked.
|
boolean |
onInterceptTouchEvent(androidx.recyclerview.widget.RecyclerView rv,
android.view.MotionEvent ev)
Needed for RecyclerView.OnItemTouchListener
|
void |
onItemCopy(int index)
Called when an alarm card was swiped to be copied.
|
void |
onItemDelete(int index)
Called when an alarm card was swiped to be deleted.
|
boolean |
onMenuItemClick(android.view.MenuItem item)
Catch when a menu item is clicked.
|
void |
onRequestDisallowInterceptTouchEvent(boolean disallowIntercept)
Note: Needed for RecyclerView.OnItemTouchListener
|
void |
onTouchEvent(androidx.recyclerview.widget.RecyclerView rv,
android.view.MotionEvent e)
Note: Needed for RecyclerView.OnItemTouchListener
|
void |
restore(NacAlarm alarm,
int position)
Restore a previously deleted alarm.
|
void |
setOnUseNfcChangeListener(NacCardAdapter.OnUseNfcChangeListener listener)
Set the on use NFC change listener.
|
void |
setWasAddedWithFloatingActionButton(boolean added)
Set whether an alarm was added with the floating button.
|
void |
showAlarm(NacAlarm alarm)
Show the most recently edited alarm.
|
void |
showNextAlarm()
Show the next alarm.
|
void |
showNfcTagId(NacAlarm alarm)
Show the saved NFC tag ID of the given alarm.
|
int |
size() |
void |
sort()
Sort the enabled alarms from soonest to latest.
|
int |
sortAlarm(NacAlarm alarm)
Sort an alarm into the alarm list.
|
void |
sortHighlight(NacAlarm alarm)
Sort and highlight the alarm, if the alarm card is collapsed.
|
void |
toastMaxAlarmsError()
Toast for when the maximum number of alarms has been created.
|
void |
undo(NacAlarm alarm,
int position,
NacCardAdapter.Undo.Type type)
Save undo parameters.
|
void |
updateNotification()
Update the notification.
|
boolean |
wasAddedWithFloatingActionButton() |
bindViewHolder, createViewHolder, getItemViewType, hasObservers, hasStableIds, notifyDataSetChanged, notifyItemChanged, notifyItemChanged, notifyItemInserted, notifyItemMoved, notifyItemRangeChanged, notifyItemRangeChanged, notifyItemRangeInserted, notifyItemRangeRemoved, notifyItemRemoved, onAttachedToRecyclerView, onBindViewHolder, onDetachedFromRecyclerView, onFailedToRecycleView, onViewAttachedToWindow, onViewDetachedFromWindow, onViewRecycled, registerAdapterDataObserver, setHasStableIds, unregisterAdapterDataObserverpublic void addAlarm()
addAlarm(NacAlarm)public void addAlarm(NacAlarm alarm)
alarm - The alarm to add.addAlarm(NacAlarm, int)public void addAlarm(NacAlarm alarm, int index)
alarm - The alarm to add.index - The index to add the alarm.public boolean atMaxAlarmCapacity()
public void build()
public void copyAlarm(int index)
index - The index of the alarm to copy.public void deleteAlarm(int index)
index - The index of the alarm to delete.public int findAlarm(NacAlarm alarm)
public NacAlarm getAlarm(int index)
public java.util.List<NacAlarm> getAlarms()
public NacCardHolder getCardHolder(NacAlarm alarm)
public long getItemId(int position)
getItemId in class androidx.recyclerview.widget.RecyclerView.Adapter<NacCardHolder>public int getItemCount()
getItemCount in class androidx.recyclerview.widget.RecyclerView.Adapter<NacCardHolder>public NacAlarm getNextAlarm()
public NacUpcomingAlarmNotification getNotification()
protected NacCardAdapter.OnUseNfcChangeListener getOnUseNfcChangeListener()
public java.util.List<NacAlarm> getSortedAlarms()
public int getUniqueId()
public void highlight(NacAlarm alarm)
public void notifyDeleteAlarm(int index)
public void notifyInsertAlarm(NacAlarm alarm, int index)
public void onAlarmChange(NacAlarm alarm)
onAlarmChange in interface NacAlarm.OnAlarmChangeListeneralarm - The alarm that was changed.public void onBindViewHolder(NacCardHolder card, int position)
onBindViewHolder in class androidx.recyclerview.widget.RecyclerView.Adapter<NacCardHolder>card - The alarm card.position - The position of the alarm card.public void onCardCollapsed(NacCardHolder holder, NacAlarm alarm)
onCardCollapsed in interface NacCardHolder.OnCardCollapsedListenerpublic void onCardExpanded(NacCardHolder holder, NacAlarm alarm)
onCardExpanded in interface NacCardHolder.OnCardExpandedListenerpublic void onClick(android.view.View view)
onClick in interface android.view.View.OnClickListenerview - The view that was clicked.public void onCreateContextMenu(android.view.ContextMenu menu,
android.view.View view,
android.view.ContextMenu.ContextMenuInfo menuInfo)
onCreateContextMenu in interface android.view.View.OnCreateContextMenuListener@NonNull public NacCardHolder onCreateViewHolder(android.view.ViewGroup parent, int viewType)
onCreateViewHolder in class androidx.recyclerview.widget.RecyclerView.Adapter<NacCardHolder>parent - The parent view.viewType - The type of view.public void onDeleteClicked(int position)
onDeleteClicked in interface NacCardHolder.OnDeleteClickedListenerpublic boolean onInterceptTouchEvent(@NonNull
androidx.recyclerview.widget.RecyclerView rv,
android.view.MotionEvent ev)
onInterceptTouchEvent in interface androidx.recyclerview.widget.RecyclerView.OnItemTouchListenerpublic void onItemCopy(int index)
onItemCopy in interface NacCardTouchHelper.Adapterindex - The index of the alarm to copy.public void onItemDelete(int index)
onItemDelete in interface NacCardTouchHelper.Adapterindex - The index of the alarm to delete.public boolean onMenuItemClick(android.view.MenuItem item)
onMenuItemClick in interface android.view.MenuItem.OnMenuItemClickListenerpublic void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept)
onRequestDisallowInterceptTouchEvent in interface androidx.recyclerview.widget.RecyclerView.OnItemTouchListenerpublic void onTouchEvent(@NonNull
androidx.recyclerview.widget.RecyclerView rv,
@NonNull
android.view.MotionEvent e)
onTouchEvent in interface androidx.recyclerview.widget.RecyclerView.OnItemTouchListenerpublic void restore(NacAlarm alarm, int position)
alarm - The alarm to restore.position - The position to insert the alarm.public void setOnUseNfcChangeListener(NacCardAdapter.OnUseNfcChangeListener listener)
public void setWasAddedWithFloatingActionButton(boolean added)
public void showAlarm(NacAlarm alarm)
public void showNextAlarm()
public void showNfcTagId(NacAlarm alarm)
public int size()
public void sort()
public int sortAlarm(NacAlarm alarm)
public void sortHighlight(NacAlarm alarm)
public void toastMaxAlarmsError()
public void undo(NacAlarm alarm, int position, NacCardAdapter.Undo.Type type)
public void updateNotification()
public boolean wasAddedWithFloatingActionButton()