private static Observable<List<File>> createFilesFromClipData(final Context context,
      final ClipData clipData, final MimeMap mimeTypeMap) {
    return Observable.defer(new Func0<Observable<List<File>>>() {
      @Override
      public Observable<List<File>> call() {
        int numOfUris = clipData.getItemCount();
        List<File> filesRetrieved = new ArrayList<>(numOfUris);

        for (int i = 0; i < numOfUris; i++) {
          Uri data = clipData.getItemAt(i).getUri();
          if (data != null) {
            try {
              filesRetrieved.add(fileFromUri(context, data, mimeTypeMap));
            } catch (Exception e) {
              logError(e);
              return Observable.error(e);
            }
          }
        }
        return Observable.just(filesRetrieved);
      }
    });
  }
private static Observable < List < File > > createFilesFromClipData ( final Context context , final ClipData clipData , final MimeMap mimeTypeMap ) { return Observable . defer ( new Func0 < Observable < List < File > > > ( ) { @ Override public Observable < List < File > > call ( ) { int numOfUris = clipData . getItemCount ( ) ; List < File > filesRetrieved = new ArrayList < > ( numOfUris ) ; for ( int i = 0 ; i < numOfUris ; i ++ ) { Uri data = clipData . getItemAt ( i ) . getUri ( ) ; if ( data != null ) { try { filesRetrieved . add ( fileFromUri ( context , data , mimeTypeMap ) ) ; } catch ( Exception e ) { logError ( e ) ; return Observable . error ( e ) ; } } } return Observable . just ( filesRetrieved ) ; } } ) ; }
/*
Create a copy of the files found under the ClipData item passed from MultiSelection, in the Library's cache folder.

You can supply mime type mapping parameter to choose which map will be used.

MIME_TYPE_MAP - The mime type of the resource will be determined by MimeTypeMap.getMimeTypeFromExtension() method.
URL_CONNECTION_MAP - The mime type of the resource will be determined by URLConnection.guessContentTypeFromName() method.