[Android] Fix a bug in FolderBrowser.java which was causing an incomplete directory structure to show.

This commit is contained in:
Lioncash 2013-08-22 02:52:05 -04:00
parent 85c78759c7
commit 988c168c2d

View File

@ -4,6 +4,7 @@ import android.app.Activity;
import android.app.Fragment; import android.app.Fragment;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment; import android.os.Environment;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -38,20 +39,22 @@ public final class FolderBrowser extends Fragment
Set<String> validExts = new HashSet<String>(Arrays.asList(".gcm", ".iso", ".wbfs", ".gcz", ".dol", ".elf", ".dff")); Set<String> validExts = new HashSet<String>(Arrays.asList(".gcm", ".iso", ".wbfs", ".gcz", ".dol", ".elf", ".dff"));
Set<String> invalidExts = new HashSet<String>(Arrays.asList(".zip", ".rar", ".7z")); Set<String> invalidExts = new HashSet<String>(Arrays.asList(".zip", ".rar", ".7z"));
// Search for any directories or supported files within the current dir. // Search for any directories or files within the current dir.
try
{
for(File entry : dirs) for(File entry : dirs)
{
try
{ {
String entryName = entry.getName(); String entryName = entry.getName();
boolean hasExtension = (entryName.lastIndexOf(".") != -1) ? true : false;
// Skip hidden folders/files.
if (entryName.charAt(0) != '.') if (entryName.charAt(0) != '.')
{ {
if(entry.isDirectory()) if(entry.isDirectory())
{ {
dir.add(new FolderBrowserItem(entryName, entry.getAbsolutePath(), true)); dir.add(new FolderBrowserItem(entryName, entry.getAbsolutePath(), true));
} }
else else if (entry.isFile() && hasExtension)
{ {
if (validExts.contains(entryName.toLowerCase().substring(entryName.lastIndexOf('.')))) if (validExts.contains(entryName.toLowerCase().substring(entryName.lastIndexOf('.'))))
{ {
@ -64,9 +67,10 @@ public final class FolderBrowser extends Fragment
} }
} }
} }
} catch (Exception ex)
catch(Exception ignored)
{ {
Log.d("EXCEPTION", ex.toString());
}
} }
Collections.sort(dir); Collections.sort(dir);