method renaming and reformat
This commit is contained in:
parent
627bbb519a
commit
781870e732
4 changed files with 37 additions and 46 deletions
|
@ -465,9 +465,9 @@ class ItemsAdapter(
|
|||
|
||||
CompressAsDialog(activity, firstPath) {
|
||||
val destination = it
|
||||
activity.handlePrimaryAndroidSAFDialog(firstPath) { granted ->
|
||||
activity.handleAndroidSAFDialog(firstPath) { granted ->
|
||||
if (!granted) {
|
||||
return@handlePrimaryAndroidSAFDialog
|
||||
return@handleAndroidSAFDialog
|
||||
}
|
||||
activity.handleSAFDialog(firstPath) {
|
||||
if (!it) {
|
||||
|
|
|
@ -53,10 +53,10 @@ class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val ca
|
|||
when {
|
||||
isRPlus() || path.startsWith(activity.internalStoragePath, true) -> {
|
||||
if (activity.isRestrictedSAFOnlyRoot(path)) {
|
||||
activity.handlePrimaryAndroidSAFDialog(path) {
|
||||
activity.handleAndroidSAFDialog(path) {
|
||||
if (!it) {
|
||||
callback(false)
|
||||
return@handlePrimaryAndroidSAFDialog
|
||||
return@handleAndroidSAFDialog
|
||||
}
|
||||
if (activity.createAndroidSAFDirectory(path)) {
|
||||
success(alertDialog)
|
||||
|
@ -103,10 +103,10 @@ class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val ca
|
|||
try {
|
||||
when {
|
||||
activity.isRestrictedSAFOnlyRoot(path) -> {
|
||||
activity.handlePrimaryAndroidSAFDialog(path) {
|
||||
activity.handleAndroidSAFDialog(path) {
|
||||
if (!it) {
|
||||
callback(false)
|
||||
return@handlePrimaryAndroidSAFDialog
|
||||
return@handleAndroidSAFDialog
|
||||
}
|
||||
if (activity.createAndroidSAFFile(path)) {
|
||||
success(alertDialog)
|
||||
|
|
|
@ -162,7 +162,18 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||
ensureBackgroundThread {
|
||||
if (activity?.isDestroyed == false && activity?.isFinishing == false) {
|
||||
val config = context!!.config
|
||||
if (context!!.isPathOnOTG(path) && config.OTGTreeUri.isNotEmpty()) {
|
||||
if (context.isRestrictedSAFOnlyRoot(path)) {
|
||||
activity?.handleAndroidSAFDialog(path) {
|
||||
if (!it) {
|
||||
activity?.toast(R.string.no_storage_permissions)
|
||||
return@handleAndroidSAFDialog
|
||||
}
|
||||
val getProperChildCount = context!!.config.getFolderViewType(currentPath) == VIEW_TYPE_LIST
|
||||
context.getAndroidSAFFileItems(path, context.config.shouldShowHidden, getProperChildCount) { fileItems ->
|
||||
callback(path, getListItemsFromFileDirItems(fileItems))
|
||||
}
|
||||
}
|
||||
} else if (context!!.isPathOnOTG(path) && config.OTGTreeUri.isNotEmpty()) {
|
||||
val getProperFileSize = context!!.config.getFolderSorting(currentPath) and SORT_BY_SIZE != 0
|
||||
context!!.getOTGItems(path, config.shouldShowHidden, getProperFileSize) {
|
||||
callback(path, getListItemsFromFileDirItems(it))
|
||||
|
@ -178,52 +189,33 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||
|
||||
private fun getRegularItemsOf(path: String, callback: (originalPath: String, items: ArrayList<ListItem>) -> Unit) {
|
||||
val items = ArrayList<ListItem>()
|
||||
|
||||
if (context == null) {
|
||||
val files = File(path).listFiles()?.filterNotNull()
|
||||
if (context == null || files == null) {
|
||||
callback(path, items)
|
||||
return
|
||||
}
|
||||
|
||||
val isSortingBySize = context!!.config.getFolderSorting(currentPath) and SORT_BY_SIZE != 0
|
||||
val getProperChildCount = context!!.config.getFolderViewType(currentPath) == VIEW_TYPE_LIST
|
||||
val lastModifieds = context!!.getFolderLastModifieds(path)
|
||||
|
||||
if (context.isRestrictedSAFOnlyRoot(path)) {
|
||||
activity?.handlePrimaryAndroidSAFDialog(path) {
|
||||
if (!it) {
|
||||
activity?.toast(R.string.no_storage_permissions)
|
||||
return@handlePrimaryAndroidSAFDialog
|
||||
}
|
||||
|
||||
context.getAndroidSAFFileItems(path, context.config.shouldShowHidden, getProperChildCount) { fileItems ->
|
||||
callback(path, getListItemsFromFileDirItems(fileItems))
|
||||
}
|
||||
for (file in files) {
|
||||
val fileDirItem = getFileDirItemFromFile(file, isSortingBySize, lastModifieds, false)
|
||||
if (fileDirItem != null) {
|
||||
items.add(fileDirItem)
|
||||
}
|
||||
} else {
|
||||
val files = File(path).listFiles()?.filterNotNull()
|
||||
if (files == null) {
|
||||
callback(path, items)
|
||||
return
|
||||
}
|
||||
val lastModifieds = context!!.getFolderLastModifieds(path)
|
||||
}
|
||||
|
||||
for (file in files) {
|
||||
val fileDirItem = getFileDirItemFromFile(file, isSortingBySize, lastModifieds, false)
|
||||
if (fileDirItem != null) {
|
||||
items.add(fileDirItem)
|
||||
}
|
||||
}
|
||||
// send out the initial item list asap, get proper child count asynchronously as it can be slow
|
||||
callback(path, items)
|
||||
|
||||
// send out the initial item list asap, get proper child count asynchronously as it can be slow
|
||||
callback(path, items)
|
||||
|
||||
if (getProperChildCount) {
|
||||
items.filter { it.mIsDirectory }.forEach {
|
||||
if (context != null) {
|
||||
val childrenCount = it.getDirectChildrenCount(activity as BaseSimpleActivity, showHidden)
|
||||
if (childrenCount != 0) {
|
||||
activity?.runOnUiThread {
|
||||
getRecyclerAdapter()?.updateChildCount(it.mPath, childrenCount)
|
||||
}
|
||||
if (getProperChildCount) {
|
||||
items.filter { it.mIsDirectory }.forEach {
|
||||
if (context != null) {
|
||||
val childrenCount = it.getDirectChildrenCount(activity as BaseSimpleActivity, showHidden)
|
||||
if (childrenCount != 0) {
|
||||
activity?.runOnUiThread {
|
||||
getRecyclerAdapter()?.updateChildCount(it.mPath, childrenCount)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||
)
|
||||
|
||||
try {
|
||||
val cursor = if (isOreoPlus()) {
|
||||
if (isOreoPlus()) {
|
||||
val queryArgs = bundleOf(
|
||||
ContentResolver.QUERY_ARG_LIMIT to RECENTS_LIMIT,
|
||||
ContentResolver.QUERY_ARG_SORT_COLUMNS to arrayOf(FileColumns.DATE_MODIFIED),
|
||||
|
@ -133,8 +133,7 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||
} else {
|
||||
val sortOrder = "${FileColumns.DATE_MODIFIED} DESC LIMIT $RECENTS_LIMIT"
|
||||
context?.contentResolver?.query(uri, projection, null, null, sortOrder)
|
||||
}
|
||||
cursor?.use {
|
||||
}?.use { cursor ->
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
val path = cursor.getStringValue(FileColumns.DATA)
|
||||
|
|
Loading…
Reference in a new issue