[Android] [PATCH] Send directly dir list in ArrayList format
Geoffrey Métais
geoffrey.metais at gmail.com
Tue Nov 25 16:59:21 CET 2014
Avoid useless conversions between String[] and ArrayList<String>
---
vlc-android/src/org/videolan/vlc/gui/BrowserActivity.java | 4 ++--
vlc-android/src/org/videolan/vlc/util/AndroidDevices.java | 12 +++---------
2 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/BrowserActivity.java b/vlc-android/src/org/videolan/vlc/gui/BrowserActivity.java
index 018ec33..50d96a4 100644
--- a/vlc-android/src/org/videolan/vlc/gui/BrowserActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/BrowserActivity.java
@@ -98,7 +98,7 @@ public class BrowserActivity extends ListActivity {
private void refreshRoots() {
ArrayList<String> list = new ArrayList<String>();
- list.addAll(Arrays.asList(AndroidDevices.getStorageDirectories()));
+ list.addAll(AndroidDevices.getStorageDirectories());
list.addAll(Arrays.asList(CustomDirectories.getCustomDirectories()));
mRoots = list.toArray(new String[list.size()]);
}
@@ -117,7 +117,7 @@ public class BrowserActivity extends ListActivity {
final File item = mAdapter.getItem(position);
if (mCurrentDir != null
|| item.getPath().equals(BrowserAdapter.ADD_ITEM_PATH)
- || Arrays.asList(AndroidDevices.getStorageDirectories()).contains(
+ || AndroidDevices.getStorageDirectories().contains(
item.getPath())) {
return;
}
diff --git a/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java b/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java
index d71f55f..8d1af79 100644
--- a/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java
+++ b/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java
@@ -87,8 +87,7 @@ public class AndroidDevices {
return hasTsp;
}
- public static String[] getStorageDirectories() {
- String[] dirs = null;
+ public static ArrayList<String> getStorageDirectories() {
BufferedReader bufReader = null;
ArrayList<String> list = new ArrayList<String>();
list.add(Environment.getExternalStorageDirectory().getPath());
@@ -127,11 +126,6 @@ public class AndroidDevices {
if (Strings.StartsWith(deviceWL, device) && (typeWL.contains(type) || Strings.StartsWith(mountWL, mountpoint)))
list.add(mountpoint);
}
-
- dirs = new String[list.size()];
- for (int i = 0; i < list.size(); i++) {
- dirs[i] = list.get(i);
- }
}
catch (FileNotFoundException e) {}
catch (IOException e) {}
@@ -143,12 +137,12 @@ public class AndroidDevices {
catch (IOException e) {}
}
}
- return dirs;
+ return list;
}
public static String[] getMediaDirectories() {
ArrayList<String> list = new ArrayList<String>();
- list.addAll(Arrays.asList(getStorageDirectories()));
+ list.addAll(getStorageDirectories());
list.addAll(Arrays.asList(CustomDirectories.getCustomDirectories()));
return list.toArray(new String[list.size()]);
}
--
1.9.1
More information about the Android
mailing list