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

Commit e1cf9da

Browse files
committed
Add comments
1 parent 4a6ca38 commit e1cf9da

File tree

7 files changed

+22
-66
lines changed

7 files changed

+22
-66
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121
import okhttp3.RequestBody;
2222
import okio.BufferedSink;
2323

24-
/**
25-
* Created by wkh237 on 2016/7/11.
26-
*/
2724
public class RNFetchBlobBody extends RequestBody{
2825

2926
InputStream requestStream;

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55

66
import java.util.HashMap;
77

8-
/**
9-
* Created by wkh237 on 2016/5/29.
10-
*/
8+
119
public class RNFetchBlobConfig {
1210

1311
public Boolean fileCache;

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
package com.RNFetchBlob;
22

3-
import okhttp3.MediaType;
43

5-
/**
6-
* Created by wkh237 on 2016/7/11.
7-
*/
84
public class RNFetchBlobConst {
95
public static final String EVENT_UPLOAD_PROGRESS = "RNFetchBlobProgress-upload";
106
public static final String EVENT_PROGRESS = "RNFetchBlobProgress";

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

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
package com.RNFetchBlob;
22

3-
import android.app.LoaderManager;
4-
import android.content.ContentResolver;
5-
import android.content.CursorLoader;
63
import android.content.res.AssetFileDescriptor;
7-
import android.database.Cursor;
8-
import android.graphics.Path;
94
import android.media.MediaScannerConnection;
105
import android.net.Uri;
116
import android.os.AsyncTask;
127
import android.os.Environment;
13-
import android.os.Looper;
148
import android.os.SystemClock;
15-
import android.provider.MediaStore;
169
import android.util.Base64;
1710

1811
import com.RNFetchBlob.Utils.PathResolver;
@@ -23,31 +16,19 @@
2316
import com.facebook.react.bridge.ReadableArray;
2417
import com.facebook.react.bridge.WritableArray;
2518
import com.facebook.react.bridge.WritableMap;
26-
import com.facebook.react.bridge.WritableNativeArray;
2719
import com.facebook.react.modules.core.DeviceEventManagerModule;
2820

2921
import java.io.File;
3022
import java.io.FileInputStream;
31-
import java.io.FileNotFoundException;
3223
import java.io.FileOutputStream;
3324
import java.io.IOException;
3425
import java.io.InputStream;
3526
import java.io.OutputStream;
36-
import java.io.UnsupportedEncodingException;
37-
import java.net.URLDecoder;
3827
import java.nio.charset.Charset;
3928
import java.util.HashMap;
4029
import java.util.Map;
4130
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+
5132
public class RNFetchBlobFS {
5233

5334
ReactApplicationContext mCtx;
@@ -676,10 +657,10 @@ public void onScanCompleted(String s, Uri uri) {
676657

677658
/**
678659
* 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.
683664
*/
684665
static void createFile(String path, String data, String encoding, Callback callback) {
685666
try {
@@ -785,8 +766,8 @@ private static byte[] stringToBytes(String data, String encoding) {
785766
return data.getBytes(Charset.forName("US-ASCII"));
786767
}
787768
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+
790771
}
791772
else if(encoding.equalsIgnoreCase("utf8")) {
792773
return data.getBytes(Charset.forName("UTF-8"));
@@ -825,8 +806,8 @@ void emitFSData(String taskId, String event, String data) {
825806
/**
826807
* Get input stream of the given path, when the path is a string starts with bundle-assets://
827808
* 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
830811
* @throws IOException
831812
*/
832813
static InputStream inputStreamFromPath(String path) throws IOException {
@@ -838,8 +819,8 @@ static InputStream inputStreamFromPath(String path) throws IOException {
838819

839820
/**
840821
* 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.
843824
*/
844825
static boolean isPathExists(String path) {
845826
if(path.startsWith(RNFetchBlobConst.FILE_PREFIX_BUNDLE_ASSET)) {

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,16 @@
11
package com.RNFetchBlob;
22

33
import com.facebook.react.ReactPackage;
4-
import com.facebook.react.bridge.Callback;
54
import com.facebook.react.bridge.JavaScriptModule;
65
import com.facebook.react.bridge.NativeModule;
76
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;
157
import com.facebook.react.uimanager.ViewManager;
168

179
import java.util.ArrayList;
1810
import java.util.Collections;
1911
import java.util.List;
2012

21-
/**
22-
* Created by wkh237 on 2016/4/29.
23-
*/
13+
2414
public class RNFetchBlobPackage implements ReactPackage {
2515

2616
@Override

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

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@
4848
import okhttp3.Response;
4949
import okhttp3.ResponseBody;
5050

51-
52-
/**
53-
* Created by wkh237 on 2016/6/21.
54-
*/
5551
public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
5652

5753
enum RequestType {
@@ -60,12 +56,12 @@ enum RequestType {
6056
AsIs,
6157
WithoutBody,
6258
Others
63-
};
59+
}
6460

6561
enum ResponseType {
6662
KeepInMemory,
6763
FileStorage
68-
};
64+
}
6965

7066
public static HashMap<String, Call> taskTable = new HashMap<>();
7167
static HashMap<String, Boolean> progressReport = new HashMap<>();
@@ -420,7 +416,7 @@ private void done(Response resp) {
420416
try {
421417
// For XMLHttpRequest, automatic response data storing strategy, when response
422418
// data is considered as binary data, write it to file system
423-
if(isBlobResp && options.auto == true) {
419+
if(isBlobResp && options.auto) {
424420
String dest = RNFetchBlobFS.getTmpPath(ctx, taskId);
425421
InputStream ins = resp.body().byteStream();
426422
FileOutputStream os = new FileOutputStream(new File(dest));
@@ -503,10 +499,10 @@ public static boolean isReportUploadProgress(String taskId) {
503499
}
504500

505501
/**
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.
510506
*/
511507
private WritableMap getResponseInfo(Response resp, boolean isBlobResp) {
512508
WritableMap info = Arguments.createMap();
@@ -543,7 +539,7 @@ else if(getHeaderIgnoreCases(h, "content-type").contains("application/json")) {
543539
/**
544540
* Check if response data is binary data.
545541
* @param resp OkHttp response.
546-
* @return
542+
* @return If the response data contains binary bytes
547543
*/
548544
private boolean isBlobResponse(Response resp) {
549545
Headers h = resp.headers();

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616

1717
import okhttp3.OkHttpClient;
1818

19-
/**
20-
* Created by wkh237 on 2016/7/11.
21-
*/
19+
2220
public class RNFetchBlobUtils {
2321

2422
public static String getMD5(String input) {

0 commit comments

Comments
 (0)