Skip to content

Commit 0159423

Browse files
authored
Incrementally adding docs and initial instructions for first-time users
1 parent 9e565aa commit 0159423

1 file changed

Lines changed: 31 additions & 27 deletions

File tree

README.md

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Key features in the library include the following:
4242
ease of handling. Many of these exceptions are just wrappers around data returned by a newly
4343
spawned file picker activity and do not necessarily indicate errors in the file selection process.
4444

45-
### Screenshots of the library in action (TODO)
45+
### Screenshots of the library in action (Default theme)
4646

4747
<img src="https://raw.githubusercontent.com/maxieds/AndroidFileChooserLight/master/Screenshots/WorkingUI-Screenshot_20201112-052224.png" width="250" /><img src="" width="250" /><img src="" width="250" />
4848

@@ -125,12 +125,41 @@ that the application set the option
125125
## Sample client Java source code
126126

127127
The next examples document basic, advanced, and custom uses of the library in client code.
128+
The file chooser instance is launched via a traditional ``startActivityForResult`` call
129+
from within the client caller's code. The following is a suggestion as to how to handle
130+
the results:
131+
```java
132+
@Override
133+
public void onActivityResult(int requestCode, int resultCode, Intent data) {
134+
// Handle activity codes:
135+
// FileChooserBuilder.ACTIVITY_CODE_SELECT_FILE ||
136+
// FileChooserBuilder.ACTIVITY_CODE_SELECT_DIRECTORY_ONLY ||
137+
// ACTIVITY_CODE_SELECT_MULTIPLE_FILES:
138+
super.onActivityResult(requestCode, resultCode, data);
139+
try {
140+
selectedFilePaths = FileChooserBuilder.handleActivityResult(this, requestCode, resultCode, data);
141+
} catch (RuntimeException rte) {
142+
if (data != null) {
143+
rteErrorMsg = rte.getMessage();
144+
}
145+
if (rteErrorMsg == null) {
146+
rteErrorMsg = "Unknown reason for exception.";
147+
}
148+
}
149+
showFileChooserResultsDialog(selectedFilePaths, rteErrorMsg);
150+
}
151+
```
128152

129153
### Basic usage: Returning a file path selected by the user
130154

131155
This is a quick method to select a file and/or directory picked by the user:
132156
```java
133-
/* TODO */
157+
public void actionButtonLaunchSingleFilePickerActivity(View btnView) {
158+
FileChooserBuilder fpInst = FileChooserBuilder.getDirectoryChooserInstance(this);
159+
fpInst.showHidden(true);
160+
fpInst.setPickerInitialPath(FileChooserBuilder.BaseFolderPathType.BASE_PATH_TYPE_EXTERNAL_FILES_SCREENSHOTS);
161+
fpInst.launchFilePicker();
162+
}
134163
```
135164

136165
### Detailed list of non-display type options
@@ -144,31 +173,6 @@ These can be set using the ``AndroidFilePickerLight.Builder`` class as follows:
144173

145174
### Extending file types for filtering and sorting purposes in the picker UI
146175

147-
### Handling runtime exceptions and extending the runtime exception class (for custom error handling)
148-
149-
#### List of default exception sub-types
150-
151-
```java
152-
/* Basic interface methods to implement for subclasses: */
153-
public interface AndroidFilePickerLightException extends RuntimeException {}
154-
155-
/* Some predefined options for exceptions that can be thrown by the chooser selection activity: */
156-
public class GenericRuntimeErrorException extends AndroidFilePickerLightException { /* ... */ }
157-
public class FileIOException extends AndroidFilePickerLightException { /* ... */ }
158-
public class PermissionsErrorException extends AndroidFilePickerLightException { /* ... */ }
159-
public class AbortedByTimeoutException extends AndroidFilePickerLightException { /* ... */ }
160-
public class AbortedByUserActionException extends AndroidFilePickerLightException { /* ... */ }
161-
public class CommunicateSelectionDataException extends AndroidFilePickerLightException { /* ... */ }
162-
public class CommunicateNoDataException extends AndroidFilePickerLightException { /* ... */ }
163-
public class InvalidInitialPathException extends AndroidFilePickerLightException { /* ... */ }
164-
public class InvalidThemeResourceException extends AndroidFilePickerLightException { /* ... */ }
165-
```
166-
167-
#### Checking whether the returned file path is valid
168-
169-
#### Determine whether an idle timeout occurred to close the picker
170-
171-
#### Query whether items in the list of paths are directories versus files
172176

173177

174178
### Configuring the client theme and UI look-and-feel properties

0 commit comments

Comments
 (0)