Closed yindetao closed 11 years ago
thanks for your great job first !!
the ANE works fine in iOS, but in android, it sometimes causes the main activity death when picking image with cropping, so I modified some code in class AirImagePickerExtensionContext, and then it works fine, I hope they could give some help.
I copied some code from here: http://www.open-open.com/lib/view/open1352201409844.html
and here is the code diff for AirImagePickerExtensionContext :
@@ -201,6 +202,7 @@ public class AirImagePickerExtensionContext extends FREContext if (_pickerActivity != null) { _pickerActivity.finish();
_pickerActivity = null; } String event = success ? "DID_FINISH_PICKING" : "DID_CANCEL";
@@ -232,8 +234,8 @@ public class AirImagePickerExtensionContext extends FREContext switch (action) { case GALLERY_ACTION:
intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*"); return Intent.createChooser(intent, "Choose Picture"); case CAMERA_ACTION:
@@ -282,6 +284,7 @@ public class AirImagePickerExtensionContext extends FREContext //-----------------------------------------------------//
PickerActivity _pickerActivity;
private Uri _cropInputUri;
private void startPickerActivityForAction(int action) { @@ -333,7 +336,8 @@ public class AirImagePickerExtensionContext extends FREContext
if (_shouldCrop) {
_cropInputUri = imageUri; startPickerActivityForAction(CROP_ACTION); } else
@@ -380,41 +384,55 @@ public class AirImagePickerExtensionContext extends FREContext
private Boolean _shouldCrop = false; private String _cropInputPath;
private String _cropOutputPath; +// private String _cropOutputPath;
private void prepareIntentForCrop(Intent intent) { // Set crop input
}
// Set crop output
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tempFile));
+// // Set crop output +// File tempFile = getTemporaryImageFile(); +// _cropOutputPath = tempFile.getAbsolutePath(); +// intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tempFile));
// Cropped image should be square (aspect ratio 1:1) intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); intent.putExtra("scale", true);
// Set crop output size
intent.putExtra("return-data", true);
private void handleResultForCrop(Intent data) { AirImagePickerExtension.log("Handle result for crop: " + data);
deleteTemporaryImageFile(_cropOutputPath);
+// _pickedImage = BitmapFactory.decodeFile(_cropOutputPath); +// +// deleteTemporaryImageFile(_cropInputPath); +// deleteTemporaryImageFile(_cropOutputPath);
Bundle extras = data.getExtras();
apologize for my poor english : )
the main activity still die, maybe the explicit property value of outputX and outputY reduced the probability. : (
thanks for your great job first !!
the ANE works fine in iOS, but in android, it sometimes causes the main activity death when picking image with cropping, so I modified some code in class AirImagePickerExtensionContext, and then it works fine, I hope they could give some help.
I copied some code from here: http://www.open-open.com/lib/view/open1352201409844.html
and here is the code diff for AirImagePickerExtensionContext :
@@ -201,6 +202,7 @@ public class AirImagePickerExtensionContext extends FREContext if (_pickerActivity != null) { _pickerActivity.finish();
@@ -232,8 +234,8 @@ public class AirImagePickerExtensionContext extends FREContext switch (action) { case GALLERY_ACTION:
@@ -282,6 +284,7 @@ public class AirImagePickerExtensionContext extends FREContext //-----------------------------------------------------//
PickerActivity _pickerActivity;
private Uri _cropInputUri;
private void startPickerActivityForAction(int action) { @@ -333,7 +336,8 @@ public class AirImagePickerExtensionContext extends FREContext
@@ -380,41 +384,55 @@ public class AirImagePickerExtensionContext extends FREContext
private Boolean _shouldCrop = false; private String _cropInputPath;
private String _cropOutputPath; +// private String _cropOutputPath;
private void prepareIntentForCrop(Intent intent) { // Set crop input
+// // Set crop output +// File tempFile = getTemporaryImageFile(); +// _cropOutputPath = tempFile.getAbsolutePath(); +// intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tempFile));
}
private void handleResultForCrop(Intent data) { AirImagePickerExtension.log("Handle result for crop: " + data);
- _pickedImage = BitmapFactory.decodeFile(_cropOutputPath);
+// _pickedImage = BitmapFactory.decodeFile(_cropOutputPath); +//
+// deleteTemporaryImageFile(_cropInputPath); +// deleteTemporaryImageFile(_cropOutputPath);
apologize for my poor english : )