diff --git a/app/src/main/java/it/niedermann/owncloud/notes/main/items/NoteViewHolder.java b/app/src/main/java/it/niedermann/owncloud/notes/main/items/NoteViewHolder.java index e3bbaa6d..15810817 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/main/items/NoteViewHolder.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/main/items/NoteViewHolder.java @@ -50,8 +50,8 @@ public abstract class NoteViewHolder extends RecyclerView.ViewHolder { @CallSuper public void bind(@NonNull DBNote note, boolean showCategory, int mainColor, int textColor, @Nullable CharSequence searchQuery) { - itemView.setOnClickListener((view) -> noteClickListener.onNoteClick(getAdapterPosition(), view)); - itemView.setOnLongClickListener((view) -> noteClickListener.onNoteLongClick(getAdapterPosition(), view)); + itemView.setOnClickListener((view) -> noteClickListener.onNoteClick(getLayoutPosition(), view)); + itemView.setOnLongClickListener((view) -> noteClickListener.onNoteLongClick(getLayoutPosition(), view)); } protected void bindStatus(AppCompatImageView noteStatus, DBStatus status, int mainColor) { @@ -106,7 +106,7 @@ public abstract class NoteViewHolder extends RecyclerView.ViewHolder { protected void bindFavorite(@NonNull ImageView noteFavorite, boolean isFavorite) { noteFavorite.setImageResource(isFavorite ? R.drawable.ic_star_yellow_24dp : R.drawable.ic_star_grey_ccc_24dp); - noteFavorite.setOnClickListener(view -> noteClickListener.onNoteFavoriteClick(getAdapterPosition(), view)); + noteFavorite.setOnClickListener(view -> noteClickListener.onNoteFavoriteClick(getLayoutPosition(), view)); } protected void bindSearchableContent(@NonNull Context context, @NonNull TextView textView, @Nullable CharSequence searchQuery, @NonNull String content, int mainColor) { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/main/items/list/NotesListViewItemTouchHelper.java b/app/src/main/java/it/niedermann/owncloud/notes/main/items/list/NotesListViewItemTouchHelper.java index 900e211f..ed4b28dc 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/main/items/list/NotesListViewItemTouchHelper.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/main/items/list/NotesListViewItemTouchHelper.java @@ -71,7 +71,7 @@ public class NotesListViewItemTouchHelper extends ItemTouchHelper { public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { switch (direction) { case ItemTouchHelper.LEFT: - final DBNote dbNoteWithoutContent = (DBNote) adapter.getItem(viewHolder.getAdapterPosition()); + final DBNote dbNoteWithoutContent = (DBNote) adapter.getItem(viewHolder.getLayoutPosition()); final DBNote dbNote = db.getNote(dbNoteWithoutContent.getAccountId(), dbNoteWithoutContent.getId()); db.deleteNoteAndSync(ssoAccount, dbNote.getId()); adapter.remove(dbNote); @@ -92,7 +92,7 @@ public class NotesListViewItemTouchHelper extends ItemTouchHelper { } break; case ItemTouchHelper.RIGHT: - final DBNote adapterNote = (DBNote) adapter.getItem(viewHolder.getAdapterPosition()); + final DBNote adapterNote = (DBNote) adapter.getItem(viewHolder.getLayoutPosition()); db.toggleFavorite(ssoAccount, adapterNote, syncCallBack); refreshLists.run(); break;