Merge pull request #68 from charpeni/jobId-progress-callback

Add property jobId to progressCallback
This commit is contained in:
Chris Dell 2016-04-13 16:37:59 +01:00
commit 23a85af821
2 changed files with 31 additions and 28 deletions

View File

@ -206,7 +206,8 @@ RCT_EXPORT_METHOD(downloadFile:(NSString *)urlStr
params.progressCallback = ^(NSNumber* contentLength, NSNumber* bytesWritten) { params.progressCallback = ^(NSNumber* contentLength, NSNumber* bytesWritten) {
[self.bridge.eventDispatcher sendAppEventWithName:[NSString stringWithFormat:@"DownloadProgress-%@", jobId] [self.bridge.eventDispatcher sendAppEventWithName:[NSString stringWithFormat:@"DownloadProgress-%@", jobId]
body:@{@"contentLength": contentLength, body:@{@"jobId": jobId,
@"contentLength": contentLength,
@"bytesWritten": bytesWritten}]; @"bytesWritten": bytesWritten}];
}; };

View File

@ -265,6 +265,8 @@ public class RNFSManager extends ReactContextBaseJavaModule {
params.onDownloadProgress = new DownloadParams.OnDownloadProgress() { params.onDownloadProgress = new DownloadParams.OnDownloadProgress() {
public void onDownloadProgress(int contentLength, int bytesWritten) { public void onDownloadProgress(int contentLength, int bytesWritten) {
WritableMap data = Arguments.createMap(); WritableMap data = Arguments.createMap();
data.putInt("jobId", jobId);
data.putInt("contentLength", contentLength); data.putInt("contentLength", contentLength);
data.putInt("bytesWritten", bytesWritten); data.putInt("bytesWritten", bytesWritten);