WIP new rules for tasks ordering

This commit is contained in:
BONNEVILLE Geoffroy
2018-11-09 18:28:07 +01:00
parent 9ad67699c0
commit 45d934dbb0
8 changed files with 24 additions and 40 deletions

Binary file not shown.

2
.idea/modules.xml generated
View File

@@ -2,8 +2,8 @@
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
<module fileurl="file://$PROJECT_DIR$/donext.iml" filepath="$PROJECT_DIR$/donext.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
</modules>
</component>
</project>

View File

@@ -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);
}

View File

@@ -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);
}
}

View File

@@ -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">
<fragment
android:id="@+id/fragment_main"

View File

@@ -2,6 +2,7 @@
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"

View File

@@ -10,7 +10,8 @@
android:id="@+id/task_cycle"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_marginStart="10dp"
android:layout_gravity="center"
android:textAppearance="?attr/textAppearanceListItem" />
<TextView
android:id="@+id/task_id"
@@ -23,6 +24,7 @@
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:layout_marginEnd="5dp"
android:layout_gravity="center"
android:contentDescription="@string/task_alarm"/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"

View File

@@ -33,9 +33,9 @@
android:id="@+id/task_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="70dp"
android:layout_marginBottom="40dp"
android:scrollbars="vertical"
android:name="com.wismna.geoffroy.donext.activities.TaskFragment"
app:layoutManager="LinearLayoutManager"
tools:context=".fragments.TasksFragment"
tools:listitem="@layout/fragment_task_detailed" />
<RelativeLayout
@@ -72,37 +72,25 @@
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="70dp"
android:layout_marginBottom="40dp"
android:layout_gravity="bottom"
android:background="@color/colorPrimaryLight"/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_height="40dp"
android:layout_gravity="bottom"
android:layout_marginTop="5dp"
android:paddingTop="15dp"
android:orientation="horizontal"
android:focusable="true"
android:background="?android:attr/selectableItemBackground" >
<TextView
android:id="@+id/total_task_cycles"
android:layout_width="100dp"
android:layout_marginStart="10dp"
android:layout_gravity="center"
android:layout_height="wrap_content"/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:focusable="true"
android:background="?android:attr/selectableItemBackground" >
<TextView
android:id="@+id/total_task_count"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/remaining_task_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
</FrameLayout>