From 45d934dbb0777874901255273ac6e0c752ce60dc Mon Sep 17 00:00:00 2001 From: BONNEVILLE Geoffroy Date: Fri, 9 Nov 2018 18:28:07 +0100 Subject: [PATCH] WIP new rules for tasks ordering --- .idea/caches/build_file_checksums.ser | Bin 538 -> 535 bytes .idea/modules.xml | 2 +- .../donext/database/TaskDataAccess.java | 2 +- .../donext/fragments/TasksFragment.java | 22 ++++-------- app/src/main/res/layout/activity_history.xml | 1 + app/src/main/res/layout/activity_today.xml | 1 + .../res/layout/fragment_task_detailed.xml | 4 ++- app/src/main/res/layout/fragment_tasks.xml | 32 ++++++------------ 8 files changed, 24 insertions(+), 40 deletions(-) diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 87587bfa04fd51ef144c4e03b2db4171f15223e4..509a532e3134686ce7d464407885b7392a0713a5 100644 GIT binary patch delta 245 zcmbQmGM#0@43_T?xaB9#@vj$1EGURcD$UGE(MvB%OvyODkiizwWv78-N`iuYG2IccZ|{kS7du`_A_i^dD*}@@i*r$PAw_P%u6rUOD{@H$w@6OVql7PTJu@_2OCGo111KB ziUI}(27%@Oqz+Ha-1<}_DlRxpUsZatKcl3!C-?0w6PQ?+huc5j`pG@!UI~MyerR!O zQL%n{YJOT;QGTU9)KvY+dl_}v1ak6|6LThiWE6E^JZV>OJum2#-~|&k$vX^DB@6 - + \ No newline at end of file diff --git a/app/src/main/java/com/wismna/geoffroy/donext/database/TaskDataAccess.java b/app/src/main/java/com/wismna/geoffroy/donext/database/TaskDataAccess.java index 2d7fec4..c183434 100644 --- a/app/src/main/java/com/wismna/geoffroy/donext/database/TaskDataAccess.java +++ b/app/src/main/java/com/wismna/geoffroy/donext/database/TaskDataAccess.java @@ -120,7 +120,7 @@ public class TaskDataAccess implements AutoCloseable { " AND (" + DatabaseHelper.TASKS_COLUMN_DONE + " = " + history + (isHistory ? " OR " : " AND ") + DatabaseHelper.TASKS_COLUMN_DELETED + " = " + history + ")", null, null, null, - DatabaseHelper.TASKS_COLUMN_CYCLE + ", " + DatabaseHelper.COLUMN_ID + " DESC"); + DatabaseHelper.TASKS_COLUMN_PRIORITY + " DESC"); return getTasksFromCursor(cursor); } diff --git a/app/src/main/java/com/wismna/geoffroy/donext/fragments/TasksFragment.java b/app/src/main/java/com/wismna/geoffroy/donext/fragments/TasksFragment.java index 0f24efd..af78849 100644 --- a/app/src/main/java/com/wismna/geoffroy/donext/fragments/TasksFragment.java +++ b/app/src/main/java/com/wismna/geoffroy/donext/fragments/TasksFragment.java @@ -38,7 +38,6 @@ import com.wismna.geoffroy.donext.database.TaskDataAccess; import com.wismna.geoffroy.donext.database.TaskListDataAccess; import com.wismna.geoffroy.donext.helpers.TaskTouchHelper; import com.wismna.geoffroy.donext.listeners.RecyclerItemClickListener; -import com.wismna.geoffroy.donext.widgets.NoScrollingLayoutManager; import org.joda.time.LocalDate; @@ -104,7 +103,7 @@ public class TasksFragment extends Fragment implements // Set the Recycler view recyclerView = view.findViewById(R.id.task_list_view); - recyclerView.setLayoutManager(isHistory ? new LinearLayoutManager(context) : new NoScrollingLayoutManager(context)); + recyclerView.setLayoutManager(new LinearLayoutManager(context)); // Get all tasks try (TaskDataAccess taskDataAccess = new TaskDataAccess(view.getContext())) { @@ -206,16 +205,6 @@ public class TasksFragment extends Fragment implements totalTasksView.setText(resources.getQuantityString(R.plurals.task_total, totalTasks, totalTasks)); } - 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); - NoScrollingLayoutManager noScrollingLayoutManager = (NoScrollingLayoutManager)layoutManager; - int remainingTaskCount = totalTasks - (noScrollingLayoutManager != null ? noScrollingLayoutManager.findLastVisibleItemPosition() : 1) - 1; - if (remainingTaskCount == 0) remainingTasksView.setText(""); - else remainingTasksView.setText(resources.getQuantityString(R.plurals.task_remaining, remainingTaskCount, remainingTaskCount)); - return true; } }); @@ -302,6 +291,7 @@ public class TasksFragment extends Fragment implements // Should never happen because we will have to be on this tab to open the dialog if (taskRecyclerViewAdapter == null) return; + int position = 0; // Add the task if (task == null) { // If the new task is added to another task list, update the tab @@ -310,13 +300,14 @@ public class TasksFragment extends Fragment implements } // Otherwise add it to the current one else { - taskRecyclerViewAdapter.add(newTask, 0); - recyclerView.scrollToPosition(0); + position = taskRecyclerViewAdapter.getItemCount(); + taskRecyclerViewAdapter.add(newTask, position); + recyclerView.scrollToPosition(position); } } // Update the task else { - int position = args != null ? args.getInt("position") : 0; + position = args != null ? args.getInt("position") : 0; // Check if task list was changed if ((isTodayView && !isToday) || (!isTodayView && task.getTaskListId() != taskList.getId())) { @@ -329,6 +320,7 @@ public class TasksFragment extends Fragment implements taskRecyclerViewAdapter.update(newTask, position); } } + taskRecyclerViewAdapter.notifyItemChanged(position); } } diff --git a/app/src/main/res/layout/activity_history.xml b/app/src/main/res/layout/activity_history.xml index c53dbe3..2181eaa 100644 --- a/app/src/main/res/layout/activity_history.xml +++ b/app/src/main/res/layout/activity_history.xml @@ -3,6 +3,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" + android:id="@+id/main_content" tools:context="com.wismna.geoffroy.donext.activities.HistoryActivity"> + - - - - \ No newline at end of file