mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 04:57:59 +01:00
use layoutPosition at directory and media adapters
This commit is contained in:
parent
7597efcba2
commit
aa16084192
2 changed files with 20 additions and 20 deletions
|
@ -336,7 +336,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
val dir = dirs[position]
|
val dir = dirs[position]
|
||||||
itemViews.put(position, holder.bindView(dir, pinnedFolders.contains(dir.path), scrollVertically, position))
|
itemViews.put(position, holder.bindView(dir, pinnedFolders.contains(dir.path), scrollVertically))
|
||||||
toggleItemSelection(selectedPositions.contains(position), position)
|
toggleItemSelection(selectedPositions.contains(position), position)
|
||||||
holder.itemView.tag = holder
|
holder.itemView.tag = holder
|
||||||
}
|
}
|
||||||
|
@ -395,7 +395,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
||||||
class ViewHolder(val view: View, val adapterListener: MyAdapterListener, val activity: SimpleActivity, val multiSelectorCallback: ModalMultiSelectorCallback,
|
class ViewHolder(val view: View, val adapterListener: MyAdapterListener, val activity: SimpleActivity, val multiSelectorCallback: ModalMultiSelectorCallback,
|
||||||
val multiSelector: MultiSelector, val listener: DirOperationsListener?, val isPickIntent: Boolean, val itemClick: (Directory) -> (Unit)) :
|
val multiSelector: MultiSelector, val listener: DirOperationsListener?, val isPickIntent: Boolean, val itemClick: (Directory) -> (Unit)) :
|
||||||
SwappingHolder(view, MultiSelector()) {
|
SwappingHolder(view, MultiSelector()) {
|
||||||
fun bindView(directory: Directory, isPinned: Boolean, scrollVertically: Boolean, position: Int): View {
|
fun bindView(directory: Directory, isPinned: Boolean, scrollVertically: Boolean): View {
|
||||||
itemView.apply {
|
itemView.apply {
|
||||||
dir_name.text = directory.name
|
dir_name.text = directory.name
|
||||||
photo_cnt.text = directory.mediaCnt.toString()
|
photo_cnt.text = directory.mediaCnt.toString()
|
||||||
|
@ -403,29 +403,29 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
||||||
dir_pin.beVisibleIf(isPinned)
|
dir_pin.beVisibleIf(isPinned)
|
||||||
dir_sd_card.beVisibleIf(activity.isPathOnSD(directory.path))
|
dir_sd_card.beVisibleIf(activity.isPathOnSD(directory.path))
|
||||||
|
|
||||||
setOnClickListener { viewClicked(directory, position) }
|
setOnClickListener { viewClicked(directory) }
|
||||||
setOnLongClickListener { if (isPickIntent) viewClicked(directory, position) else viewLongClicked(position); true }
|
setOnLongClickListener { if (isPickIntent) viewClicked(directory) else viewLongClicked(); true }
|
||||||
}
|
}
|
||||||
return itemView
|
return itemView
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun viewClicked(directory: Directory, position: Int) {
|
private fun viewClicked(directory: Directory) {
|
||||||
if (multiSelector.isSelectable) {
|
if (multiSelector.isSelectable) {
|
||||||
val isSelected = adapterListener.getSelectedPositions().contains(position)
|
val isSelected = adapterListener.getSelectedPositions().contains(layoutPosition)
|
||||||
adapterListener.toggleItemSelectionAdapter(!isSelected, position)
|
adapterListener.toggleItemSelectionAdapter(!isSelected, layoutPosition)
|
||||||
} else {
|
} else {
|
||||||
itemClick(directory)
|
itemClick(directory)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun viewLongClicked(position: Int) {
|
private fun viewLongClicked() {
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
if (!multiSelector.isSelectable) {
|
if (!multiSelector.isSelectable) {
|
||||||
activity.startSupportActionMode(multiSelectorCallback)
|
activity.startSupportActionMode(multiSelectorCallback)
|
||||||
adapterListener.toggleItemSelectionAdapter(true, position)
|
adapterListener.toggleItemSelectionAdapter(true, layoutPosition)
|
||||||
}
|
}
|
||||||
|
|
||||||
listener.itemLongClicked(position)
|
listener.itemLongClicked(layoutPosition)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -251,7 +251,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
itemViews.put(position, holder.bindView(media[position], displayFilenames, scrollVertically, position))
|
itemViews.put(position, holder.bindView(media[position], displayFilenames, scrollVertically))
|
||||||
toggleItemSelection(selectedPositions.contains(position), position)
|
toggleItemSelection(selectedPositions.contains(position), position)
|
||||||
holder.itemView.tag = holder
|
holder.itemView.tag = holder
|
||||||
}
|
}
|
||||||
|
@ -315,36 +315,36 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
class ViewHolder(val view: View, val adapterListener: MyAdapterListener, val activity: SimpleActivity, val multiSelectorCallback: ModalMultiSelectorCallback,
|
class ViewHolder(val view: View, val adapterListener: MyAdapterListener, val activity: SimpleActivity, val multiSelectorCallback: ModalMultiSelectorCallback,
|
||||||
val multiSelector: MultiSelector, val listener: MediaOperationsListener?, val isPickIntent: Boolean, val itemClick: (Medium) -> (Unit)) :
|
val multiSelector: MultiSelector, val listener: MediaOperationsListener?, val isPickIntent: Boolean, val itemClick: (Medium) -> (Unit)) :
|
||||||
SwappingHolder(view, MultiSelector()) {
|
SwappingHolder(view, MultiSelector()) {
|
||||||
fun bindView(medium: Medium, displayFilenames: Boolean, scrollVertically: Boolean, position: Int): View {
|
fun bindView(medium: Medium, displayFilenames: Boolean, scrollVertically: Boolean): View {
|
||||||
itemView.apply {
|
itemView.apply {
|
||||||
play_outline.visibility = if (medium.video) View.VISIBLE else View.GONE
|
play_outline.visibility = if (medium.video) View.VISIBLE else View.GONE
|
||||||
photo_name.beVisibleIf(displayFilenames)
|
photo_name.beVisibleIf(displayFilenames)
|
||||||
photo_name.text = medium.name
|
photo_name.text = medium.name
|
||||||
activity.loadImage(medium.path, medium_thumbnail, scrollVertically)
|
activity.loadImage(medium.path, medium_thumbnail, scrollVertically)
|
||||||
|
|
||||||
setOnClickListener { viewClicked(medium, position) }
|
setOnClickListener { viewClicked(medium) }
|
||||||
setOnLongClickListener { if (isPickIntent) viewClicked(medium, position) else viewLongClicked(position); true }
|
setOnLongClickListener { if (isPickIntent) viewClicked(medium) else viewLongClicked(); true }
|
||||||
}
|
}
|
||||||
return itemView
|
return itemView
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun viewClicked(medium: Medium, position: Int) {
|
private fun viewClicked(medium: Medium) {
|
||||||
if (multiSelector.isSelectable) {
|
if (multiSelector.isSelectable) {
|
||||||
val isSelected = adapterListener.getSelectedPositions().contains(position)
|
val isSelected = adapterListener.getSelectedPositions().contains(layoutPosition)
|
||||||
adapterListener.toggleItemSelectionAdapter(!isSelected, position)
|
adapterListener.toggleItemSelectionAdapter(!isSelected, layoutPosition)
|
||||||
} else {
|
} else {
|
||||||
itemClick(medium)
|
itemClick(medium)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun viewLongClicked(position: Int) {
|
private fun viewLongClicked() {
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
if (!multiSelector.isSelectable) {
|
if (!multiSelector.isSelectable) {
|
||||||
activity.startSupportActionMode(multiSelectorCallback)
|
activity.startSupportActionMode(multiSelectorCallback)
|
||||||
adapterListener.toggleItemSelectionAdapter(true, position)
|
adapterListener.toggleItemSelectionAdapter(true, layoutPosition)
|
||||||
}
|
}
|
||||||
|
|
||||||
listener.itemLongClicked(position)
|
listener.itemLongClicked(layoutPosition)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue