diff --git a/android/phoenix/src/org/retroarch/browser/FileWrapper.java b/android/phoenix/src/org/retroarch/browser/FileWrapper.java index cee18e991f..9f0a3ac91f 100644 --- a/android/phoenix/src/org/retroarch/browser/FileWrapper.java +++ b/android/phoenix/src/org/retroarch/browser/FileWrapper.java @@ -6,25 +6,24 @@ import org.retroarch.R; import android.graphics.drawable.Drawable; -public final class FileWrapper implements IconAdapterItem { - public final File file; - public final boolean parentItem; - public final boolean dirSelectItem; - - protected final boolean enabled; - +public final class FileWrapper implements IconAdapterItem, Comparable { + public static final int DIRSELECT = 0; public static final int PARENT = 1; public static final int FILE = 2; - - protected final int typeIndex; + + private final File file; + private final boolean parentItem; + private final boolean dirSelectItem; + private final boolean enabled; + private final int typeIndex; public FileWrapper(File file, int type, boolean isEnabled) { this.file = file; - this.parentItem = type == PARENT; - this.dirSelectItem = type == DIRSELECT; - this.typeIndex = type == FILE ? (FILE + (file.isDirectory() ? 0 : 1)) : type; + this.parentItem = (type == PARENT); + this.dirSelectItem = (type == DIRSELECT); + this.typeIndex = (type == FILE) ? (FILE + (file.isDirectory() ? 0 : 1)) : type; this.enabled = parentItem || dirSelectItem || isEnabled; } @@ -43,7 +42,7 @@ public final class FileWrapper implements IconAdapterItem { else return file.getName(); } - + @Override public String getSubText() { return null; @@ -63,6 +62,38 @@ public final class FileWrapper implements IconAdapterItem { return null; } + /** + * Checks whether or not the wrapped {@link File} is + * the "Parent Directory" item in the file browser. + * + * @return true if the wrapped {@link File} is the "Parent Directory" + * item in the file browser; false otherwise. + */ + public boolean isParentItem() { + return parentItem; + } + + /** + * Checks whether or not the wrapped {@link File} + * is the "use this directory" item. + * + * @return true if the wrapped {@link File} is the "Use this directory" + * item in the file browser; false otherwise. + */ + public boolean isDirSelectItem() { + return dirSelectItem; + } + + /** + * Gets the file wrapped by this FileWrapper. + * + * @return the file wrapped by this FileWrapper. + */ + public File getFile() { + return file; + } + + @Override public int compareTo(FileWrapper other) { if (other != null) { // Who says ternary is hard to follow diff --git a/android/phoenix/src/org/retroarch/browser/diractivities/DirectoryActivity.java b/android/phoenix/src/org/retroarch/browser/diractivities/DirectoryActivity.java index a40bf37f0e..ebcfca2199 100644 --- a/android/phoenix/src/org/retroarch/browser/diractivities/DirectoryActivity.java +++ b/android/phoenix/src/org/retroarch/browser/diractivities/DirectoryActivity.java @@ -122,21 +122,20 @@ public class DirectoryActivity extends ListActivity { public void onListItemClick(ListView listView, View aView, int position, long id) { final FileWrapper item = adapter.getItem(position); - if (item.parentItem && backStack.get(backStack.size() - 1).parentIsBack) { + if (item.isParentItem() && backStack.get(backStack.size() - 1).parentIsBack) { backStack.remove(backStack.size() - 1); wrapFiles(); return; - } else if (item.dirSelectItem) { + } else if (item.isDirSelectItem()) { finishWithPath(listedDirectory.getAbsolutePath()); return; } - final File selected = item.parentItem ? listedDirectory.getParentFile() - : item.file; + final File selected = item.isParentItem() ? listedDirectory.getParentFile() : item.getFile(); if (selected.isDirectory()) { backStack.add(new BackStackItem(selected.getAbsolutePath(), - !item.parentItem)); + !item.isParentItem())); wrapFiles(); } else { String filePath = selected.getAbsolutePath(); @@ -228,8 +227,8 @@ public class DirectoryActivity extends ListActivity { // Sort items adapter.sort(new Comparator() { @Override - public int compare(FileWrapper aLeft, FileWrapper aRight) { - return aLeft.compareTo(aRight); + public int compare(FileWrapper left, FileWrapper right) { + return left.compareTo(right); }; });