mirror of
https://github.com/wismna/DoNext.git
synced 2025-10-03 07:30:13 -04:00
WIP new rules for tasks ordering
This commit is contained in:
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
2
.idea/modules.xml
generated
2
.idea/modules.xml
generated
@@ -2,8 +2,8 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectModuleManager">
|
<component name="ProjectModuleManager">
|
||||||
<modules>
|
<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$/donext.iml" filepath="$PROJECT_DIR$/donext.iml" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
|
||||||
</modules>
|
</modules>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@@ -120,7 +120,7 @@ public class TaskDataAccess implements AutoCloseable {
|
|||||||
" AND (" + DatabaseHelper.TASKS_COLUMN_DONE + " = " + history +
|
" AND (" + DatabaseHelper.TASKS_COLUMN_DONE + " = " + history +
|
||||||
(isHistory ? " OR " : " AND ") + DatabaseHelper.TASKS_COLUMN_DELETED + " = " + history + ")",
|
(isHistory ? " OR " : " AND ") + DatabaseHelper.TASKS_COLUMN_DELETED + " = " + history + ")",
|
||||||
null, null, null,
|
null, null, null,
|
||||||
DatabaseHelper.TASKS_COLUMN_CYCLE + ", " + DatabaseHelper.COLUMN_ID + " DESC");
|
DatabaseHelper.TASKS_COLUMN_PRIORITY + " DESC");
|
||||||
return getTasksFromCursor(cursor);
|
return getTasksFromCursor(cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -38,7 +38,6 @@ import com.wismna.geoffroy.donext.database.TaskDataAccess;
|
|||||||
import com.wismna.geoffroy.donext.database.TaskListDataAccess;
|
import com.wismna.geoffroy.donext.database.TaskListDataAccess;
|
||||||
import com.wismna.geoffroy.donext.helpers.TaskTouchHelper;
|
import com.wismna.geoffroy.donext.helpers.TaskTouchHelper;
|
||||||
import com.wismna.geoffroy.donext.listeners.RecyclerItemClickListener;
|
import com.wismna.geoffroy.donext.listeners.RecyclerItemClickListener;
|
||||||
import com.wismna.geoffroy.donext.widgets.NoScrollingLayoutManager;
|
|
||||||
|
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
|
|
||||||
@@ -104,7 +103,7 @@ public class TasksFragment extends Fragment implements
|
|||||||
|
|
||||||
// Set the Recycler view
|
// Set the Recycler view
|
||||||
recyclerView = view.findViewById(R.id.task_list_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
|
// Get all tasks
|
||||||
try (TaskDataAccess taskDataAccess = new TaskDataAccess(view.getContext())) {
|
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));
|
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;
|
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
|
// Should never happen because we will have to be on this tab to open the dialog
|
||||||
if (taskRecyclerViewAdapter == null) return;
|
if (taskRecyclerViewAdapter == null) return;
|
||||||
|
|
||||||
|
int position = 0;
|
||||||
// Add the task
|
// Add the task
|
||||||
if (task == null) {
|
if (task == null) {
|
||||||
// If the new task is added to another task list, update the tab
|
// 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
|
// Otherwise add it to the current one
|
||||||
else {
|
else {
|
||||||
taskRecyclerViewAdapter.add(newTask, 0);
|
position = taskRecyclerViewAdapter.getItemCount();
|
||||||
recyclerView.scrollToPosition(0);
|
taskRecyclerViewAdapter.add(newTask, position);
|
||||||
|
recyclerView.scrollToPosition(position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Update the task
|
// Update the task
|
||||||
else {
|
else {
|
||||||
int position = args != null ? args.getInt("position") : 0;
|
position = args != null ? args.getInt("position") : 0;
|
||||||
// Check if task list was changed
|
// Check if task list was changed
|
||||||
if ((isTodayView && !isToday) || (!isTodayView && task.getTaskListId() != taskList.getId()))
|
if ((isTodayView && !isToday) || (!isTodayView && task.getTaskListId() != taskList.getId()))
|
||||||
{
|
{
|
||||||
@@ -329,6 +320,7 @@ public class TasksFragment extends Fragment implements
|
|||||||
taskRecyclerViewAdapter.update(newTask, position);
|
taskRecyclerViewAdapter.update(newTask, position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
taskRecyclerViewAdapter.notifyItemChanged(position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:id="@+id/main_content"
|
||||||
tools:context="com.wismna.geoffroy.donext.activities.HistoryActivity">
|
tools:context="com.wismna.geoffroy.donext.activities.HistoryActivity">
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/fragment_main"
|
android:id="@+id/fragment_main"
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/main_content"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:fitsSystemWindows="true"
|
android:fitsSystemWindows="true"
|
||||||
|
@@ -10,7 +10,8 @@
|
|||||||
android:id="@+id/task_cycle"
|
android:id="@+id/task_cycle"
|
||||||
android:layout_width="30dp"
|
android:layout_width="30dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="10dp"
|
android:layout_marginStart="10dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
android:textAppearance="?attr/textAppearanceListItem" />
|
android:textAppearance="?attr/textAppearanceListItem" />
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/task_id"
|
android:id="@+id/task_id"
|
||||||
@@ -23,6 +24,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingTop="10dp"
|
android:paddingTop="10dp"
|
||||||
android:layout_marginEnd="5dp"
|
android:layout_marginEnd="5dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
android:contentDescription="@string/task_alarm"/>
|
android:contentDescription="@string/task_alarm"/>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@@ -33,9 +33,9 @@
|
|||||||
android:id="@+id/task_list_view"
|
android:id="@+id/task_list_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="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"
|
android:name="com.wismna.geoffroy.donext.activities.TaskFragment"
|
||||||
app:layoutManager="LinearLayoutManager"
|
|
||||||
tools:context=".fragments.TasksFragment"
|
tools:context=".fragments.TasksFragment"
|
||||||
tools:listitem="@layout/fragment_task_detailed" />
|
tools:listitem="@layout/fragment_task_detailed" />
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
@@ -72,37 +72,25 @@
|
|||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:layout_marginBottom="70dp"
|
android:layout_marginBottom="40dp"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
android:background="@color/colorPrimaryLight"/>
|
android:background="@color/colorPrimaryLight"/>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="70dp"
|
android:layout_height="40dp"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:paddingTop="15dp"
|
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:background="?android:attr/selectableItemBackground" >
|
android:background="?android:attr/selectableItemBackground" >
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/total_task_cycles"
|
android:id="@+id/total_task_cycles"
|
||||||
android:layout_width="100dp"
|
android:layout_width="100dp"
|
||||||
android:layout_marginStart="10dp"
|
android:layout_gravity="center"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/total_task_count"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"/>
|
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_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>
|
</LinearLayout>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
Reference in New Issue
Block a user