TP-86947 | Optimised PhotoModule
This commit is contained in:
@@ -344,9 +344,7 @@ public class PhotoModule extends ReactContextBaseJavaModule {
|
||||
private void fetchLocationAndManipulatePhoto(Activity currentActivity) {
|
||||
// If geolocation passed down by the app is not old, then proceed with that
|
||||
if (!photoText.isEmpty()) {
|
||||
currentActivity.runOnUiThread(() -> {
|
||||
continueEditingPhoto(currentActivity);
|
||||
});
|
||||
continueEditingPhoto(currentActivity);
|
||||
} else {
|
||||
// If geolocation is old, then capture a newer one and use that
|
||||
HandlerThread handlerThread = new HandlerThread("LocationThread");
|
||||
@@ -360,30 +358,26 @@ public class PhotoModule extends ReactContextBaseJavaModule {
|
||||
public void onSuccess(Double latitude, Double longitude, String timestamp) {
|
||||
// Since we're updating UI elements or resolving promises, switch back to the
|
||||
// main thread
|
||||
currentActivity.runOnUiThread(() -> {
|
||||
photoText += "Lat: " + latitude + ", Long: " + longitude;
|
||||
attributes.putString("geolocationTimestamp", timestamp);
|
||||
attributes.putString("latitude", latitude.toString());
|
||||
attributes.putString("longitude", longitude.toString());
|
||||
continueEditingPhoto(currentActivity);
|
||||
handlerThread.quitSafely();
|
||||
});
|
||||
photoText += "Lat: " + latitude + ", Long: " + longitude;
|
||||
attributes.putString("geolocationTimestamp", timestamp);
|
||||
attributes.putString("latitude", latitude.toString());
|
||||
attributes.putString("longitude", longitude.toString());
|
||||
continueEditingPhoto(currentActivity);
|
||||
handlerThread.quitSafely();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
currentActivity.runOnUiThread(() -> {
|
||||
photoText += oldGeolocationText;
|
||||
continueEditingPhoto(currentActivity);
|
||||
handlerThread.quitSafely();
|
||||
});
|
||||
photoText += oldGeolocationText;
|
||||
continueEditingPhoto(currentActivity);
|
||||
handlerThread.quitSafely();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void continueEditingPhoto (Activity activity) {
|
||||
private void continueEditingPhoto(Activity activity) {
|
||||
try {
|
||||
Bitmap originalBitmap = downscaleImage(mCurrentPhotoPath);
|
||||
originalBitmap = rotateImageIfRequired(originalBitmap, mCurrentPhotoPath);
|
||||
|
||||
Reference in New Issue
Block a user