Animate google task indentation

pull/820/head
Alex Baker 5 years ago
parent 4fcf02365a
commit dd2d038ba0

@ -39,7 +39,6 @@ import com.google.android.material.snackbar.Snackbar;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Join;
import com.todoroo.andlib.sql.QueryTemplate;
import com.todoroo.astrid.adapter.GoogleTaskAdapter;
import com.todoroo.astrid.adapter.TaskAdapter;
import com.todoroo.astrid.adapter.TaskAdapterProvider;
import com.todoroo.astrid.api.CaldavFilter;
@ -524,7 +523,7 @@ public final class TaskListFragment extends InjectingFragment
*/
private void refresh() {
// TODO: compare indents in diff callback, then animate this
loadTaskListContent(!(taskAdapter instanceof GoogleTaskAdapter));
loadTaskListContent();
setSyncOngoing(preferences.isSyncOngoing());
}
@ -536,12 +535,6 @@ public final class TaskListFragment extends InjectingFragment
*/
public void loadTaskListContent() {
loadTaskListContent(true);
}
public void loadTaskListContent(boolean animate) {
recyclerAdapter.setAnimate(animate);
taskListViewModel.invalidate();
}

@ -101,7 +101,7 @@ public class ItemTouchHelperCallback extends ItemTouchHelper.Callback {
to++;
}
adapter.moved(from, to);
taskList.loadTaskListContent(false);
taskList.loadTaskListContent();
}
}
from = -1;
@ -112,6 +112,6 @@ public class ItemTouchHelperCallback extends ItemTouchHelper.Callback {
@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
adapter.indented(viewHolder.getAdapterPosition(), direction == ItemTouchHelper.RIGHT ? 1 : -1);
taskList.loadTaskListContent(false);
taskList.loadTaskListContent();
}
}

@ -29,7 +29,6 @@ public class TaskListRecyclerAdapter extends ListAdapter<TaskContainer, ViewHold
private final ItemTouchHelperCallback itemTouchHelperCallback;
private ActionMode mode = null;
private boolean animate;
private RecyclerView recyclerView;
public TaskListRecyclerAdapter(
@ -169,35 +168,22 @@ public class TaskListRecyclerAdapter extends ListAdapter<TaskContainer, ViewHold
@Override
public void onMoved(int fromPosition, int toPosition) {
if (animate) {
notifyItemChanged(fromPosition);
notifyItemMoved(fromPosition, toPosition);
recyclerView.scrollToPosition(fromPosition);
} else {
notifyDataSetChanged();
}
notifyItemChanged(fromPosition);
notifyItemMoved(fromPosition, toPosition);
recyclerView.scrollToPosition(fromPosition);
}
@Override
public void onChanged(int position, int count, Object payload) {
if (animate) {
notifyItemRangeChanged(position, count, payload);
} else {
notifyDataSetChanged();
}
notifyItemRangeChanged(position, count, payload);
}
public void onTaskSaved() {
setAnimate(true);
int scrollY = recyclerView.getScrollY();
notifyDataSetChanged();
recyclerView.setScrollY(scrollY);
}
public void setAnimate(boolean animate) {
this.animate = animate;
}
boolean isActionModeActive() {
return mode != null;
}

@ -185,6 +185,7 @@ class ViewHolder extends RecyclerView.ViewHolder {
if (atLeastLollipop()) {
MarginLayoutParams layoutParams = (MarginLayoutParams) row.getLayoutParams();
layoutParams.setMarginStart(indentSize);
row.setLayoutParams(layoutParams);
} else {
rowBody.setPadding(indentSize, rowBody.getPaddingTop(), 0, rowBody.getPaddingBottom());
}

Loading…
Cancel
Save