Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

Commit d807f0f

Browse files
committed
Add missing Android implementation
1 parent be00a24 commit d807f0f

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

android.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,26 @@ function actionViewIntent(path:string, mime:string = 'text/plain') {
2121
if(Platform.OS === 'android')
2222
return RNFetchBlob.actionViewIntent(path, mime)
2323
else
24-
return Promise.reject('RNFetchBlob.actionViewIntent only supports Android.')
24+
return Promise.reject('RNFetchBlob.android.actionViewIntent only supports Android.')
2525
}
2626

2727
function getContentIntent(mime:string) {
2828
if(Platform.OS === 'android')
2929
return RNFetchBlob.getContentIntent(mime)
3030
else
31-
return Promise.reject('RNFetchBlob.getContentIntent only supports Android.')
31+
return Promise.reject('RNFetchBlob.android.getContentIntent only supports Android.')
32+
}
33+
34+
function addCompleteDownload(config) {
35+
if(Platform.OS === 'android')
36+
return RNFetchBlob.addCompleteDownload(config)
37+
else
38+
return Promise.reject('RNFetchBlob.android.addCompleteDownload only supports Android.')
3239
}
3340

3441

3542
export default {
3643
actionViewIntent,
37-
getContentIntent
44+
getContentIntent,
45+
addCompleteDownload
3846
}

android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java

+10-2
Original file line numberDiff line numberDiff line change
@@ -882,13 +882,21 @@ static boolean isAsset(String path) {
882882
return false;
883883
}
884884

885+
/**
886+
* Normalize the path, remove URI scheme (xxx://) so that we can handle it.
887+
* @param path URI string.
888+
* @return Normalized string
889+
*/
885890
static String normalizePath(String path) {
886891
if(path == null)
887892
return null;
888-
Uri uri = Uri.parse(path);
889-
if(uri.getScheme() == null) {
893+
if(!path.matches("\\w+\\:.*"))
890894
return path;
895+
if(path.startsWith("file://")) {
896+
return path.replace("file://", "");
891897
}
898+
899+
Uri uri = Uri.parse(path);
892900
if(path.startsWith(RNFetchBlobConst.FILE_PREFIX_BUNDLE_ASSET)) {
893901
return path;
894902
}

0 commit comments

Comments
 (0)