[Android] Allow the user to select multiple browse paths.

This commit is contained in:
Ryan Houdek 2013-05-05 22:42:13 -05:00
parent 12d791a628
commit b2d3dc8a68
2 changed files with 41 additions and 39 deletions

View File

@ -6,8 +6,6 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import net.simonvt.menudrawer.MenuDrawer;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;

View File

@ -28,7 +28,7 @@ import android.widget.Toast;
public class GameListView extends ListActivity { public class GameListView extends ListActivity {
private GameListAdapter adapter; private GameListAdapter adapter;
private static File currentDir = null; private static List<File> currentDir;
private MenuDrawer mDrawer; private MenuDrawer mDrawer;
private SideMenuAdapter mAdapter; private SideMenuAdapter mAdapter;
@ -37,38 +37,42 @@ public class GameListView extends ListActivity {
public static native String GetConfig(String Key, String Value, String Default); public static native String GetConfig(String Key, String Value, String Default);
public static native void SetConfig(String Key, String Value, String Default); public static native void SetConfig(String Key, String Value, String Default);
private void Fill(File f) private void Fill()
{ {
File[]dirs = f.listFiles();
this.setTitle("Game List"); this.setTitle("Game List");
List<GameListItem>dir = new ArrayList<GameListItem>();
List<GameListItem>fls = new ArrayList<GameListItem>(); List<GameListItem>fls = new ArrayList<GameListItem>();
String Directories = GetConfig("General", "GCMPathes", "0");
try int intDirectories = Integer.parseInt(Directories);
for (int a = 0; a < intDirectories; ++a)
{ {
for(File ff: dirs) String BrowseDir = GetConfig("General", "GCMPaths" + Integer.toString(a), "");
File currentDir = new File(BrowseDir);
File[]dirs = currentDir.listFiles();
try
{ {
if (ff.getName().charAt(0) != '.') for(File ff: dirs)
if(!ff.isDirectory()) {
if (ff.getName().toLowerCase().contains(".gcm") || if (ff.getName().charAt(0) != '.')
ff.getName().toLowerCase().contains(".iso") || if(!ff.isDirectory())
ff.getName().toLowerCase().contains(".wbfs") || if (ff.getName().toLowerCase().contains(".gcm") ||
ff.getName().toLowerCase().contains(".gcz") || ff.getName().toLowerCase().contains(".iso") ||
ff.getName().toLowerCase().contains(".dol") || ff.getName().toLowerCase().contains(".wbfs") ||
ff.getName().toLowerCase().contains(".elf")) ff.getName().toLowerCase().contains(".gcz") ||
fls.add(new GameListItem(getApplicationContext(), ff.getName(),"File Size: "+ff.length(),ff.getAbsolutePath())); ff.getName().toLowerCase().contains(".dol") ||
} ff.getName().toLowerCase().contains(".elf"))
} fls.add(new GameListItem(getApplicationContext(), ff.getName(),"File Size: "+ff.length(),ff.getAbsolutePath()));
catch(Exception e) }
{ }
} catch(Exception e)
{
}
}
Collections.sort(fls);
Collections.sort(dir); adapter = new GameListAdapter(this,R.layout.main, fls);
Collections.sort(fls); this.setListAdapter(adapter);
dir.addAll(fls);
adapter = new GameListAdapter(this,R.layout.main,dir);
this.setListAdapter(adapter);
} }
@Override @Override
@ -103,11 +107,13 @@ public class GameListView extends ListActivity {
{ {
String FileName = data.getStringExtra("Select"); String FileName = data.getStringExtra("Select");
Toast.makeText(this, "Folder Selected: " + FileName, Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Folder Selected: " + FileName, Toast.LENGTH_SHORT).show();
SetConfig("General", "GCMPathes", "1"); String Directories = GetConfig("General", "GCMPathes", "0");
SetConfig("General", "GCMPaths0", FileName); int intDirectories = Integer.parseInt(Directories);
Directories = Integer.toString(intDirectories + 1);
SetConfig("General", "GCMPathes", Directories);
SetConfig("General", "GCMPaths" + Integer.toString(intDirectories), FileName);
currentDir = new File(FileName); Fill();
Fill(currentDir);
} }
} }
@ -119,10 +125,8 @@ public class GameListView extends ListActivity {
mDrawer = MenuDrawer.attach(this, MenuDrawer.MENU_DRAG_CONTENT); mDrawer = MenuDrawer.attach(this, MenuDrawer.MENU_DRAG_CONTENT);
String BrowseDir = GetConfig("General", "GCMPaths0", "");
if(currentDir == null) Fill();
currentDir = new File(BrowseDir);
Fill(currentDir);
List<SideMenuItem>dir = new ArrayList<SideMenuItem>(); List<SideMenuItem>dir = new ArrayList<SideMenuItem>();
dir.add(new SideMenuItem("Browse Folder", 0)); dir.add(new SideMenuItem("Browse Folder", 0));