|
|
|
@ -1,8 +1,10 @@
|
|
|
|
package org.tasks.tasklist;
|
|
|
|
package org.tasks.tasklist;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.os.Parcelable;
|
|
|
|
import androidx.paging.AsyncPagedListDiffer;
|
|
|
|
import androidx.paging.AsyncPagedListDiffer;
|
|
|
|
import androidx.paging.PagedList;
|
|
|
|
import androidx.paging.PagedList;
|
|
|
|
import androidx.recyclerview.widget.AsyncDifferConfig;
|
|
|
|
import androidx.recyclerview.widget.AsyncDifferConfig;
|
|
|
|
|
|
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
|
|
import com.todoroo.astrid.activity.TaskListFragment;
|
|
|
|
import com.todoroo.astrid.activity.TaskListFragment;
|
|
|
|
import com.todoroo.astrid.adapter.TaskAdapter;
|
|
|
|
import com.todoroo.astrid.adapter.TaskAdapter;
|
|
|
|
import com.todoroo.astrid.dao.TaskDao;
|
|
|
|
import com.todoroo.astrid.dao.TaskDao;
|
|
|
|
@ -11,15 +13,18 @@ import org.tasks.data.TaskContainer;
|
|
|
|
|
|
|
|
|
|
|
|
public class PagedListRecyclerAdapter extends TaskListRecyclerAdapter {
|
|
|
|
public class PagedListRecyclerAdapter extends TaskListRecyclerAdapter {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final RecyclerView recyclerView;
|
|
|
|
private AsyncPagedListDiffer<TaskContainer> differ;
|
|
|
|
private AsyncPagedListDiffer<TaskContainer> differ;
|
|
|
|
|
|
|
|
|
|
|
|
public PagedListRecyclerAdapter(
|
|
|
|
public PagedListRecyclerAdapter(
|
|
|
|
TaskAdapter adapter,
|
|
|
|
TaskAdapter adapter,
|
|
|
|
|
|
|
|
RecyclerView recyclerView,
|
|
|
|
ViewHolderFactory viewHolderFactory,
|
|
|
|
ViewHolderFactory viewHolderFactory,
|
|
|
|
TaskListFragment taskList,
|
|
|
|
TaskListFragment taskList,
|
|
|
|
List<TaskContainer> list,
|
|
|
|
List<TaskContainer> list,
|
|
|
|
TaskDao taskDao) {
|
|
|
|
TaskDao taskDao) {
|
|
|
|
super(adapter, viewHolderFactory, taskList, taskDao);
|
|
|
|
super(adapter, viewHolderFactory, taskList, taskDao);
|
|
|
|
|
|
|
|
this.recyclerView = recyclerView;
|
|
|
|
differ =
|
|
|
|
differ =
|
|
|
|
new AsyncPagedListDiffer<>(
|
|
|
|
new AsyncPagedListDiffer<>(
|
|
|
|
this, new AsyncDifferConfig.Builder<>(new ItemCallback()).build());
|
|
|
|
this, new AsyncDifferConfig.Builder<>(new ItemCallback()).build());
|
|
|
|
@ -37,6 +42,15 @@ public class PagedListRecyclerAdapter extends TaskListRecyclerAdapter {
|
|
|
|
differ.submitList((PagedList<TaskContainer>) list);
|
|
|
|
differ.submitList((PagedList<TaskContainer>) list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onMoved(int fromPosition, int toPosition) {
|
|
|
|
|
|
|
|
Parcelable recyclerViewState = recyclerView.getLayoutManager().onSaveInstanceState();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
super.onMoved(fromPosition, toPosition);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
recyclerView.getLayoutManager().onRestoreInstanceState(recyclerViewState);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public int getItemCount() {
|
|
|
|
public int getItemCount() {
|
|
|
|
return differ.getItemCount();
|
|
|
|
return differ.getItemCount();
|
|
|
|
|