|
2 | 2 |
|
3 | 3 | import android.app.Activity;
|
4 | 4 | import android.app.DownloadManager;
|
| 5 | +import android.content.ActivityNotFoundException; |
5 | 6 | import android.content.Intent;
|
6 | 7 | import android.content.pm.PackageManager;
|
7 | 8 | import android.net.Uri;
|
8 | 9 | import android.os.Build;
|
| 10 | +import android.util.SparseArray; |
9 | 11 |
|
10 | 12 | import androidx.annotation.NonNull;
|
11 | 13 | import androidx.core.content.FileProvider;
|
12 | 14 |
|
13 |
| -import android.util.SparseArray; |
14 |
| -import android.content.ActivityNotFoundException; |
15 |
| - |
16 | 15 | import com.facebook.react.bridge.ActivityEventListener;
|
17 | 16 | import com.facebook.react.bridge.Callback;
|
18 | 17 | import com.facebook.react.bridge.LifecycleEventListener;
|
|
22 | 21 | import com.facebook.react.bridge.ReactMethod;
|
23 | 22 | import com.facebook.react.bridge.ReadableArray;
|
24 | 23 | import com.facebook.react.bridge.ReadableMap;
|
25 |
| - |
26 |
| -// Cookies |
27 | 24 | import com.facebook.react.bridge.WritableMap;
|
28 |
| -import com.facebook.react.modules.network.ForwardingCookieHandler; |
29 | 25 | import com.facebook.react.modules.network.CookieJarContainer;
|
| 26 | +import com.facebook.react.modules.network.ForwardingCookieHandler; |
30 | 27 | import com.facebook.react.modules.network.OkHttpClientProvider;
|
31 | 28 |
|
32 |
| -import okhttp3.JavaNetCookieJar; |
33 |
| -import okhttp3.OkHttpClient; |
34 |
| - |
35 |
| -import javax.annotation.Nullable; |
36 |
| - |
37 | 29 | import java.io.File;
|
38 | 30 | import java.util.Map;
|
39 | 31 | import java.util.concurrent.LinkedBlockingQueue;
|
40 | 32 | import java.util.concurrent.ThreadPoolExecutor;
|
41 | 33 | import java.util.concurrent.TimeUnit;
|
42 | 34 |
|
| 35 | +import javax.annotation.Nullable; |
| 36 | + |
| 37 | +import okhttp3.JavaNetCookieJar; |
| 38 | +import okhttp3.OkHttpClient; |
| 39 | + |
43 | 40 | import static android.app.Activity.RESULT_OK;
|
44 | 41 | import static com.ReactNativeBlobUtil.ReactNativeBlobUtilConst.GET_CONTENT_INTENT;
|
45 | 42 |
|
@@ -180,7 +177,7 @@ public void onHostDestroy() {
|
180 | 177 |
|
181 | 178 | @ReactMethod
|
182 | 179 | public void writeArrayChunk(final String streamId, final ReadableArray dataArray, final Callback callback) {
|
183 |
| - ReactNativeBlobUtilFS.writeArrayChunk(streamId, dataArray, callback); |
| 180 | + ReactNativeBlobUtilStream.writeArrayChunk(streamId, dataArray, callback); |
184 | 181 | }
|
185 | 182 |
|
186 | 183 | @ReactMethod
|
@@ -220,17 +217,17 @@ public void ls(String path, Promise promise) {
|
220 | 217 |
|
221 | 218 | @ReactMethod
|
222 | 219 | public void writeStream(String path, String encode, boolean append, Callback callback) {
|
223 |
| - new ReactNativeBlobUtilFS(this.getReactApplicationContext()).writeStream(path, encode, append, callback); |
| 220 | + new ReactNativeBlobUtilStream(this.getReactApplicationContext()).writeStream(path, encode, append, callback); |
224 | 221 | }
|
225 | 222 |
|
226 | 223 | @ReactMethod
|
227 | 224 | public void writeChunk(String streamId, String data, Callback callback) {
|
228 |
| - ReactNativeBlobUtilFS.writeChunk(streamId, data, callback); |
| 225 | + ReactNativeBlobUtilStream.writeChunk(streamId, data, callback); |
229 | 226 | }
|
230 | 227 |
|
231 | 228 | @ReactMethod
|
232 | 229 | public void closeStream(String streamId, Callback callback) {
|
233 |
| - ReactNativeBlobUtilFS.closeStream(streamId, callback); |
| 230 | + ReactNativeBlobUtilStream.closeStream(streamId, callback); |
234 | 231 | }
|
235 | 232 |
|
236 | 233 | @ReactMethod
|
@@ -323,7 +320,7 @@ public void readStream(final String path, final String encoding, final int buffe
|
323 | 320 | fsThreadPool.execute(new Runnable() {
|
324 | 321 | @Override
|
325 | 322 | public void run() {
|
326 |
| - ReactNativeBlobUtilFS fs = new ReactNativeBlobUtilFS(ctx); |
| 323 | + ReactNativeBlobUtilStream fs = new ReactNativeBlobUtilStream(ctx); |
327 | 324 | fs.readStream(path, encoding, bufferSize, tick, streamId);
|
328 | 325 | }
|
329 | 326 | });
|
@@ -396,7 +393,7 @@ public void addCompleteDownload(ReadableMap config, Promise promise) {
|
396 | 393 | promise.reject("EINVAL", "ReactNativeBlobUtil.addCompleteDownload config or path missing.");
|
397 | 394 | return;
|
398 | 395 | }
|
399 |
| - String path = ReactNativeBlobUtilFS.normalizePath(config.getString("path")); |
| 396 | + String path = ReactNativeBlobUtilUtils.normalizePath(config.getString("path")); |
400 | 397 | if (path == null) {
|
401 | 398 | promise.reject("EINVAL", "ReactNativeBlobUtil.addCompleteDownload can not resolve URI:" + config.getString("path"));
|
402 | 399 | return;
|
@@ -428,4 +425,5 @@ public void getSDCardDir(Promise promise) {
|
428 | 425 | public void getSDCardApplicationDir(Promise promise) {
|
429 | 426 | ReactNativeBlobUtilFS.getSDCardApplicationDir(this.getReactApplicationContext(), promise);
|
430 | 427 | }
|
| 428 | + |
431 | 429 | }
|
0 commit comments