TP-74667 | fix
This commit is contained in:
@@ -44,6 +44,7 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.text.DateFormatSymbols;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
@@ -129,9 +130,11 @@ public class PhotoModule extends ReactContextBaseJavaModule {
|
||||
|
||||
// Get time in the format "DD MMM YYYY, HH:mm A"
|
||||
private String getTime() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy, HH:mm a", Locale.getDefault());
|
||||
Log.d("PhotoModule", "getTime: " + sdf.format(new Date()));
|
||||
return sdf.format(new Date());
|
||||
DateFormatSymbols symbols = new DateFormatSymbols(Locale.getDefault());
|
||||
symbols.setAmPmStrings(new String[] { "AM", "PM" });
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy, h:mm a", symbols);
|
||||
String formattedDate = sdf.format(new Date());
|
||||
return formattedDate;
|
||||
}
|
||||
|
||||
private Bitmap addTextToBottom(Bitmap img, Context context) {
|
||||
@@ -375,22 +378,18 @@ public class PhotoModule extends ReactContextBaseJavaModule {
|
||||
// Add a method to fetch location
|
||||
private void fetchLocationAndManipulatePhoto(Activity currentActivity) {
|
||||
Log.d("PhotoModule", "fetchLocationAndManipulatePhoto");
|
||||
// Create a HandlerThread
|
||||
HandlerThread handlerThread = new HandlerThread("LocationThread");
|
||||
handlerThread.start();
|
||||
// Create a Handler attached to the HandlerThread's Looper
|
||||
Handler locationHandler = new Handler(handlerThread.getLooper());
|
||||
|
||||
locationHandler.post(() -> {
|
||||
// If geolocation passed down by the app is not old, then proceed with that
|
||||
if (!photoText.isEmpty()) {
|
||||
currentActivity.runOnUiThread(() -> {
|
||||
continueEditingPhoto(currentActivity);
|
||||
// Consider stopping the HandlerThread when done
|
||||
handlerThread.quitSafely();
|
||||
});
|
||||
} else {
|
||||
// If geolocation is old, then capture a newer one and use that
|
||||
// If geolocation passed down by the app is not old, then proceed with that
|
||||
if (!photoText.isEmpty()) {
|
||||
currentActivity.runOnUiThread(() -> {
|
||||
continueEditingPhoto(currentActivity);
|
||||
});
|
||||
} else {
|
||||
// If geolocation is old, then capture a newer one and use that
|
||||
HandlerThread handlerThread = new HandlerThread("LocationThread");
|
||||
handlerThread.start();
|
||||
// Create a Handler attached to the HandlerThread's Looper
|
||||
Handler locationHandler = new Handler(handlerThread.getLooper());
|
||||
locationHandler.post(() -> {
|
||||
GeolocationModule geolocationModule = new GeolocationModule(getReactApplicationContext());
|
||||
geolocationModule.fetchLocation(new GeolocationModule.LocationCallbackInterface() {
|
||||
@Override
|
||||
@@ -418,8 +417,8 @@ public class PhotoModule extends ReactContextBaseJavaModule {
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
|
||||
Reference in New Issue
Block a user