@capgo/capacitor-uploader 0.0.25 → 0.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,17 +9,14 @@ import java.util.Map;
9
9
  import net.gotev.uploadservice.UploadServiceConfig;
10
10
  import net.gotev.uploadservice.data.UploadNotificationConfig;
11
11
  import net.gotev.uploadservice.data.UploadNotificationStatusConfig;
12
- import net.gotev.uploadservice.observer.request.RequestObserverDelegate;
13
12
  import net.gotev.uploadservice.protocols.binary.BinaryUploadRequest;
14
13
 
15
14
  public class Uploader {
16
15
 
17
16
  private final Context context;
18
- private final RequestObserverDelegate delegate;
19
17
 
20
- public Uploader(Context context, RequestObserverDelegate delegate) {
18
+ public Uploader(Context context) {
21
19
  this.context = context;
22
- this.delegate = delegate;
23
20
  initializeUploadService(context);
24
21
  }
25
22
 
@@ -15,6 +15,7 @@ import java.util.Iterator;
15
15
  import java.util.Map;
16
16
  import net.gotev.uploadservice.data.UploadInfo;
17
17
  import net.gotev.uploadservice.network.ServerResponse;
18
+ import net.gotev.uploadservice.observer.request.RequestObserver;
18
19
  import net.gotev.uploadservice.observer.request.RequestObserverDelegate;
19
20
 
20
21
  @CapacitorPlugin(name = "Uploader")
@@ -48,8 +49,11 @@ public class UploaderPlugin extends Plugin {
48
49
  @Override
49
50
  public void load() {
50
51
  createNotificationChannel();
51
- implementation = new Uploader(
52
- getContext(),
52
+
53
+ // Create a request observer for all uploads
54
+ RequestObserver observer = new RequestObserver(
55
+ getContext().getApplicationContext(),
56
+ getActivity(),
53
57
  new RequestObserverDelegate() {
54
58
  @Override
55
59
  public void onProgress(Context context, UploadInfo uploadInfo) {
@@ -94,15 +98,20 @@ public class UploaderPlugin extends Plugin {
94
98
 
95
99
  @Override
96
100
  public void onCompleted(Context context, UploadInfo uploadInfo) {
97
- // This method is called after onSuccess or onError
101
+ JSObject event = new JSObject();
102
+ event.put("name", "finished");
103
+ event.put("id", uploadInfo.getUploadId());
104
+ notifyListeners("events", event);
98
105
  }
99
106
 
100
107
  @Override
101
108
  public void onCompletedWhileNotObserving() {
102
- // This method is called when the upload completes while the observer is not registered
109
+ // Handle completion while not observing if needed
103
110
  }
104
111
  }
105
112
  );
113
+
114
+ implementation = new Uploader(getContext().getApplicationContext());
106
115
  }
107
116
 
108
117
  public static String getMimeType(String url) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-uploader",
3
- "version": "0.0.25",
3
+ "version": "0.0.27",
4
4
  "description": "Upload file natively",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",