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)
|
||||
actMode?.invalidate()
|
||||
}
|
||||
|
||||
fun updateTitle(cnt: Int) {
|
||||
actMode?.title = "$cnt / ${mItems.size}"
|
||||
actMode?.invalidate()
|
||||
}
|
||||
|
||||
init {
|
||||
|
@ -86,6 +86,7 @@ class ItemsAdapter(val activity: SimpleActivity, var mItems: MutableList<FileDir
|
|||
R.id.cab_share -> shareFiles()
|
||||
R.id.cab_copy_to -> copyMoveTo(true)
|
||||
R.id.cab_move_to -> copyMoveTo(false)
|
||||
R.id.cab_select_all -> selectAll()
|
||||
R.id.cab_delete -> askConfirmDelete()
|
||||
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() {
|
||||
ConfirmationDialog(activity) {
|
||||
deleteFiles()
|
||||
|
@ -245,8 +255,6 @@ class ItemsAdapter(val activity: SimpleActivity, var mItems: MutableList<FileDir
|
|||
item_name.setTextColor(textColor)
|
||||
item_details.setTextColor(textColor)
|
||||
|
||||
// toggleItemSelection(this, selectedPositions.contains(pos), pos)
|
||||
|
||||
if (fileDirItem.isDirectory) {
|
||||
item_icon.setImageDrawable(folderDrawable)
|
||||
item_details.text = getChildrenCnt(fileDirItem)
|
||||
|
|
|
@ -24,6 +24,11 @@
|
|||
android:id="@+id/cab_move_to"
|
||||
android:title="@string/move_to"
|
||||
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
|
||||
android:id="@+id/cab_delete"
|
||||
android:icon="@drawable/ic_delete"
|
||||
|
|
Loading…
Reference in New Issue