try using adapterPosition instead of layoutPosition in recyclerView adapters

This commit is contained in:
tibbi 2017-09-30 20:24:18 +02:00
parent 16eb8cde3f
commit 73bcad0f68
2 changed files with 8 additions and 8 deletions

View file

@ -420,8 +420,8 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
private fun viewClicked(directory: Directory) { private fun viewClicked(directory: Directory) {
if (multiSelector.isSelectable) { if (multiSelector.isSelectable) {
val isSelected = adapterListener.getSelectedPositions().contains(layoutPosition) val isSelected = adapterListener.getSelectedPositions().contains(adapterPosition)
adapterListener.toggleItemSelectionAdapter(!isSelected, layoutPosition) adapterListener.toggleItemSelectionAdapter(!isSelected, adapterPosition)
} else { } else {
itemClick(directory) itemClick(directory)
} }
@ -431,10 +431,10 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
if (listener != null) { if (listener != null) {
if (!multiSelector.isSelectable) { if (!multiSelector.isSelectable) {
activity.startSupportActionMode(multiSelectorCallback) activity.startSupportActionMode(multiSelectorCallback)
adapterListener.toggleItemSelectionAdapter(true, layoutPosition) adapterListener.toggleItemSelectionAdapter(true, adapterPosition)
} }
listener.itemLongClicked(layoutPosition) listener.itemLongClicked(adapterPosition)
} }
} }

View file

@ -335,8 +335,8 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
private fun viewClicked(medium: Medium) { private fun viewClicked(medium: Medium) {
if (multiSelector.isSelectable) { if (multiSelector.isSelectable) {
val isSelected = adapterListener.getSelectedPositions().contains(layoutPosition) val isSelected = adapterListener.getSelectedPositions().contains(adapterPosition)
adapterListener.toggleItemSelectionAdapter(!isSelected, layoutPosition) adapterListener.toggleItemSelectionAdapter(!isSelected, adapterPosition)
} else { } else {
itemClick(medium) itemClick(medium)
} }
@ -346,10 +346,10 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
if (listener != null) { if (listener != null) {
if (!multiSelector.isSelectable) { if (!multiSelector.isSelectable) {
activity.startSupportActionMode(multiSelectorCallback) activity.startSupportActionMode(multiSelectorCallback)
adapterListener.toggleItemSelectionAdapter(true, layoutPosition) adapterListener.toggleItemSelectionAdapter(true, adapterPosition)
} }
listener.itemLongClicked(layoutPosition) listener.itemLongClicked(adapterPosition)
} }
} }