Commit c3d4d6e1 authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Send directly dir list in ArrayList format

Avoid useless conversions between String[] and ArrayList<String>
parent 41ddb5cc
......@@ -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;
}
......
......@@ -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()]);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment