From 7c031f1141de4e4e0de871886b848c0d5dc6c50b Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Tue, 5 Nov 2019 17:16:35 -0600 Subject: [PATCH] Fix caldav subtask animations --- .../todoroo/astrid/activity/TaskListFragment.java | 2 +- .../todoroo/astrid/adapter/AstridTaskAdapter.java | 5 ----- .../todoroo/astrid/adapter/CaldavTaskAdapter.java | 8 -------- .../todoroo/astrid/adapter/GoogleTaskAdapter.java | 5 ----- .../com/todoroo/astrid/adapter/TaskAdapter.java | 4 ---- .../org/tasks/tasklist/ItemTouchHelperCallback.java | 13 ++++--------- .../tasks/tasklist/ManualSortRecyclerAdapter.java | 7 ++----- 7 files changed, 7 insertions(+), 37 deletions(-) diff --git a/app/src/main/java/com/todoroo/astrid/activity/TaskListFragment.java b/app/src/main/java/com/todoroo/astrid/activity/TaskListFragment.java index 77e3051bc..72d3bc4e3 100644 --- a/app/src/main/java/com/todoroo/astrid/activity/TaskListFragment.java +++ b/app/src/main/java/com/todoroo/astrid/activity/TaskListFragment.java @@ -256,7 +256,7 @@ public final class TaskListFragment extends InjectingFragment taskListViewModel.setFilter( searchQuery == null ? filter : createSearchFilter(searchQuery), - taskAdapter.isManuallySorted()); + taskAdapter.supportsParentingOrManualSort()); recyclerAdapter = taskAdapter.supportsParentingOrManualSort() diff --git a/app/src/main/java/com/todoroo/astrid/adapter/AstridTaskAdapter.java b/app/src/main/java/com/todoroo/astrid/adapter/AstridTaskAdapter.java index 81708b458..613ebc19b 100644 --- a/app/src/main/java/com/todoroo/astrid/adapter/AstridTaskAdapter.java +++ b/app/src/main/java/com/todoroo/astrid/adapter/AstridTaskAdapter.java @@ -50,11 +50,6 @@ public final class AstridTaskAdapter extends TaskAdapter { return updater.getIndentForTask(parentUuid) + 1; } - @Override - public boolean isManuallySorted() { - return true; - } - @Override public boolean supportsParentingOrManualSort() { return true; diff --git a/app/src/main/java/com/todoroo/astrid/adapter/CaldavTaskAdapter.java b/app/src/main/java/com/todoroo/astrid/adapter/CaldavTaskAdapter.java index 4c36de474..b796e87ce 100644 --- a/app/src/main/java/com/todoroo/astrid/adapter/CaldavTaskAdapter.java +++ b/app/src/main/java/com/todoroo/astrid/adapter/CaldavTaskAdapter.java @@ -44,11 +44,6 @@ public final class CaldavTaskAdapter extends TaskAdapter { return 0; } - @Override - public boolean isManuallySorted() { - return false; - } - @Override public boolean supportsParentingOrManualSort() { return true; @@ -59,9 +54,6 @@ public final class CaldavTaskAdapter extends TaskAdapter { TaskContainer task = getTask(from); TaskContainer previous = to > 0 ? getTask(to-1) : null; - String prevTitle = previous != null ? previous.getTitle() : ""; - Timber.d("Moving %s (index %s) to %s (index %s)", task.getTitle(), from, prevTitle, to); - long newParent = task.getParent(); if (indent == 0) { newParent = 0; diff --git a/app/src/main/java/com/todoroo/astrid/adapter/GoogleTaskAdapter.java b/app/src/main/java/com/todoroo/astrid/adapter/GoogleTaskAdapter.java index de7e4b984..5489cacc3 100644 --- a/app/src/main/java/com/todoroo/astrid/adapter/GoogleTaskAdapter.java +++ b/app/src/main/java/com/todoroo/astrid/adapter/GoogleTaskAdapter.java @@ -65,11 +65,6 @@ public final class GoogleTaskAdapter extends TaskAdapter { return task.hasChildren() || !getTask(nextPosition).hasParent() ? 0 : 1; } - @Override - public boolean isManuallySorted() { - return true; - } - @Override public boolean supportsParentingOrManualSort() { return true; diff --git a/app/src/main/java/com/todoroo/astrid/adapter/TaskAdapter.java b/app/src/main/java/com/todoroo/astrid/adapter/TaskAdapter.java index 97a857929..587351cab 100644 --- a/app/src/main/java/com/todoroo/astrid/adapter/TaskAdapter.java +++ b/app/src/main/java/com/todoroo/astrid/adapter/TaskAdapter.java @@ -81,10 +81,6 @@ public class TaskAdapter { } } - public boolean isManuallySorted() { - return false; - } - public boolean supportsParentingOrManualSort() { return false; } diff --git a/app/src/main/java/org/tasks/tasklist/ItemTouchHelperCallback.java b/app/src/main/java/org/tasks/tasklist/ItemTouchHelperCallback.java index b02f52a9c..4b5e811a6 100644 --- a/app/src/main/java/org/tasks/tasklist/ItemTouchHelperCallback.java +++ b/app/src/main/java/org/tasks/tasklist/ItemTouchHelperCallback.java @@ -9,7 +9,6 @@ import android.graphics.Canvas; import androidx.annotation.NonNull; import androidx.recyclerview.widget.ItemTouchHelper; import androidx.recyclerview.widget.RecyclerView; -import com.todoroo.astrid.adapter.CaldavTaskAdapter; import com.todoroo.astrid.adapter.TaskAdapter; import com.todoroo.astrid.utility.Flags; import org.tasks.data.TaskContainer; @@ -141,17 +140,13 @@ public class ItemTouchHelperCallback extends ItemTouchHelper.Callback { if (from < to) { to++; } - if (!(adapter instanceof CaldavTaskAdapter)) { - vh.task.setIndent(targetIndent); - vh.setIndent(targetIndent); - } + vh.task.setIndent(targetIndent); + vh.setIndent(targetIndent); recyclerAdapter.moved(from, to, targetIndent); } else if (task.getIndent() != targetIndent) { int position = vh.getAdapterPosition(); - if (!(adapter instanceof CaldavTaskAdapter)) { - vh.task.setIndent(targetIndent); - vh.setIndent(targetIndent); - } + vh.task.setIndent(targetIndent); + vh.setIndent(targetIndent); recyclerAdapter.moved(position, position, targetIndent); } } diff --git a/app/src/main/java/org/tasks/tasklist/ManualSortRecyclerAdapter.java b/app/src/main/java/org/tasks/tasklist/ManualSortRecyclerAdapter.java index 12b2f21f6..ea0ee2126 100644 --- a/app/src/main/java/org/tasks/tasklist/ManualSortRecyclerAdapter.java +++ b/app/src/main/java/org/tasks/tasklist/ManualSortRecyclerAdapter.java @@ -16,7 +16,6 @@ import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.CompositeDisposable; import io.reactivex.schedulers.Schedulers; import io.reactivex.subjects.PublishSubject; -import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Queue; @@ -104,10 +103,8 @@ public class ManualSortRecyclerAdapter extends TaskListRecyclerAdapter { void moved(int from, int to, int indent) { adapter.moved(from, to, indent); - if (list instanceof ArrayList) { - TaskContainer task = list.remove(from); - list.add(from < to ? to - 1 : to, task); - } + TaskContainer task = list.remove(from); + list.add(from < to ? to - 1 : to, task); taskList.loadTaskListContent(); } }