i am trying to implement an option to hide certain items from an ArrayList "mTaskList".
For that, i provide a boolean "hideDues" in the Adapter's Constructor. If it is true, i filter these items out of the list.
public DeadlinesAdapter(Context context, ArrayList<TaskItem> taskList, DeadlinesAdapterListener listener, boolean hideDues) {
if (hideDues) {
for (int i = 0; i < taskList.size(); i++) {
if (taskList.get(i).getTimeLeftInMinutes() < 1) taskList.remove(i);
}
}
mTaskList = taskList;
mContext = context;
mListener = listener;
}
It works, but when i set that boolean to false and reset the adapter, it still uses the filtered list, even though the original ArrayList i provide in the Constructor, is unchanged.
if (mHideDues) {
mHideDues = false;
item.setIcon(R.drawable.ic_invisible_white);
} else {
mHideDues = true;
item.setIcon(R.drawable.ic_visible_white);
}
mDeadlinesAdapter = new DeadlinesAdapter(this, mTaskList, this, mHideDues);
mDeadlinesRecyclerView.setAdapter(mDeadlinesAdapter);
I change the boolean and reset the Adapter. mTaskList shouldnt have any changes. So why doesnt it take a new ArrayList?