Skip to content

Commit 0af5ee2

Browse files
committed
improve file loading performance on Android 11+
1 parent 12b96e1 commit 0af5ee2

File tree

2 files changed

+3
-33
lines changed

2 files changed

+3
-33
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ android {
5858
}
5959

6060
dependencies {
61-
implementation 'com.simplemobiletools:commons:5.30.18'
61+
implementation 'com.simplemobiletools:commons:5.30.21'
6262
implementation 'com.github.Stericson:RootTools:df729dcb13'
6363
implementation 'com.github.Stericson:RootShell:1.6'
6464
implementation 'com.alexvasilkov:gesture-views:2.5.2'

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/ItemsFragment.kt

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.simplemobiletools.filemanager.pro.fragments
22

33
import android.os.Bundle
44
import android.os.Parcelable
5-
import android.provider.MediaStore
65
import android.view.LayoutInflater
76
import android.view.View
87
import android.view.ViewGroup
@@ -12,6 +11,7 @@ import com.simplemobiletools.commons.dialogs.StoragePickerDialog
1211
import com.simplemobiletools.commons.extensions.*
1312
import com.simplemobiletools.commons.helpers.SORT_BY_SIZE
1413
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
14+
import com.simplemobiletools.commons.helpers.isRPlus
1515
import com.simplemobiletools.commons.models.FileDirItem
1616
import com.simplemobiletools.commons.views.Breadcrumbs
1717
import com.simplemobiletools.commons.views.MyLinearLayoutManager
@@ -218,7 +218,7 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
218218
return
219219
}
220220

221-
val lastModifieds = getFolderLastModifieds(path)
221+
val lastModifieds = if (isRPlus()) context!!.getFolderLastModifieds(path) else HashMap()
222222
val isSortingBySize = context!!.config.getFolderSorting(currentPath) and SORT_BY_SIZE != 0
223223
if (files != null) {
224224
for (file in files) {
@@ -268,36 +268,6 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
268268
return listItems
269269
}
270270

271-
private fun getFolderLastModifieds(folder: String): HashMap<String, Long> {
272-
val lastModifieds = HashMap<String, Long>()
273-
val projection = arrayOf(
274-
MediaStore.Images.Media.DISPLAY_NAME,
275-
MediaStore.Images.Media.DATE_MODIFIED
276-
)
277-
278-
val uri = MediaStore.Files.getContentUri("external")
279-
val selection = "${MediaStore.Images.Media.DATA} LIKE ? AND ${MediaStore.Images.Media.DATA} NOT LIKE ?"
280-
val selectionArgs = arrayOf("$folder/%", "$folder/%/%")
281-
282-
val cursor = context!!.contentResolver.query(uri, projection, selection, selectionArgs, null)
283-
cursor?.use {
284-
if (cursor.moveToFirst()) {
285-
do {
286-
try {
287-
val lastModified = cursor.getLongValue(MediaStore.Images.Media.DATE_MODIFIED) * 1000
288-
if (lastModified != 0L) {
289-
val name = cursor.getStringValue(MediaStore.Images.Media.DISPLAY_NAME)
290-
lastModifieds["$folder/$name"] = lastModified
291-
}
292-
} catch (e: Exception) {
293-
}
294-
} while (cursor.moveToNext())
295-
}
296-
}
297-
298-
return lastModifieds
299-
}
300-
301271
private fun itemClicked(item: FileDirItem) {
302272
if (item.isDirectory) {
303273
(activity as? MainActivity)?.apply {

0 commit comments

Comments
 (0)