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) {
if (multiSelector.isSelectable) {
val isSelected = adapterListener.getSelectedPositions().contains(layoutPosition)
adapterListener.toggleItemSelectionAdapter(!isSelected, layoutPosition)
val isSelected = adapterListener.getSelectedPositions().contains(adapterPosition)
adapterListener.toggleItemSelectionAdapter(!isSelected, adapterPosition)
} else {
itemClick(directory)
}
@ -431,10 +431,10 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
if (listener != null) {
if (!multiSelector.isSelectable) {
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) {
if (multiSelector.isSelectable) {
val isSelected = adapterListener.getSelectedPositions().contains(layoutPosition)
adapterListener.toggleItemSelectionAdapter(!isSelected, layoutPosition)
val isSelected = adapterListener.getSelectedPositions().contains(adapterPosition)
adapterListener.toggleItemSelectionAdapter(!isSelected, adapterPosition)
} else {
itemClick(medium)
}
@ -346,10 +346,10 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
if (listener != null) {
if (!multiSelector.isSelectable) {
activity.startSupportActionMode(multiSelectorCallback)
adapterListener.toggleItemSelectionAdapter(true, layoutPosition)
adapterListener.toggleItemSelectionAdapter(true, adapterPosition)
}
listener.itemLongClicked(layoutPosition)
listener.itemLongClicked(adapterPosition)
}
}