pull/156/head
M66B 6 years ago
parent ad07bda9d6
commit 68ae1dbafc

@ -67,7 +67,6 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
private LayoutInflater inflater;
private LifecycleOwner owner;
private boolean show_hidden;
private boolean reorder = false;
private long account;
private int level;
@ -372,9 +371,6 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
@Override
public boolean onLongClick(View v) {
if (reorder)
return false;
int pos = getAdapterPosition();
if (pos == RecyclerView.NO_POSITION)
return false;
@ -701,10 +697,6 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
}
}
void setReorder(boolean reorder) {
this.reorder = reorder;
}
private class DiffCallback extends DiffUtil.Callback {
private List<TupleFolderEx> prev = new ArrayList<>();
private List<TupleFolderEx> next = new ArrayList<>();
@ -749,51 +741,6 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
return items.size();
}
void onMove(int from, int to) {
if (from < 0 || from >= items.size() ||
to < 0 || to >= items.size())
return;
if (from < to)
for (int i = from; i < to; i++)
Collections.swap(items, i, i + 1);
else
for (int i = from; i > to; i--)
Collections.swap(items, i, i - 1);
notifyItemMoved(from, to);
List<Long> order = new ArrayList<>();
for (int i = 0; i < items.size(); i++)
order.add(items.get(i).id);
Bundle args = new Bundle();
args.putLongArray("order", Helper.toLongArray(order));
new SimpleTask<Void>() {
@Override
protected Void onExecute(Context context, Bundle args) {
final long[] order = args.getLongArray("order");
final DB db = DB.getInstance(context);
db.runInTransaction(new Runnable() {
@Override
public void run() {
for (int i = 0; i < order.length; i++)
db.folder().setFolderOrder(order[i], i);
}
});
return null;
}
@Override
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(context, owner, ex);
}
}.execute(context, owner, args, "folders:order");
}
@Override
@NonNull
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {

Loading…
Cancel
Save