1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
public void onResult(Activity activity, int requestCode, int resultCode, Intent data)
{
if (resultCode == Activity.RESULT_CANCELED)
{
Toast.makeText(getActivity(), "Ouverture annulee", Toast.LENGTH_LONG).show();
}
else
{
if (requestCode == 2)
{
try
{
String LATITUDE = null;
String LATITUDE_REF = null;
String LONGITUDE = null;
String LONGITUDE_REF = null;
Bitmap bitmap = MediaStore.Images.Media.getBitmap(getActivity().getContentResolver(),mFileUri);
try {
ExifInterface exif = new ExifInterface(filePath);
HashMap eventData = new HashMap();
LATITUDE = getExifTag(exif,ExifInterface.TAG_GPS_LATITUDE);
LATITUDE_REF = getExifTag(exif,ExifInterface.TAG_GPS_LATITUDE_REF);
LONGITUDE = getExifTag(exif,ExifInterface.TAG_GPS_LONGITUDE);
LONGITUDE_REF = getExifTag(exif,ExifInterface.TAG_GPS_LONGITUDE_REF);
Float Latitude = null, Longitude = null;
if((LATITUDE !=null)
&& (LATITUDE_REF !=null)
&& (LONGITUDE != null)
&& (LONGITUDE_REF !=null))
{
if(LATITUDE_REF.equals("N")){
Latitude = convertToDegree(LATITUDE);
}
else{
Latitude = 0 - convertToDegree(LATITUDE);
}
if(LONGITUDE_REF.equals("E")){
Longitude = convertToDegree(LONGITUDE);
}
else{
Longitude = 0 - convertToDegree(LONGITUDE);
}
}
eventData.put("date", getExifTag(exif,ExifInterface.TAG_DATETIME));
eventData.put("longitude", Longitude.toString());
eventData.put("latitude", Latitude.toString());
eventData.put("link", Environment.getExternalStorageDirectory().getAbsolutePath() + "/DossierFinal/tmp"+ timeStamp + ".jpg");
fireEvent("data",eventData);
performCrop();
} catch (IOException e) {
e.printStackTrace();
}
try {
Toast.makeText(getActivity(), "GET TEMP FILE > Lat > "+ LATITUDE + "Lon > " +LONGITUDE, Toast.LENGTH_LONG).show(); // Debug
Toast.makeText(getActivity(), filePath2, Toast.LENGTH_LONG).show(); // Debug
ExifInterface exif1 = new ExifInterface(filePath2);
if (lat > 0) {
exif1.setAttribute(ExifInterface.TAG_GPS_LATITUDE_REF, LATITUDE_REF);
} else {
exif1.setAttribute(ExifInterface.TAG_GPS_LATITUDE_REF, LATITUDE_REF);
}
if (lon > 0) {
exif1.setAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF, LONGITUDE_REF);
} else {
exif1.setAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF, LONGITUDE_REF);
}
exif1.setAttribute(ExifInterface.TAG_GPS_LATITUDE, LATITUDE);
exif1.setAttribute(ExifInterface.TAG_GPS_LONGITUDE, LONGITUDE);
exif1.saveAttributes();
} catch (IOException e) {
e.printStackTrace();
}
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
} |
Partager