Skip to content

Commit

Permalink
Fix/upload (#5)
Browse files Browse the repository at this point in the history
* Fix upload in 1.81

* Fix fast reupload
  • Loading branch information
antonKalinin authored Dec 9, 2019
1 parent a35a9a4 commit 2712244
Showing 1 changed file with 34 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import android.os.Build;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.FileProvider;
import androidx.core.app.ActivityCompat;
import androidx.core.content.FileProvider;
import android.util.Base64;
import android.webkit.MimeTypeMap;

Expand Down Expand Up @@ -113,7 +113,7 @@ public class PickerModule extends ReactContextBaseJavaModule implements Activity
private Compression compression = new Compression();
private ReactApplicationContext reactContext;

private Set<Promise> updatesListeners = new HashSet<>();
// private Set<Promise> updatesListeners = new HashSet<>();
private Promise lastRegisteredPromise = null;
private Boolean wasDestroyed = false;
private WritableMap storedValue;
Expand All @@ -132,16 +132,16 @@ public class PickerModule extends ReactContextBaseJavaModule implements Activity

@Override
public void onHostResume() {
updatesListeners.clear();

if (!wasDestroyed && lastRegisteredPromise != null) {
updatesListeners.add(lastRegisteredPromise);
}
// updatesListeners.clear();
//
// if (lastRegisteredPromise != null) {
// updatesListeners.add(lastRegisteredPromise);
// }
}

@Override
public void onHostPause() {
updatesListeners.clear();
// updatesListeners.clear();
}

@Override
Expand All @@ -151,7 +151,7 @@ public void onHostDestroy() {
storedValue = null;
lastRegisteredPromise = null;

updatesListeners.clear();
// updatesListeners.clear();
}

@SuppressWarnings("unused")
Expand Down Expand Up @@ -198,20 +198,34 @@ private void invokeSuccess(final WritableMap data) {
return;
}

if (updatesListeners.size() > 0) {
for (Promise listener : updatesListeners) {
listener.resolve(copyMap(data));
}
updatesListeners.clear();
// if (updatesListeners.size() > 0) {
// for (Promise listener : updatesListeners) {
// listener.resolve(copyMap(data));
// }
// updatesListeners.clear();
// storedValue = null;
// }

if (lastRegisteredPromise != null) {
lastRegisteredPromise.resolve(copyMap(data));
lastRegisteredPromise = null;
storedValue = null;
}
}

private void invokeFailure(String code, String message) {
if (updatesListeners.size() > 0) {
for (Promise listener : updatesListeners) {
listener.reject(code, message);
}
updatesListeners.clear();
// if (updatesListeners.size() > 0) {
// for (Promise listener : updatesListeners) {
// listener.reject(code, message);
// }
// updatesListeners.clear();
// storedValue = null;
// }

if (lastRegisteredPromise != null) {
lastRegisteredPromise.reject(code, message);
lastRegisteredPromise = null;
storedValue = null;
}
}

Expand Down

0 comments on commit 2712244

Please sign in to comment.