Przeglądaj źródła

Add missing Android implementation

Ben Hsieh 7 lat temu
rodzic
commit
d807f0f4af

+ 11
- 3
android.js Wyświetl plik

21
   if(Platform.OS === 'android')
21
   if(Platform.OS === 'android')
22
     return RNFetchBlob.actionViewIntent(path, mime)
22
     return RNFetchBlob.actionViewIntent(path, mime)
23
   else
23
   else
24
-    return Promise.reject('RNFetchBlob.actionViewIntent only supports Android.')
24
+    return Promise.reject('RNFetchBlob.android.actionViewIntent only supports Android.')
25
 }
25
 }
26
 
26
 
27
 function getContentIntent(mime:string) {
27
 function getContentIntent(mime:string) {
28
   if(Platform.OS === 'android')
28
   if(Platform.OS === 'android')
29
     return RNFetchBlob.getContentIntent(mime)
29
     return RNFetchBlob.getContentIntent(mime)
30
   else
30
   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.')
32
 }
39
 }
33
 
40
 
34
 
41
 
35
 export default {
42
 export default {
36
   actionViewIntent,
43
   actionViewIntent,
37
-  getContentIntent
44
+  getContentIntent,
45
+  addCompleteDownload
38
 }
46
 }

+ 10
- 2
android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java Wyświetl plik

882
         return false;
882
         return false;
883
     }
883
     }
884
 
884
 
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
+     */
885
     static String normalizePath(String path) {
890
     static String normalizePath(String path) {
886
         if(path == null)
891
         if(path == null)
887
             return null;
892
             return null;
888
-        Uri uri = Uri.parse(path);
889
-        if(uri.getScheme() == null) {
893
+        if(!path.matches("\\w+\\:.*"))
890
             return path;
894
             return path;
895
+        if(path.startsWith("file://")) {
896
+            return path.replace("file://", "");
891
         }
897
         }
898
+
899
+        Uri uri = Uri.parse(path);
892
         if(path.startsWith(RNFetchBlobConst.FILE_PREFIX_BUNDLE_ASSET)) {
900
         if(path.startsWith(RNFetchBlobConst.FILE_PREFIX_BUNDLE_ASSET)) {
893
             return path;
901
             return path;
894
         }
902
         }