allow opening folders from search results
This commit is contained in:
parent
1308e1b434
commit
b2f65a448e
|
@ -160,7 +160,7 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
|
|||
|
||||
override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) {
|
||||
val fileDirItem = listItems[position]
|
||||
holder.bindView(fileDirItem, !fileDirItem.isSectionTitle, !fileDirItem.isSectionTitle) { itemView, layoutPosition ->
|
||||
holder.bindView(fileDirItem, true, !fileDirItem.isSectionTitle) { itemView, layoutPosition ->
|
||||
setupView(itemView, fileDirItem)
|
||||
}
|
||||
bindViewHolder(holder)
|
||||
|
|
|
@ -175,7 +175,12 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
|
|||
|
||||
storedItems = items
|
||||
ItemsAdapter(activity as SimpleActivity, storedItems, this@ItemsFragment, items_list, isPickMultipleIntent, items_fastscroller) {
|
||||
itemClicked(it as FileDirItem)
|
||||
if ((it as? ListItem)?.isSectionTitle == true) {
|
||||
openDirectory(it.mPath)
|
||||
searchClosed()
|
||||
} else {
|
||||
itemClicked(it as FileDirItem)
|
||||
}
|
||||
}.apply {
|
||||
setupZoomListener(zoomListener)
|
||||
items_list.adapter = this
|
||||
|
@ -278,11 +283,7 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
|
|||
|
||||
private fun itemClicked(item: FileDirItem) {
|
||||
if (item.isDirectory) {
|
||||
(activity as? MainActivity)?.apply {
|
||||
skipItemUpdating = isSearchOpen
|
||||
openedDirectory()
|
||||
}
|
||||
openPath(item.path)
|
||||
openDirectory(item.path)
|
||||
} else {
|
||||
val path = item.path
|
||||
if (isGetContentIntent) {
|
||||
|
@ -299,6 +300,14 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
|
|||
}
|
||||
}
|
||||
|
||||
private fun openDirectory(path: String) {
|
||||
(activity as? MainActivity)?.apply {
|
||||
skipItemUpdating = isSearchOpen
|
||||
openedDirectory()
|
||||
}
|
||||
openPath(path)
|
||||
}
|
||||
|
||||
fun searchQueryChanged(text: String) {
|
||||
val searchText = text.trim()
|
||||
lastSearchedText = searchText
|
||||
|
@ -337,7 +346,8 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
|
|||
files.forEach {
|
||||
val parent = it.mPath.getParentPath()
|
||||
if (parent != previousParent && context != null) {
|
||||
listItems.add(ListItem("", context!!.humanizePath(parent), false, 0, 0, 0, true))
|
||||
val sectionTitle = ListItem(parent, context!!.humanizePath(parent), false, 0, 0, 0, true)
|
||||
listItems.add(sectionTitle)
|
||||
previousParent = parent
|
||||
}
|
||||
listItems.add(it)
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
android:id="@+id/item_section"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingStart="@dimen/normal_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:paddingEnd="@dimen/normal_margin"
|
||||
|
|
Loading…
Reference in New Issue