From 6e88949363bfa61c15d1189a94357fe34e83f744 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 20 Nov 2016 19:12:11 +0100 Subject: [PATCH] add properties dialog --- .../filemanager/adapters/ItemsAdapter.kt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt index 3c375497..9d466745 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt @@ -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, RecyclerView.Adapter() { val multiSelector = MultiSelector() val views = ArrayList() + val config = Config.newInstance(activity) companion object { var actMode: ActionMode? = null @@ -33,6 +36,10 @@ class ItemsAdapter(val activity: SimpleActivity, val mItems: List, 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, } } + private fun showProperties() { + val selections = multiSelector.selectedPositions + if (selections.size <= 1) { + PropertiesDialog(activity, mItems[selections[0]].path, config.showHidden) + } else { + val paths = ArrayList() + 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)