-
Notifications
You must be signed in to change notification settings - Fork 306
Closed
Labels
more info requiredFurther information is requestedFurther information is requested
Description
And how can I actually update an existing list in the database, for example, the elements are interchanged? In the put method, I pass a list with the same elements, only the position in the list is changed, but still when the application is restarted, it issues the order that was originally.
###Code
@Override
public void onItemMove(int oldPosition, int newPosition) {
// Note targetNote = dataset.get(oldPosition);
// Note note = new Note(targetNote);
// dataset.remove(oldPosition);
// dataset.add(newPosition, note);
// notifyItemMoved(oldPosition, newPosition);
if (oldPosition < newPosition) {
for (int i = oldPosition; i < newPosition; i++) {
Collections.swap(dataset, i, i + 1);
}
} else {
for (int i = oldPosition; i > newPosition; i--) {
Collections.swap(dataset, i, i - 1);
}
}
notesBox.put(dataset);
// dataset.clear();
// dataset.addAll(noteQuery.find());
notifyItemMoved(oldPosition, newPosition);
// notifyDataSetChanged();
}
Metadata
Metadata
Assignees
Labels
more info requiredFurther information is requestedFurther information is requested