Ben Hsieh hace 7 años
padre
commit
e1cf9da54e

+ 0
- 3
src/android/src/main/java/com/RNFetchBlob/RNFetchBlobBody.java Ver fichero

@@ -21,9 +21,6 @@ import okhttp3.MediaType;
21 21
 import okhttp3.RequestBody;
22 22
 import okio.BufferedSink;
23 23
 
24
-/**
25
- * Created by wkh237 on 2016/7/11.
26
- */
27 24
 public class RNFetchBlobBody extends RequestBody{
28 25
 
29 26
     InputStream requestStream;

+ 1
- 3
src/android/src/main/java/com/RNFetchBlob/RNFetchBlobConfig.java Ver fichero

@@ -5,9 +5,7 @@ import com.facebook.react.bridge.ReadableMap;
5 5
 
6 6
 import java.util.HashMap;
7 7
 
8
-/**
9
- * Created by wkh237 on 2016/5/29.
10
- */
8
+
11 9
 public class RNFetchBlobConfig {
12 10
 
13 11
     public Boolean fileCache;

+ 0
- 4
src/android/src/main/java/com/RNFetchBlob/RNFetchBlobConst.java Ver fichero

@@ -1,10 +1,6 @@
1 1
 package com.RNFetchBlob;
2 2
 
3
-import okhttp3.MediaType;
4 3
 
5
-/**
6
- * Created by wkh237 on 2016/7/11.
7
- */
8 4
 public class RNFetchBlobConst {
9 5
     public static final String EVENT_UPLOAD_PROGRESS = "RNFetchBlobProgress-upload";
10 6
     public static final String EVENT_PROGRESS = "RNFetchBlobProgress";

+ 11
- 30
src/android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java Ver fichero

@@ -1,18 +1,11 @@
1 1
 package com.RNFetchBlob;
2 2
 
3
-import android.app.LoaderManager;
4
-import android.content.ContentResolver;
5
-import android.content.CursorLoader;
6 3
 import android.content.res.AssetFileDescriptor;
7
-import android.database.Cursor;
8
-import android.graphics.Path;
9 4
 import android.media.MediaScannerConnection;
10 5
 import android.net.Uri;
11 6
 import android.os.AsyncTask;
12 7
 import android.os.Environment;
13
-import android.os.Looper;
14 8
 import android.os.SystemClock;
15
-import android.provider.MediaStore;
16 9
 import android.util.Base64;
17 10
 
18 11
 import com.RNFetchBlob.Utils.PathResolver;
@@ -23,31 +16,19 @@ import com.facebook.react.bridge.ReactApplicationContext;
23 16
 import com.facebook.react.bridge.ReadableArray;
24 17
 import com.facebook.react.bridge.WritableArray;
25 18
 import com.facebook.react.bridge.WritableMap;
26
-import com.facebook.react.bridge.WritableNativeArray;
27 19
 import com.facebook.react.modules.core.DeviceEventManagerModule;
28 20
 
29 21
 import java.io.File;
30 22
 import java.io.FileInputStream;
31
-import java.io.FileNotFoundException;
32 23
 import java.io.FileOutputStream;
33 24
 import java.io.IOException;
34 25
 import java.io.InputStream;
35 26
 import java.io.OutputStream;
36
-import java.io.UnsupportedEncodingException;
37
-import java.net.URLDecoder;
38 27
 import java.nio.charset.Charset;
39 28
 import java.util.HashMap;
40 29
 import java.util.Map;
41 30
 import java.util.UUID;
42
-import java.util.concurrent.BlockingDeque;
43
-import java.util.concurrent.BlockingQueue;
44
-import java.util.concurrent.LinkedBlockingQueue;
45
-import java.util.concurrent.ThreadPoolExecutor;
46
-import java.util.concurrent.TimeUnit;
47
-
48
-/**
49
- * Created by wkh237 on 2016/5/26.
50
- */
31
+
51 32
 public class RNFetchBlobFS {
52 33
 
53 34
     ReactApplicationContext mCtx;
@@ -676,10 +657,10 @@ public class RNFetchBlobFS {
676 657
 
677 658
     /**
678 659
      * Create new file at path
679
-     * @param path
680
-     * @param data
681
-     * @param encoding
682
-     * @param callback
660
+     * @param path The destination path of the new file.
661
+     * @param data Initial data of the new file.
662
+     * @param encoding Encoding of initial data.
663
+     * @param callback RCT bridge callback.
683 664
      */
684 665
     static void createFile(String path, String data, String encoding, Callback callback) {
685 666
         try {
@@ -785,8 +766,8 @@ public class RNFetchBlobFS {
785 766
             return data.getBytes(Charset.forName("US-ASCII"));
786 767
         }
787 768
         else if(encoding.toLowerCase().contains("base64")) {
788
-            byte [] b = Base64.decode(data, Base64.NO_WRAP);
789
-            return b;
769
+            return Base64.decode(data, Base64.NO_WRAP);
770
+
790 771
         }
791 772
         else if(encoding.equalsIgnoreCase("utf8")) {
792 773
             return data.getBytes(Charset.forName("UTF-8"));
@@ -825,8 +806,8 @@ public class RNFetchBlobFS {
825 806
     /**
826 807
      * Get input stream of the given path, when the path is a string starts with bundle-assets://
827 808
      * the stream is created by Assets Manager, otherwise use FileInputStream.
828
-     * @param path
829
-     * @return
809
+     * @param path The file to open stream
810
+     * @return InputStream instance
830 811
      * @throws IOException
831 812
      */
832 813
     static InputStream inputStreamFromPath(String path) throws IOException {
@@ -838,8 +819,8 @@ public class RNFetchBlobFS {
838 819
 
839 820
     /**
840 821
      * Check if the asset or the file exists
841
-     * @param path
842
-     * @return
822
+     * @param path A file path URI string
823
+     * @return A boolean value represents if the path exists.
843 824
      */
844 825
     static boolean isPathExists(String path) {
845 826
         if(path.startsWith(RNFetchBlobConst.FILE_PREFIX_BUNDLE_ASSET)) {

+ 1
- 11
src/android/src/main/java/com/RNFetchBlob/RNFetchBlobPackage.java Ver fichero

@@ -1,26 +1,16 @@
1 1
 package com.RNFetchBlob;
2 2
 
3 3
 import com.facebook.react.ReactPackage;
4
-import com.facebook.react.bridge.Callback;
5 4
 import com.facebook.react.bridge.JavaScriptModule;
6 5
 import com.facebook.react.bridge.NativeModule;
7 6
 import com.facebook.react.bridge.ReactApplicationContext;
8
-import com.facebook.react.bridge.ReactContext;
9
-import com.facebook.react.bridge.ReactContextBaseJavaModule;
10
-import com.facebook.react.bridge.ReactMethod;
11
-import com.facebook.react.bridge.ReadableArray;
12
-import com.facebook.react.bridge.ReadableMap;
13
-import com.facebook.react.bridge.ReadableMapKeySetIterator;
14
-import com.facebook.react.bridge.ReadableType;
15 7
 import com.facebook.react.uimanager.ViewManager;
16 8
 
17 9
 import java.util.ArrayList;
18 10
 import java.util.Collections;
19 11
 import java.util.List;
20 12
 
21
-/**
22
- * Created by wkh237 on 2016/4/29.
23
- */
13
+
24 14
 public class RNFetchBlobPackage implements ReactPackage {
25 15
 
26 16
     @Override

+ 8
- 12
src/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java Ver fichero

@@ -48,10 +48,6 @@ import okhttp3.RequestBody;
48 48
 import okhttp3.Response;
49 49
 import okhttp3.ResponseBody;
50 50
 
51
-
52
-/**
53
- * Created by wkh237 on 2016/6/21.
54
- */
55 51
 public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
56 52
 
57 53
     enum RequestType  {
@@ -60,12 +56,12 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
60 56
         AsIs,
61 57
         WithoutBody,
62 58
         Others
63
-    };
59
+    }
64 60
 
65 61
     enum ResponseType {
66 62
         KeepInMemory,
67 63
         FileStorage
68
-    };
64
+    }
69 65
 
70 66
     public static HashMap<String, Call> taskTable = new HashMap<>();
71 67
     static HashMap<String, Boolean> progressReport = new HashMap<>();
@@ -420,7 +416,7 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
420 416
                 try {
421 417
                     // For XMLHttpRequest, automatic response data storing strategy, when response
422 418
                     // data is considered as binary data, write it to file system
423
-                    if(isBlobResp && options.auto == true) {
419
+                    if(isBlobResp && options.auto) {
424 420
                         String dest = RNFetchBlobFS.getTmpPath(ctx, taskId);
425 421
                         InputStream ins = resp.body().byteStream();
426 422
                         FileOutputStream os = new FileOutputStream(new File(dest));
@@ -503,10 +499,10 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
503 499
     }
504 500
 
505 501
     /**
506
-     * Create response information object, conatins status code, headers, etc.
507
-     * @param resp
508
-     * @param isBlobResp
509
-     * @return
502
+     * Create response information object, contains status code, headers, etc.
503
+     * @param resp Response object
504
+     * @param isBlobResp If the response is binary data
505
+     * @return Get RCT bridge object contains response information.
510 506
      */
511 507
     private WritableMap getResponseInfo(Response resp, boolean isBlobResp) {
512 508
         WritableMap info = Arguments.createMap();
@@ -543,7 +539,7 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
543 539
     /**
544 540
      * Check if response data is binary data.
545 541
      * @param resp OkHttp response.
546
-     * @return
542
+     * @return If the response data contains binary bytes
547 543
      */
548 544
     private boolean isBlobResponse(Response resp) {
549 545
         Headers h = resp.headers();

+ 1
- 3
src/android/src/main/java/com/RNFetchBlob/RNFetchBlobUtils.java Ver fichero

@@ -16,9 +16,7 @@ import javax.net.ssl.X509TrustManager;
16 16
 
17 17
 import okhttp3.OkHttpClient;
18 18
 
19
-/**
20
- * Created by wkh237 on 2016/7/11.
21
- */
19
+
22 20
 public class RNFetchBlobUtils {
23 21
 
24 22
     public static String getMD5(String input) {