Correction of bug in History (wrong layout manager cast)

This commit is contained in:
2017-12-21 23:27:38 +01:00
parent 1c505b3b45
commit 0b3560a752

View File

@@ -209,10 +209,13 @@ public class TasksFragment extends Fragment implements
totalTasksView.setText(resources.getQuantityString(R.plurals.task_total, totalTasks, totalTasks)); totalTasksView.setText(resources.getQuantityString(R.plurals.task_total, totalTasks, totalTasks));
} }
// Update remaining tasks RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
if (layoutManager instanceof LinearLayoutManager) return true;
// Update remaining tasks - only when needed
TextView remainingTasksView = view.findViewById(R.id.remaining_task_count); TextView remainingTasksView = view.findViewById(R.id.remaining_task_count);
NoScrollingLayoutManager layoutManager = (NoScrollingLayoutManager) recyclerView.getLayoutManager(); NoScrollingLayoutManager noScrollingLayoutManager = (NoScrollingLayoutManager)layoutManager;
int remainingTaskCount = totalTasks - layoutManager.findLastVisibleItemPosition() - 1; int remainingTaskCount = totalTasks - noScrollingLayoutManager.findLastVisibleItemPosition() - 1;
if (remainingTaskCount == 0) remainingTasksView.setText(""); if (remainingTaskCount == 0) remainingTasksView.setText("");
else remainingTasksView.setText(resources.getQuantityString(R.plurals.task_remaining, remainingTaskCount, remainingTaskCount)); else remainingTasksView.setText(resources.getQuantityString(R.plurals.task_remaining, remainingTaskCount, remainingTaskCount));