diff --git a/.gitignore b/.gitignore
index 93fa760..6e2fdda 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,10 +1,12 @@
/demo/.idea
+/demo/.gradle
/demo/build
/demo/local.properties
/demo/aFileDialog/build
/demo/aFileDialogTesting/build
/library/.idea
+/library/.gradle
/library/build
/library/local.properties
/library/app/build
diff --git a/demo/aFileDialog/aFileDialog.iml b/demo/aFileDialog/aFileDialog.iml
index 5597765..04a49c3 100644
--- a/demo/aFileDialog/aFileDialog.iml
+++ b/demo/aFileDialog/aFileDialog.iml
@@ -12,10 +12,12 @@
-
-
+
+ generateDebugAndroidTestSources
+ generateDebugSources
+
@@ -25,7 +27,7 @@
-
+
diff --git a/demo/aFileDialog/src/main/java/ar/com/daidalos/afiledialog/FileChooserActivity.java b/demo/aFileDialog/src/main/java/ar/com/daidalos/afiledialog/FileChooserActivity.java
index d4c462f..547dc2d 100644
--- a/demo/aFileDialog/src/main/java/ar/com/daidalos/afiledialog/FileChooserActivity.java
+++ b/demo/aFileDialog/src/main/java/ar/com/daidalos/afiledialog/FileChooserActivity.java
@@ -70,7 +70,13 @@ public class FileChooserActivity extends Activity implements FileChooser {
* a boolean that indicates if the user can create files.
*/
public static final String INPUT_CAN_CREATE_FILES = "input_can_create_files";
-
+
+ /**
+ * Constant used for represent the key of the bundle object (inside the start's intent) which contains
+ * a boolean that indicates if the cancel button must be show.
+ */
+ public static final String INPUT_SHOW_CANCEL_BUTTON = "input_show_cancel_button";
+
/**
* Constant used for represent the key of the bundle object (inside the start's intent) which contains
* a regular expression which is going to be used as a filter to determine which files can be selected.
@@ -160,6 +166,7 @@ public void onCreate(Bundle savedInstanceState) {
if(extras.containsKey(INPUT_CAN_CREATE_FILES)) core.setCanCreateFiles(extras.getBoolean(INPUT_CAN_CREATE_FILES));
if(extras.containsKey(INPUT_LABELS)) core.setLabels((FileChooserLabels) extras.get(INPUT_LABELS));
if(extras.containsKey(INPUT_SHOW_CONFIRMATION_ON_CREATE)) core.setShowConfirmationOnCreate(extras.getBoolean(INPUT_SHOW_CONFIRMATION_ON_CREATE));
+ if(extras.containsKey(INPUT_SHOW_CANCEL_BUTTON)) core.setShowCancelButton(extras.getBoolean(INPUT_SHOW_CANCEL_BUTTON));
if(extras.containsKey(INPUT_SHOW_CONFIRMATION_ON_SELECT)) core.setShowConfirmationOnSelect(extras.getBoolean(INPUT_SHOW_CONFIRMATION_ON_SELECT));
if(extras.containsKey(INPUT_SHOW_FULL_PATH_IN_TITLE)) core.setShowFullPathInTitle(extras.getBoolean(INPUT_SHOW_FULL_PATH_IN_TITLE));
if(extras.containsKey(INPUT_USE_BACK_BUTTON_TO_NAVIGATE)) this.useBackButton = extras.getBoolean(INPUT_USE_BACK_BUTTON_TO_NAVIGATE);
@@ -193,6 +200,14 @@ public void onFileSelected(File file) {
finish();
}
});
+
+ // Add a listener for when the cancel button is pressed.
+ core.addListener(new FileChooserCore.OnCancelListener() {
+ public void onCancel() {
+ // Close activity.
+ FileChooserActivity.super.onBackPressed();
+ }
+ });
}
/** Called when the user push the 'back' button. */
diff --git a/demo/aFileDialog/src/main/java/ar/com/daidalos/afiledialog/FileChooserCore.java b/demo/aFileDialog/src/main/java/ar/com/daidalos/afiledialog/FileChooserCore.java
index f233e88..df9b0eb 100644
--- a/demo/aFileDialog/src/main/java/ar/com/daidalos/afiledialog/FileChooserCore.java
+++ b/demo/aFileDialog/src/main/java/ar/com/daidalos/afiledialog/FileChooserCore.java
@@ -51,8 +51,13 @@ class FileChooserCore {
/**
* The listeners for the event of select a file.
*/
- private List listeners;
-
+ private List fileSelectedListeners;
+
+ /**
+ * The listeners for the event of select a file.
+ */
+ private List cancelListeners;
+
/**
* A regular expression for filter the files.
*/
@@ -72,7 +77,12 @@ class FileChooserCore {
* A boolean indicating if the chooser is going to be used to select folders.
*/
private boolean folderMode;
-
+
+ /**
+ * A boolean indicating if the chooser is going to be used to select folders.
+ */
+ private boolean showCancelButton;
+
/**
* A file that indicates the folder that is currently being displayed.
*/
@@ -122,7 +132,8 @@ class FileChooserCore {
public FileChooserCore(FileChooser fileChooser) {
// Initialize attributes.
this.chooser = fileChooser;
- this.listeners = new LinkedList();
+ this.fileSelectedListeners = new LinkedList();
+ this.cancelListeners = new LinkedList();
this.filter = null;
this.showOnlySelectable = false;
this.setCanCreateFiles(false);
@@ -132,13 +143,16 @@ public FileChooserCore(FileChooser fileChooser) {
this.showConfirmationOnCreate = false;
this.showConfirmationOnSelect = false;
this.showFullPathInTitle = false;
-
- // Add listener for the buttons.
+ this.showCancelButton = false;
+
+ // Add listener for the buttons.
LinearLayout root = this.chooser.getRootLayout();
Button addButton = (Button) root.findViewById(R.id.buttonAdd);
addButton.setOnClickListener(addButtonClickListener);
Button okButton = (Button) root.findViewById(R.id.buttonOk);
okButton.setOnClickListener(okButtonClickListener);
+ Button cancelButton = (Button) root.findViewById(R.id.buttonCancel);
+ cancelButton.setOnClickListener(cancelButtonClickListener);
}
// ----- Events methods ----- //
@@ -178,7 +192,7 @@ public void onClick(DialogInterface dialog, int whichButton) {
// Verify if a value has been entered.
if(fileName != null && fileName.length() > 0) {
// Notify the listeners.
- FileChooserCore.this.notifyListeners(FileChooserCore.this.currentFolder, fileName);
+ FileChooserCore.this.notifyFileListeners(FileChooserCore.this.currentFolder, fileName);
}
}
});
@@ -199,10 +213,20 @@ public void onClick(DialogInterface dialog, int whichButton) {
private View.OnClickListener okButtonClickListener = new View.OnClickListener() {
public void onClick(View v) {
// Notify the listeners.
- FileChooserCore.this.notifyListeners(FileChooserCore.this.currentFolder, null);
+ FileChooserCore.this.notifyFileListeners(FileChooserCore.this.currentFolder, null);
}
};
-
+
+ /**
+ * Implementation of the click listener for when the cancel button is clicked.
+ */
+ private View.OnClickListener cancelButtonClickListener = new View.OnClickListener() {
+ public void onClick(View v) {
+ // Notify the listeners.
+ FileChooserCore.this.notifyCancelListeners();
+ }
+ };
+
/**
* Implementation of the click listener for when a file item is clicked.
*/
@@ -215,7 +239,7 @@ public void onClick(FileItem source) {
FileChooserCore.this.loadFolder(file);
} else {
// Notify the listeners.
- FileChooserCore.this.notifyListeners(file, null);
+ FileChooserCore.this.notifyFileListeners(file, null);
}
}
};
@@ -226,7 +250,7 @@ public void onClick(FileItem source) {
* @param listener The listener to add.
*/
public void addListener(OnFileSelectedListener listener) {
- this.listeners.add(listener);
+ this.fileSelectedListeners.add(listener);
}
/**
@@ -235,16 +259,35 @@ public void addListener(OnFileSelectedListener listener) {
* @param listener The listener to remove.
*/
public void removeListener(OnFileSelectedListener listener) {
- this.listeners.remove(listener);
- }
-
- /**
- * Removes all the listeners for the event of a file selected.
- */
- public void removeAllListeners() {
- this.listeners.clear();
+ this.fileSelectedListeners.remove(listener);
}
-
+
+ /**
+ * Add a listener for the event of a file selected.
+ *
+ * @param listener The listener to add.
+ */
+ public void addListener(OnCancelListener listener) {
+ this.cancelListeners.add(listener);
+ }
+
+ /**
+ * Removes a listener for the event of a file selected.
+ *
+ * @param listener The listener to remove.
+ */
+ public void removeListener(OnCancelListener listener) {
+ this.cancelListeners.remove(listener);
+ }
+
+ /**
+ * Removes all the listeners for the event of a file selected.
+ */
+ public void removeAllListeners() {
+ this.fileSelectedListeners.clear();
+ this.cancelListeners.clear();
+ }
+
/**
* Interface definition for a callback to be invoked when a file is selected.
*/
@@ -264,14 +307,33 @@ public interface OnFileSelectedListener {
*/
void onFileSelected(File folder, String name);
}
-
+
+ /**
+ * Interface definition for a callback to be invoked when the cancel button is clicked.
+ */
+ public interface OnCancelListener {
+ /**
+ * Called when the cancel button is clicked.
+ */
+ void onCancel();
+ }
+
+ /**
+ * Notify to all listeners that the cancel button has been pressed.
+ */
+ private void notifyCancelListeners() {
+ for(int i=0; i 0;
@@ -301,11 +363,11 @@ private void notifyListeners(final File file, final String name) {
alert.setPositiveButton(posButton, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Notify to listeners.
- for(int i=0; i
-
+
+
+
\ No newline at end of file
diff --git a/demo/aFileDialogTesting/aFileDialogTesting.iml b/demo/aFileDialogTesting/aFileDialogTesting.iml
index 5b70629..192313a 100644
--- a/demo/aFileDialogTesting/aFileDialogTesting.iml
+++ b/demo/aFileDialogTesting/aFileDialogTesting.iml
@@ -12,10 +12,12 @@
-
-
+
+ generateDebugAndroidTestSources
+ generateDebugSources
+
@@ -24,7 +26,7 @@
-
+
diff --git a/demo/aFileDialogTesting/src/main/java/ar/com/daidalos/afiledialog/test/AFileDialogTestingActivity.java b/demo/aFileDialogTesting/src/main/java/ar/com/daidalos/afiledialog/test/AFileDialogTestingActivity.java
index b94daab..f1297c3 100644
--- a/demo/aFileDialogTesting/src/main/java/ar/com/daidalos/afiledialog/test/AFileDialogTestingActivity.java
+++ b/demo/aFileDialogTesting/src/main/java/ar/com/daidalos/afiledialog/test/AFileDialogTestingActivity.java
@@ -55,6 +55,8 @@ public void onCreate(Bundle savedInstanceState) {
buttonActivity6.setOnClickListener(btnActivityAskConfirmation);
Button buttonActivity7 = (Button)this.findViewById(R.id.activity_custom_labels);
buttonActivity7.setOnClickListener(btnActivityCustomLabels);
+ Button buttonActivity8 = (Button)this.findViewById(R.id.activity_cancel_button);
+ buttonActivity8.setOnClickListener(btnActivityCancelButton);
Button buttonDialog1 = (Button)this.findViewById(R.id.dialog_simple_open);
buttonDialog1.setOnClickListener(btnDialogSimpleOpen);
@@ -70,6 +72,8 @@ public void onCreate(Bundle savedInstanceState) {
buttonDialog6.setOnClickListener(btnDialogAskConfirmation);
Button buttonDialog7 = (Button)this.findViewById(R.id.dialog_custom_labels);
buttonDialog7.setOnClickListener(btnDialogCustomLabels);
+ Button buttonDialog8 = (Button)this.findViewById(R.id.dialog_cancel_button);
+ buttonDialog8.setOnClickListener(btnDialogCancelButton);
}
// ----- Buttons for open a dialog ----- //
@@ -184,7 +188,10 @@ public void onClick(View v) {
// Activate the button for create files.
dialog.setCanCreateFiles(true);
-
+
+ // Activate the button for cancel.
+ dialog.setShowCancelButton(true);
+
// Activate the confirmation dialogs.
dialog.setShowConfirmation(true, true);
@@ -200,13 +207,31 @@ public void onClick(View v) {
labels.messageConfirmSelection = "messageConfirmSelection";
labels.labelConfirmYesButton = "yesButton";
labels.labelConfirmNoButton = "noButton";
+ labels.labelCancelButton = "cancelButton";
dialog.setLabels(labels);
// Show the dialog.
dialog.show();
}
};
-
+
+
+ private OnClickListener btnDialogCancelButton = new OnClickListener() {
+ public void onClick(View v) {
+ // Create the dialog.
+ FileChooserDialog dialog = new FileChooserDialog(AFileDialogTestingActivity.this);
+
+ // Assign listener for the select event.
+ dialog.addListener(AFileDialogTestingActivity.this.onFileSelectedListener);
+
+ // Activate the button for create files.
+ dialog.setShowCancelButton(true);
+
+ // Show the dialog.
+ dialog.show();
+ }
+ };
+
// ---- Buttons for open an activity ----- //
private OnClickListener btnActivitySimpleOpen = new OnClickListener() {
@@ -298,7 +323,10 @@ public void onClick(View v) {
// Activate the button for create files.
intent.putExtra(FileChooserActivity.INPUT_CAN_CREATE_FILES, true);
-
+
+ // Activate the cancel button.
+ intent.putExtra(FileChooserActivity.INPUT_SHOW_CANCEL_BUTTON, true);
+
// Activate the confirmation dialogs.
intent.putExtra(FileChooserActivity.INPUT_SHOW_CONFIRMATION_ON_CREATE, true);
intent.putExtra(FileChooserActivity.INPUT_SHOW_CONFIRMATION_ON_SELECT, true);
@@ -315,13 +343,27 @@ public void onClick(View v) {
labels.messageConfirmSelection = "messageConfirmSelection";
labels.labelConfirmYesButton = "yesButton";
labels.labelConfirmNoButton = "noButton";
+ labels.labelCancelButton = "cancelButton";
intent.putExtra(FileChooserActivity.INPUT_LABELS, (Serializable) labels);
// Call the activity
AFileDialogTestingActivity.this.startActivityForResult(intent, 0);
}
};
-
+
+ private OnClickListener btnActivityCancelButton = new OnClickListener() {
+ public void onClick(View v) {
+ // Create the intent for call the activity.
+ Intent intent = new Intent(AFileDialogTestingActivity.this, FileChooserActivity.class);
+
+ // Activate the folder mode.
+ intent.putExtra(FileChooserActivity.INPUT_SHOW_CANCEL_BUTTON, true);
+
+ // Call the activity
+ AFileDialogTestingActivity.this.startActivityForResult(intent, 0);
+ }
+ };
+
/*
private OnClickListener clickButtonOpenActivity = new OnClickListener() {
public void onClick(View v) {
diff --git a/demo/aFileDialogTesting/src/main/res/layout/main.xml b/demo/aFileDialogTesting/src/main/res/layout/main.xml
index 9d2ea4f..7da03ee 100644
--- a/demo/aFileDialogTesting/src/main/res/layout/main.xml
+++ b/demo/aFileDialogTesting/src/main/res/layout/main.xml
@@ -63,6 +63,12 @@
android:layout_height="wrap_content"
android:text="@string/custom_labels" />
+
+
+
+
diff --git a/demo/aFileDialogTesting/src/main/res/values-en/strings.xml b/demo/aFileDialogTesting/src/main/res/values-en/strings.xml
index 96c4018..ce9ee32 100644
--- a/demo/aFileDialogTesting/src/main/res/values-en/strings.xml
+++ b/demo/aFileDialogTesting/src/main/res/values-en/strings.xml
@@ -14,5 +14,6 @@
Select images
Ask confirmation
Custom labels
+ Cancel button
\ No newline at end of file
diff --git a/demo/aFileDialogTesting/src/main/res/values-es/strings.xml b/demo/aFileDialogTesting/src/main/res/values-es/strings.xml
index f17a41a..182b1c2 100644
--- a/demo/aFileDialogTesting/src/main/res/values-es/strings.xml
+++ b/demo/aFileDialogTesting/src/main/res/values-es/strings.xml
@@ -14,5 +14,6 @@
Escoger imágenes
Pedir confirmación
Etiquetas personalizadas
+ Botón cancelar
\ No newline at end of file
diff --git a/demo/aFileDialogTesting/src/main/res/values-fr/strings.xml b/demo/aFileDialogTesting/src/main/res/values-fr/strings.xml
index 6fdbaf7..9898ea9 100644
--- a/demo/aFileDialogTesting/src/main/res/values-fr/strings.xml
+++ b/demo/aFileDialogTesting/src/main/res/values-fr/strings.xml
@@ -14,5 +14,6 @@
Choisir images
Démander confirmation
Étiquettes personnalisés
+ Bouton annuler
\ No newline at end of file
diff --git a/demo/aFileDialogTesting/src/main/res/values/strings.xml b/demo/aFileDialogTesting/src/main/res/values/strings.xml
index 96c4018..ce9ee32 100644
--- a/demo/aFileDialogTesting/src/main/res/values/strings.xml
+++ b/demo/aFileDialogTesting/src/main/res/values/strings.xml
@@ -14,5 +14,6 @@
Select images
Ask confirmation
Custom labels
+ Cancel button
\ No newline at end of file
diff --git a/demo/demo.iml b/demo/demo.iml
index f914fec..1666738 100644
--- a/demo/demo.iml
+++ b/demo/demo.iml
@@ -8,7 +8,7 @@
-
+
diff --git a/library/app/app.iml b/library/app/app.iml
new file mode 100644
index 0000000..484494c
--- /dev/null
+++ b/library/app/app.iml
@@ -0,0 +1,93 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ generateDebugAndroidTestSources
+ generateDebugSources
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/library/app/src/main/java/ar/com/daidalos/afiledialog/FileChooserActivity.java b/library/app/src/main/java/ar/com/daidalos/afiledialog/FileChooserActivity.java
index d4c462f..547dc2d 100644
--- a/library/app/src/main/java/ar/com/daidalos/afiledialog/FileChooserActivity.java
+++ b/library/app/src/main/java/ar/com/daidalos/afiledialog/FileChooserActivity.java
@@ -70,7 +70,13 @@ public class FileChooserActivity extends Activity implements FileChooser {
* a boolean that indicates if the user can create files.
*/
public static final String INPUT_CAN_CREATE_FILES = "input_can_create_files";
-
+
+ /**
+ * Constant used for represent the key of the bundle object (inside the start's intent) which contains
+ * a boolean that indicates if the cancel button must be show.
+ */
+ public static final String INPUT_SHOW_CANCEL_BUTTON = "input_show_cancel_button";
+
/**
* Constant used for represent the key of the bundle object (inside the start's intent) which contains
* a regular expression which is going to be used as a filter to determine which files can be selected.
@@ -160,6 +166,7 @@ public void onCreate(Bundle savedInstanceState) {
if(extras.containsKey(INPUT_CAN_CREATE_FILES)) core.setCanCreateFiles(extras.getBoolean(INPUT_CAN_CREATE_FILES));
if(extras.containsKey(INPUT_LABELS)) core.setLabels((FileChooserLabels) extras.get(INPUT_LABELS));
if(extras.containsKey(INPUT_SHOW_CONFIRMATION_ON_CREATE)) core.setShowConfirmationOnCreate(extras.getBoolean(INPUT_SHOW_CONFIRMATION_ON_CREATE));
+ if(extras.containsKey(INPUT_SHOW_CANCEL_BUTTON)) core.setShowCancelButton(extras.getBoolean(INPUT_SHOW_CANCEL_BUTTON));
if(extras.containsKey(INPUT_SHOW_CONFIRMATION_ON_SELECT)) core.setShowConfirmationOnSelect(extras.getBoolean(INPUT_SHOW_CONFIRMATION_ON_SELECT));
if(extras.containsKey(INPUT_SHOW_FULL_PATH_IN_TITLE)) core.setShowFullPathInTitle(extras.getBoolean(INPUT_SHOW_FULL_PATH_IN_TITLE));
if(extras.containsKey(INPUT_USE_BACK_BUTTON_TO_NAVIGATE)) this.useBackButton = extras.getBoolean(INPUT_USE_BACK_BUTTON_TO_NAVIGATE);
@@ -193,6 +200,14 @@ public void onFileSelected(File file) {
finish();
}
});
+
+ // Add a listener for when the cancel button is pressed.
+ core.addListener(new FileChooserCore.OnCancelListener() {
+ public void onCancel() {
+ // Close activity.
+ FileChooserActivity.super.onBackPressed();
+ }
+ });
}
/** Called when the user push the 'back' button. */
diff --git a/library/app/src/main/java/ar/com/daidalos/afiledialog/FileChooserCore.java b/library/app/src/main/java/ar/com/daidalos/afiledialog/FileChooserCore.java
index f233e88..df9b0eb 100644
--- a/library/app/src/main/java/ar/com/daidalos/afiledialog/FileChooserCore.java
+++ b/library/app/src/main/java/ar/com/daidalos/afiledialog/FileChooserCore.java
@@ -51,8 +51,13 @@ class FileChooserCore {
/**
* The listeners for the event of select a file.
*/
- private List listeners;
-
+ private List fileSelectedListeners;
+
+ /**
+ * The listeners for the event of select a file.
+ */
+ private List cancelListeners;
+
/**
* A regular expression for filter the files.
*/
@@ -72,7 +77,12 @@ class FileChooserCore {
* A boolean indicating if the chooser is going to be used to select folders.
*/
private boolean folderMode;
-
+
+ /**
+ * A boolean indicating if the chooser is going to be used to select folders.
+ */
+ private boolean showCancelButton;
+
/**
* A file that indicates the folder that is currently being displayed.
*/
@@ -122,7 +132,8 @@ class FileChooserCore {
public FileChooserCore(FileChooser fileChooser) {
// Initialize attributes.
this.chooser = fileChooser;
- this.listeners = new LinkedList();
+ this.fileSelectedListeners = new LinkedList();
+ this.cancelListeners = new LinkedList();
this.filter = null;
this.showOnlySelectable = false;
this.setCanCreateFiles(false);
@@ -132,13 +143,16 @@ public FileChooserCore(FileChooser fileChooser) {
this.showConfirmationOnCreate = false;
this.showConfirmationOnSelect = false;
this.showFullPathInTitle = false;
-
- // Add listener for the buttons.
+ this.showCancelButton = false;
+
+ // Add listener for the buttons.
LinearLayout root = this.chooser.getRootLayout();
Button addButton = (Button) root.findViewById(R.id.buttonAdd);
addButton.setOnClickListener(addButtonClickListener);
Button okButton = (Button) root.findViewById(R.id.buttonOk);
okButton.setOnClickListener(okButtonClickListener);
+ Button cancelButton = (Button) root.findViewById(R.id.buttonCancel);
+ cancelButton.setOnClickListener(cancelButtonClickListener);
}
// ----- Events methods ----- //
@@ -178,7 +192,7 @@ public void onClick(DialogInterface dialog, int whichButton) {
// Verify if a value has been entered.
if(fileName != null && fileName.length() > 0) {
// Notify the listeners.
- FileChooserCore.this.notifyListeners(FileChooserCore.this.currentFolder, fileName);
+ FileChooserCore.this.notifyFileListeners(FileChooserCore.this.currentFolder, fileName);
}
}
});
@@ -199,10 +213,20 @@ public void onClick(DialogInterface dialog, int whichButton) {
private View.OnClickListener okButtonClickListener = new View.OnClickListener() {
public void onClick(View v) {
// Notify the listeners.
- FileChooserCore.this.notifyListeners(FileChooserCore.this.currentFolder, null);
+ FileChooserCore.this.notifyFileListeners(FileChooserCore.this.currentFolder, null);
}
};
-
+
+ /**
+ * Implementation of the click listener for when the cancel button is clicked.
+ */
+ private View.OnClickListener cancelButtonClickListener = new View.OnClickListener() {
+ public void onClick(View v) {
+ // Notify the listeners.
+ FileChooserCore.this.notifyCancelListeners();
+ }
+ };
+
/**
* Implementation of the click listener for when a file item is clicked.
*/
@@ -215,7 +239,7 @@ public void onClick(FileItem source) {
FileChooserCore.this.loadFolder(file);
} else {
// Notify the listeners.
- FileChooserCore.this.notifyListeners(file, null);
+ FileChooserCore.this.notifyFileListeners(file, null);
}
}
};
@@ -226,7 +250,7 @@ public void onClick(FileItem source) {
* @param listener The listener to add.
*/
public void addListener(OnFileSelectedListener listener) {
- this.listeners.add(listener);
+ this.fileSelectedListeners.add(listener);
}
/**
@@ -235,16 +259,35 @@ public void addListener(OnFileSelectedListener listener) {
* @param listener The listener to remove.
*/
public void removeListener(OnFileSelectedListener listener) {
- this.listeners.remove(listener);
- }
-
- /**
- * Removes all the listeners for the event of a file selected.
- */
- public void removeAllListeners() {
- this.listeners.clear();
+ this.fileSelectedListeners.remove(listener);
}
-
+
+ /**
+ * Add a listener for the event of a file selected.
+ *
+ * @param listener The listener to add.
+ */
+ public void addListener(OnCancelListener listener) {
+ this.cancelListeners.add(listener);
+ }
+
+ /**
+ * Removes a listener for the event of a file selected.
+ *
+ * @param listener The listener to remove.
+ */
+ public void removeListener(OnCancelListener listener) {
+ this.cancelListeners.remove(listener);
+ }
+
+ /**
+ * Removes all the listeners for the event of a file selected.
+ */
+ public void removeAllListeners() {
+ this.fileSelectedListeners.clear();
+ this.cancelListeners.clear();
+ }
+
/**
* Interface definition for a callback to be invoked when a file is selected.
*/
@@ -264,14 +307,33 @@ public interface OnFileSelectedListener {
*/
void onFileSelected(File folder, String name);
}
-
+
+ /**
+ * Interface definition for a callback to be invoked when the cancel button is clicked.
+ */
+ public interface OnCancelListener {
+ /**
+ * Called when the cancel button is clicked.
+ */
+ void onCancel();
+ }
+
+ /**
+ * Notify to all listeners that the cancel button has been pressed.
+ */
+ private void notifyCancelListeners() {
+ for(int i=0; i 0;
@@ -301,11 +363,11 @@ private void notifyListeners(final File file, final String name) {
alert.setPositiveButton(posButton, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Notify to listeners.
- for(int i=0; i
-
+
+
+
\ No newline at end of file
diff --git a/library/library.iml b/library/library.iml
index bfb1daa..8ff71cb 100644
--- a/library/library.iml
+++ b/library/library.iml
@@ -8,12 +8,12 @@
-
+
-
+
\ No newline at end of file