Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

Commit

Permalink
Add a method for easily being able to filter the list
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas Kalderstam <[email protected]>
  • Loading branch information
spacecowboy committed May 30, 2015
1 parent 38f4ee2 commit 5d01201
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,11 @@ public boolean areItemsTheSame(File file, File file2) {
files.beginBatchedUpdates();
if (listFiles != null) {
for (java.io.File f : listFiles) {
if ((mode == MODE_FILE || mode == MODE_FILE_AND_DIR)
|| f.isDirectory()) {
if (isItemVisible(f)) {
files.add(f);
}
}
}

files.endBatchedUpdates();

return files;
Expand Down Expand Up @@ -229,5 +227,17 @@ public void onNewFolder(final String name) {
}
}

/**
* Used by the list to determine whether a file should be displayed or not.
* Default behavior is to always display folders. If files can be selected,
* then files are also displayed. Override this method to enable other
* filtering behaviour, like only displaying files with specific extensions (.zip, .txt, etc).
*
* @param file to maybe add. Can be either a directory or file.
* @return True if item should be added to the list, false otherwise
*/
protected boolean isItemVisible(final File file) {
return isDir(file) || (mode == MODE_FILE || mode == MODE_FILE_AND_DIR);
}

}

0 comments on commit 5d01201

Please sign in to comment.