[Android] List names instead of files to spare memory
Geoffrey Métais
git at videolan.org
Wed Apr 8 17:19:46 CEST 2015
vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Apr 8 15:10:12 2015 +0200| [d64b1c07a4d7a604db2b4c0fe820a2e2e1b3acc1] | committer: Geoffrey Métais
List names instead of files to spare memory
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=d64b1c07a4d7a604db2b4c0fe820a2e2e1b3acc1
---
vlc-android/src/org/videolan/vlc/MediaLibrary.java | 22 ++++++++++++--------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/MediaLibrary.java b/vlc-android/src/org/videolan/vlc/MediaLibrary.java
index a6e959c..f09f8fa 100644
--- a/vlc-android/src/org/videolan/vlc/MediaLibrary.java
+++ b/vlc-android/src/org/videolan/vlc/MediaLibrary.java
@@ -275,7 +275,7 @@ public class MediaLibrary {
int count = 0;
- ArrayList<File> mediaToScan = new ArrayList<File>();
+ LinkedList<File> mediaToScan = new LinkedList<File>();
try {
LinkedList<String> dirsToIgnore = new LinkedList<String>();
// Count total files, and stack them
@@ -307,17 +307,21 @@ public class MediaLibrary {
// Filter the extensions and the folders
try {
- if ((f = dir.listFiles(mediaFileFilter)) != null) {
- for (File file : f) {
- if (file.isFile()) {
- mediaToScan.add(file);
- } else if (file.isDirectory()) {
- directories.push(file);
+ String[] files = dir.list();
+ File file;
+ if (files != null){
+ for (String fileName : files){
+ file = new File(dirPath, fileName);
+ if (mediaFileFilter.accept(file)){
+ if (file.isFile())
+ mediaToScan.add(file);
+ else if (file.isDirectory())
+ directories.push(file);
}
+ file = null;
}
}
- } catch (Exception e)
- {
+ } catch (Exception e){
// listFiles can fail in OutOfMemoryError, go to the next folder
continue;
}
More information about the Android
mailing list