Fix caldav subtask animations

pull/848/head^2
Alex Baker 5 years ago
parent 40b952408d
commit 7c031f1141

@ -256,7 +256,7 @@ public final class TaskListFragment extends InjectingFragment
taskListViewModel.setFilter( taskListViewModel.setFilter(
searchQuery == null ? filter : createSearchFilter(searchQuery), searchQuery == null ? filter : createSearchFilter(searchQuery),
taskAdapter.isManuallySorted()); taskAdapter.supportsParentingOrManualSort());
recyclerAdapter = recyclerAdapter =
taskAdapter.supportsParentingOrManualSort() taskAdapter.supportsParentingOrManualSort()

@ -50,11 +50,6 @@ public final class AstridTaskAdapter extends TaskAdapter {
return updater.getIndentForTask(parentUuid) + 1; return updater.getIndentForTask(parentUuid) + 1;
} }
@Override
public boolean isManuallySorted() {
return true;
}
@Override @Override
public boolean supportsParentingOrManualSort() { public boolean supportsParentingOrManualSort() {
return true; return true;

@ -44,11 +44,6 @@ public final class CaldavTaskAdapter extends TaskAdapter {
return 0; return 0;
} }
@Override
public boolean isManuallySorted() {
return false;
}
@Override @Override
public boolean supportsParentingOrManualSort() { public boolean supportsParentingOrManualSort() {
return true; return true;
@ -59,9 +54,6 @@ public final class CaldavTaskAdapter extends TaskAdapter {
TaskContainer task = getTask(from); TaskContainer task = getTask(from);
TaskContainer previous = to > 0 ? getTask(to-1) : null; 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(); long newParent = task.getParent();
if (indent == 0) { if (indent == 0) {
newParent = 0; newParent = 0;

@ -65,11 +65,6 @@ public final class GoogleTaskAdapter extends TaskAdapter {
return task.hasChildren() || !getTask(nextPosition).hasParent() ? 0 : 1; return task.hasChildren() || !getTask(nextPosition).hasParent() ? 0 : 1;
} }
@Override
public boolean isManuallySorted() {
return true;
}
@Override @Override
public boolean supportsParentingOrManualSort() { public boolean supportsParentingOrManualSort() {
return true; return true;

@ -81,10 +81,6 @@ public class TaskAdapter {
} }
} }
public boolean isManuallySorted() {
return false;
}
public boolean supportsParentingOrManualSort() { public boolean supportsParentingOrManualSort() {
return false; return false;
} }

@ -9,7 +9,6 @@ import android.graphics.Canvas;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.recyclerview.widget.ItemTouchHelper; import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.todoroo.astrid.adapter.CaldavTaskAdapter;
import com.todoroo.astrid.adapter.TaskAdapter; import com.todoroo.astrid.adapter.TaskAdapter;
import com.todoroo.astrid.utility.Flags; import com.todoroo.astrid.utility.Flags;
import org.tasks.data.TaskContainer; import org.tasks.data.TaskContainer;
@ -141,17 +140,13 @@ public class ItemTouchHelperCallback extends ItemTouchHelper.Callback {
if (from < to) { if (from < to) {
to++; to++;
} }
if (!(adapter instanceof CaldavTaskAdapter)) { vh.task.setIndent(targetIndent);
vh.task.setIndent(targetIndent); vh.setIndent(targetIndent);
vh.setIndent(targetIndent);
}
recyclerAdapter.moved(from, to, targetIndent); recyclerAdapter.moved(from, to, targetIndent);
} else if (task.getIndent() != targetIndent) { } else if (task.getIndent() != targetIndent) {
int position = vh.getAdapterPosition(); int position = vh.getAdapterPosition();
if (!(adapter instanceof CaldavTaskAdapter)) { vh.task.setIndent(targetIndent);
vh.task.setIndent(targetIndent); vh.setIndent(targetIndent);
vh.setIndent(targetIndent);
}
recyclerAdapter.moved(position, position, targetIndent); recyclerAdapter.moved(position, position, targetIndent);
} }
} }

@ -16,7 +16,6 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable; import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.schedulers.Schedulers; import io.reactivex.schedulers.Schedulers;
import io.reactivex.subjects.PublishSubject; import io.reactivex.subjects.PublishSubject;
import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Queue; import java.util.Queue;
@ -104,10 +103,8 @@ public class ManualSortRecyclerAdapter extends TaskListRecyclerAdapter {
void moved(int from, int to, int indent) { void moved(int from, int to, int indent) {
adapter.moved(from, to, indent); adapter.moved(from, to, indent);
if (list instanceof ArrayList) { TaskContainer task = list.remove(from);
TaskContainer task = list.remove(from); list.add(from < to ? to - 1 : to, task);
list.add(from < to ? to - 1 : to, task);
}
taskList.loadTaskListContent(); taskList.loadTaskListContent();
} }
} }

Loading…
Cancel
Save