找不到解决办法我怎么能在房间里保存职位变动后?
@Query("SELECT * FROM notes WHERE id == :id")
Note getNoteId(int id);
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insertNote(Note note);
@Update
void update(Note note);
...
MainViewModel viewModel = new ViewModelProvider(this).get(MainViewModel.class);
viewModel.getNotes().observe(this, notes -> {
notesFromDB = new ArrayList<>(notes);
... 试过了没用
private final ItemTouchHelper.SimpleCallback simpleCallback =
new ItemTouchHelper.SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN |
ItemTouchHelper.RIGHT | ItemTouchHelper.LEFT, ItemTouchHelper.RIGHT | ItemTouchHelper.LEFT) {
@Override
public boolean onMove(@NonNull RecyclerView recyclerView,
@NonNull RecyclerView.ViewHolder viewHolder,
@NonNull RecyclerView.ViewHolder target) {
Note note = notesAdapter.getNoteAt(viewHolder.getAdapterPosition());
Collections.swap(notesFromDB, viewHolder.getAdapterPosition(), target.getAdapterPosition());
recyclerView.getAdapter().notifyItemMoved(viewHolder.getAdapterPosition(), target.getAdapterPosition());
App.getInstance().getNoteDao().update(note);
return true;
}
暂无答案!
目前还没有任何答案,快来回答吧!