add a Select All button
This commit is contained in:
parent
dc595c5a0e
commit
9d17c5a568
|
@ -56,11 +56,11 @@ class ItemsAdapter(val activity: SimpleActivity, var mItems: MutableList<FileDir
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTitle(selectedPositions.size)
|
updateTitle(selectedPositions.size)
|
||||||
actMode?.invalidate()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateTitle(cnt: Int) {
|
fun updateTitle(cnt: Int) {
|
||||||
actMode?.title = "$cnt / ${mItems.size}"
|
actMode?.title = "$cnt / ${mItems.size}"
|
||||||
|
actMode?.invalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
@ -86,6 +86,7 @@ class ItemsAdapter(val activity: SimpleActivity, var mItems: MutableList<FileDir
|
||||||
R.id.cab_share -> shareFiles()
|
R.id.cab_share -> shareFiles()
|
||||||
R.id.cab_copy_to -> copyMoveTo(true)
|
R.id.cab_copy_to -> copyMoveTo(true)
|
||||||
R.id.cab_move_to -> copyMoveTo(false)
|
R.id.cab_move_to -> copyMoveTo(false)
|
||||||
|
R.id.cab_select_all -> selectAll()
|
||||||
R.id.cab_delete -> askConfirmDelete()
|
R.id.cab_delete -> askConfirmDelete()
|
||||||
else -> return false
|
else -> return false
|
||||||
}
|
}
|
||||||
|
@ -168,6 +169,15 @@ class ItemsAdapter(val activity: SimpleActivity, var mItems: MutableList<FileDir
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun selectAll() {
|
||||||
|
val cnt = mItems.size
|
||||||
|
for (i in 0..cnt - 1) {
|
||||||
|
selectedPositions.add(i)
|
||||||
|
notifyItemChanged(i)
|
||||||
|
}
|
||||||
|
updateTitle(cnt)
|
||||||
|
}
|
||||||
|
|
||||||
private fun askConfirmDelete() {
|
private fun askConfirmDelete() {
|
||||||
ConfirmationDialog(activity) {
|
ConfirmationDialog(activity) {
|
||||||
deleteFiles()
|
deleteFiles()
|
||||||
|
@ -245,8 +255,6 @@ class ItemsAdapter(val activity: SimpleActivity, var mItems: MutableList<FileDir
|
||||||
item_name.setTextColor(textColor)
|
item_name.setTextColor(textColor)
|
||||||
item_details.setTextColor(textColor)
|
item_details.setTextColor(textColor)
|
||||||
|
|
||||||
// toggleItemSelection(this, selectedPositions.contains(pos), pos)
|
|
||||||
|
|
||||||
if (fileDirItem.isDirectory) {
|
if (fileDirItem.isDirectory) {
|
||||||
item_icon.setImageDrawable(folderDrawable)
|
item_icon.setImageDrawable(folderDrawable)
|
||||||
item_details.text = getChildrenCnt(fileDirItem)
|
item_details.text = getChildrenCnt(fileDirItem)
|
||||||
|
|
|
@ -24,6 +24,11 @@
|
||||||
android:id="@+id/cab_move_to"
|
android:id="@+id/cab_move_to"
|
||||||
android:title="@string/move_to"
|
android:title="@string/move_to"
|
||||||
app:showAsAction="never"/>
|
app:showAsAction="never"/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/cab_select_all"
|
||||||
|
android:icon="@drawable/ic_select_all"
|
||||||
|
android:title="@string/select_all"
|
||||||
|
app:showAsAction="ifRoom"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/cab_delete"
|
android:id="@+id/cab_delete"
|
||||||
android:icon="@drawable/ic_delete"
|
android:icon="@drawable/ic_delete"
|
||||||
|
|
Loading…
Reference in New Issue