set image select state only after its already init

This commit is contained in:
tibbi 2017-05-14 17:29:02 +02:00
parent ae6b53d464
commit 311d28242f
2 changed files with 4 additions and 4 deletions

View file

@ -312,6 +312,7 @@ class DirectoryAdapter(val activity: SimpleActivity, val 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(activity, multiSelectorMode, multiSelector, dir, position, pinnedFolders.contains(dir.path), listener)) itemViews.put(position, holder.bindView(activity, multiSelectorMode, multiSelector, dir, position, pinnedFolders.contains(dir.path), listener))
toggleItemSelection(selectedPositions.contains(position), position)
holder.itemView.tag = holder holder.itemView.tag = holder
} }
@ -368,7 +369,6 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
dir_name.text = directory.name dir_name.text = directory.name
photo_cnt.text = directory.mediaCnt.toString() photo_cnt.text = directory.mediaCnt.toString()
dir_pin.visibility = if (isPinned) View.VISIBLE else View.GONE dir_pin.visibility = if (isPinned) View.VISIBLE else View.GONE
adapter.toggleItemSelectionAdapter(adapter.getSelectedPositions().contains(pos), pos)
activity.loadImage(directory.tmb, dir_thumbnail) activity.loadImage(directory.tmb, dir_thumbnail)
setOnClickListener { viewClicked(multiSelector, directory, pos) } setOnClickListener { viewClicked(multiSelector, directory, pos) }
@ -391,7 +391,7 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
fun viewClicked(multiSelector: MultiSelector, directory: Directory, pos: Int) { fun viewClicked(multiSelector: MultiSelector, directory: Directory, pos: Int) {
if (multiSelector.isSelectable) { if (multiSelector.isSelectable) {
val isSelected = adapter.getSelectedPositions().contains(layoutPosition) val isSelected = adapter.getSelectedPositions().contains(pos)
adapter.toggleItemSelectionAdapter(!isSelected, pos) adapter.toggleItemSelectionAdapter(!isSelected, pos)
} else { } else {
itemClick(directory) itemClick(directory)

View file

@ -249,6 +249,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(activity, multiSelectorMode, multiSelector, media[position], position, listener, displayFilenames)) itemViews.put(position, holder.bindView(activity, multiSelectorMode, multiSelector, media[position], position, listener, displayFilenames))
toggleItemSelection(selectedPositions.contains(position), position)
holder.itemView.tag = holder holder.itemView.tag = holder
} }
@ -315,7 +316,6 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
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
adapter.toggleItemSelectionAdapter(adapter.getSelectedPositions().contains(pos), pos)
activity.loadImage(medium.path, medium_thumbnail) activity.loadImage(medium.path, medium_thumbnail)
setOnClickListener { viewClicked(multiSelector, medium, pos) } setOnClickListener { viewClicked(multiSelector, medium, pos) }
@ -338,7 +338,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
fun viewClicked(multiSelector: MultiSelector, medium: Medium, pos: Int) { fun viewClicked(multiSelector: MultiSelector, medium: Medium, pos: Int) {
if (multiSelector.isSelectable) { if (multiSelector.isSelectable) {
val isSelected = adapter.getSelectedPositions().contains(layoutPosition) val isSelected = adapter.getSelectedPositions().contains(pos)
adapter.toggleItemSelectionAdapter(!isSelected, pos) adapter.toggleItemSelectionAdapter(!isSelected, pos)
} else { } else {
itemClick(medium) itemClick(medium)