Android: Fix a possible crash in the file browser if attempting to show a file with no extension.
This commit is contained in:
parent
06b7b20e5f
commit
0fa0e55e2c
|
@ -22,6 +22,7 @@ public class FileListItem implements Comparable<FileListItem>
|
||||||
public FileListItem(File file)
|
public FileListItem(File file)
|
||||||
{
|
{
|
||||||
mPath = file.getAbsolutePath();
|
mPath = file.getAbsolutePath();
|
||||||
|
mFilename = file.getName();
|
||||||
|
|
||||||
if (file.isDirectory())
|
if (file.isDirectory())
|
||||||
{
|
{
|
||||||
|
@ -29,12 +30,22 @@ public class FileListItem implements Comparable<FileListItem>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
String fileExtension = mPath.substring(mPath.lastIndexOf('.'));
|
String fileExtension = null;
|
||||||
|
|
||||||
// Extensions to filter by.
|
int extensionStart = mPath.lastIndexOf('.');
|
||||||
|
if (extensionStart < 1)
|
||||||
|
{
|
||||||
|
// Ignore hidden files & files without extensions.
|
||||||
|
mType = TYPE_OTHER;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fileExtension = mPath.substring(extensionStart);
|
||||||
|
|
||||||
|
// The extensions we care about.
|
||||||
Set<String> allowedExtensions = new HashSet<String>(Arrays.asList(".dff", ".dol", ".elf", ".gcm", ".gcz", ".iso", ".wad", ".wbfs"));
|
Set<String> allowedExtensions = new HashSet<String>(Arrays.asList(".dff", ".dol", ".elf", ".gcm", ".gcz", ".iso", ".wad", ".wbfs"));
|
||||||
|
|
||||||
// Check that the file has an appropriate extension before trying to read out of it.
|
// Check that the file has an extension we care about before trying to read out of it.
|
||||||
if (allowedExtensions.contains(fileExtension))
|
if (allowedExtensions.contains(fileExtension))
|
||||||
{
|
{
|
||||||
mType = NativeLibrary.IsWiiTitle(mPath) ? TYPE_WII : TYPE_GC;
|
mType = NativeLibrary.IsWiiTitle(mPath) ? TYPE_WII : TYPE_GC;
|
||||||
|
@ -44,8 +55,7 @@ public class FileListItem implements Comparable<FileListItem>
|
||||||
mType = TYPE_OTHER;
|
mType = TYPE_OTHER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
mFilename = file.getName();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getType()
|
public int getType()
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue