mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
[Android] Simplify GameListFragment.Fill a little bit.
Made the filtering check against a HashSet of specified supported extensions. Not only does this get rid of the multitude of checks for extensions in the if-statement, but it also makes for less typing in the future if new file extensions/formats are used. Simply add the extension to support to the set, and you're done.
This commit is contained in:
parent
4e8c3b2f12
commit
13f30d1d1d
@ -13,8 +13,11 @@ import android.widget.Toast;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copyright 2013 Dolphin Emulator Project
|
* Copyright 2013 Dolphin Emulator Project
|
||||||
@ -40,6 +43,10 @@ public class GameListFragment extends Fragment
|
|||||||
List<GameListItem> fls = new ArrayList<GameListItem>();
|
List<GameListItem> fls = new ArrayList<GameListItem>();
|
||||||
String Directories = NativeLibrary.GetConfig("Dolphin.ini", "General", "GCMPathes", "0");
|
String Directories = NativeLibrary.GetConfig("Dolphin.ini", "General", "GCMPathes", "0");
|
||||||
int intDirectories = Integer.parseInt(Directories);
|
int intDirectories = Integer.parseInt(Directories);
|
||||||
|
|
||||||
|
// Extensions to filter by.
|
||||||
|
Set<String> exts = new HashSet<String>(Arrays.asList(".gcm", ".iso", ".wbfs", ".gcz", ".dol", ".elf", ".dff"));
|
||||||
|
|
||||||
for (int a = 0; a < intDirectories; ++a)
|
for (int a = 0; a < intDirectories; ++a)
|
||||||
{
|
{
|
||||||
String BrowseDir = NativeLibrary.GetConfig("Dolphin.ini", "General", "GCMPath" + Integer.toString(a), "");
|
String BrowseDir = NativeLibrary.GetConfig("Dolphin.ini", "General", "GCMPath" + Integer.toString(a), "");
|
||||||
@ -47,18 +54,18 @@ public class GameListFragment extends Fragment
|
|||||||
File[]dirs = currentDir.listFiles();
|
File[]dirs = currentDir.listFiles();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
for(File ff: dirs)
|
for(File entry : dirs)
|
||||||
{
|
{
|
||||||
if (ff.getName().charAt(0) != '.')
|
String entryName = entry.getName();
|
||||||
if(!ff.isDirectory())
|
|
||||||
if (ff.getName().toLowerCase().contains(".gcm") ||
|
if (entryName.charAt(0) != '.')
|
||||||
ff.getName().toLowerCase().contains(".iso") ||
|
{
|
||||||
ff.getName().toLowerCase().contains(".wbfs") ||
|
if(!entry.isDirectory())
|
||||||
ff.getName().toLowerCase().contains(".gcz") ||
|
{
|
||||||
ff.getName().toLowerCase().contains(".dol") ||
|
if (exts.contains(entryName.toLowerCase()))
|
||||||
ff.getName().toLowerCase().contains(".elf") ||
|
fls.add(new GameListItem(mMe.getApplicationContext(), entryName,"File Size: "+entry.length(),entry.getAbsolutePath(), true));
|
||||||
ff.getName().toLowerCase().contains(".dff"))
|
}
|
||||||
fls.add(new GameListItem(mMe.getApplicationContext(), ff.getName(),"File Size: "+ff.length(),ff.getAbsolutePath(), true));
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception ignored)
|
catch(Exception ignored)
|
||||||
|
Loading…
Reference in New Issue
Block a user