add properties dialog
This commit is contained in:
parent
7115330e97
commit
6e88949363
1 changed files with 18 additions and 0 deletions
|
@ -8,11 +8,13 @@ import com.bignerdranch.android.multiselector.MultiSelector
|
|||
import com.bignerdranch.android.multiselector.SwappingHolder
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import com.simplemobiletools.filemanager.Config
|
||||
import com.simplemobiletools.filemanager.R
|
||||
import com.simplemobiletools.filemanager.activities.SimpleActivity
|
||||
import com.simplemobiletools.filepicker.extensions.formatSize
|
||||
import com.simplemobiletools.filepicker.extensions.isGif
|
||||
import com.simplemobiletools.filepicker.models.FileDirItem
|
||||
import com.simplemobiletools.fileproperties.dialogs.PropertiesDialog
|
||||
import kotlinx.android.synthetic.main.list_item.view.*
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
@ -21,6 +23,7 @@ class ItemsAdapter(val activity: SimpleActivity, val mItems: List<FileDirItem>,
|
|||
RecyclerView.Adapter<ItemsAdapter.ViewHolder>() {
|
||||
val multiSelector = MultiSelector()
|
||||
val views = ArrayList<View>()
|
||||
val config = Config.newInstance(activity)
|
||||
|
||||
companion object {
|
||||
var actMode: ActionMode? = null
|
||||
|
@ -33,6 +36,10 @@ class ItemsAdapter(val activity: SimpleActivity, val mItems: List<FileDirItem>,
|
|||
val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {
|
||||
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
R.id.cab_properties -> {
|
||||
showProperties()
|
||||
true
|
||||
}
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
@ -52,6 +59,17 @@ class ItemsAdapter(val activity: SimpleActivity, val mItems: List<FileDirItem>,
|
|||
}
|
||||
}
|
||||
|
||||
private fun showProperties() {
|
||||
val selections = multiSelector.selectedPositions
|
||||
if (selections.size <= 1) {
|
||||
PropertiesDialog(activity, mItems[selections[0]].path, config.showHidden)
|
||||
} else {
|
||||
val paths = ArrayList<String>()
|
||||
selections.forEach { paths.add(mItems[it].path) }
|
||||
PropertiesDialog(activity, paths, config.showHidden)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder {
|
||||
val view = LayoutInflater.from(parent?.context).inflate(R.layout.list_item, parent, false)
|
||||
return ViewHolder(activity, view, itemClick)
|
||||
|
|
Loading…
Reference in a new issue