diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/adapters/ItemsAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/adapters/ItemsAdapter.kt index a5c177b6..ca60c678 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/adapters/ItemsAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/adapters/ItemsAdapter.kt @@ -27,6 +27,7 @@ import com.simplemobiletools.filemanager.pro.dialogs.CompressAsDialog import com.simplemobiletools.filemanager.pro.extensions.* import com.simplemobiletools.filemanager.pro.helpers.* import com.simplemobiletools.filemanager.pro.interfaces.ItemOperationsListener +import com.simplemobiletools.filemanager.pro.models.ListItem import com.stericson.RootTools.RootTools import kotlinx.android.synthetic.main.list_item.view.* import java.io.Closeable @@ -37,7 +38,7 @@ import java.util.zip.ZipEntry import java.util.zip.ZipFile import java.util.zip.ZipOutputStream -class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList, val listener: ItemOperationsListener?, recyclerView: MyRecyclerView, +class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList, val listener: ItemOperationsListener?, recyclerView: MyRecyclerView, val isPickMultipleIntent: Boolean, fastScroller: FastScroller, itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) { @@ -94,7 +95,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList - fun updateItems(newItems: ArrayList, highlightText: String = "") { + fun updateItems(newItems: ArrayList, highlightText: String = "") { if (newItems.hashCode() != currentItemsHash) { currentItemsHash = newItems.hashCode() textToHighlight = highlightText - fileDirItems = newItems.clone() as ArrayList + fileDirItems = newItems.clone() as ArrayList notifyDataSetChanged() finishActMode() } else if (textToHighlight != highlightText) { @@ -552,7 +553,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList): ArrayList { + val listItems = ArrayList() + fileDirItems.forEach { + val listItem = ListItem(it.path, it.name, it.isDirectory, it.children, it.size, false) + listItems.add(listItem) + } + return listItems + } + private fun itemClicked(item: FileDirItem) { if (item.isDirectory) { (activity as? MainActivity)?.apply { @@ -256,7 +266,7 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb mView.apply { if (items_list.isGone()) { items_list.beVisible() - getRecyclerAdapter()?.updateItems(storedItems) + getRecyclerAdapter()?.updateItems(getListItemsFromFileDirItems(storedItems)) } items_placeholder.beGone() items_placeholder_2.beGone() @@ -274,7 +284,7 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb fileDirItems.addAll(searchFiles(searchText, currentPath)) activity?.runOnUiThread { - getRecyclerAdapter()?.updateItems(fileDirItems, text) + getRecyclerAdapter()?.updateItems(getListItemsFromFileDirItems(fileDirItems), text) mView.apply { items_list.beVisibleIf(fileDirItems.isNotEmpty()) items_placeholder.beVisibleIf(fileDirItems.isEmpty()) @@ -311,7 +321,7 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb fun searchClosed() { isSearchOpen = false if (!skipItemUpdating) { - getRecyclerAdapter()?.updateItems(storedItems) + getRecyclerAdapter()?.updateItems(getListItemsFromFileDirItems(storedItems)) } skipItemUpdating = false } diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/models/ListItem.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/models/ListItem.kt new file mode 100644 index 00000000..d09b31c6 --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/models/ListItem.kt @@ -0,0 +1,8 @@ +package com.simplemobiletools.filemanager.pro.models + +import com.simplemobiletools.commons.models.FileDirItem + +data class ListItem(val mPath: String, val mName: String = "", var mIsDirectory: Boolean = false, var mChildren: Int = 0, var mSize: Long = 0L, var isSectionTitle: Boolean) + : FileDirItem(mPath, mName, mIsDirectory, mChildren, mSize) { + +}