clear selection at updating items

This commit is contained in:
tibbi 2017-10-29 10:44:08 +01:00
parent 4493d9aaa0
commit 30bd5dc250

View file

@ -52,10 +52,11 @@ class ItemsAdapter(val activity: SimpleActivity, var mItems: MutableList<FileDir
lateinit private var fileDrawable: Drawable lateinit private var fileDrawable: Drawable
fun toggleItemSelection(select: Boolean, pos: Int) { fun toggleItemSelection(select: Boolean, pos: Int) {
itemViews[pos]?.item_frame?.isSelected = select
if (select) { if (select) {
selectedPositions.add(pos) if (itemViews[pos] != null) {
itemViews[pos].item_frame?.isSelected = select
selectedPositions.add(pos)
}
} else { } else {
selectedPositions.remove(pos) selectedPositions.remove(pos)
} }
@ -433,6 +434,7 @@ class ItemsAdapter(val activity: SimpleActivity, var mItems: MutableList<FileDir
fun updateItems(newItems: MutableList<FileDirItem>) { fun updateItems(newItems: MutableList<FileDirItem>) {
mItems = newItems mItems = newItems
notifyDataSetChanged() notifyDataSetChanged()
actMode?.finish()
} }
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder { override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder {