Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-17565]: Android - Modify image logic for Android-L + add safety c... #5990

Merged
merged 1 commit into from
Aug 27, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import android.hardware.Camera;
import android.hardware.Camera.CameraInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
Expand Down Expand Up @@ -779,17 +780,32 @@ public void onResult(Activity activity, int requestCode, int resultCode, Intent
if (requestCode != code) {
return;
}
Log.e(TAG, "OnResult called: " + resultCode);
if (resultCode == Activity.RESULT_CANCELED) {
Log.d(TAG, "OnResult called: " + resultCode, Log.DEBUG_MODE);

String path = null;
if (data != null) {
path = data.getDataString();
}
//Starting with Android-L, backing out of the gallery no longer returns cancel code, but with
//an ok code and a null path.
if (resultCode == Activity.RESULT_CANCELED || (Build.VERSION.SDK_INT >= 20 && path == null)) {
if (fCancelCallback != null) {
KrollDict response = new KrollDict();
response.putCodeAndMessage(NO_ERROR, null);
fCancelCallback.callAsync(getKrollObject(), response);
}

} else {
String path = data.getDataString();
try {
//Check for invalid path
if (path == null) {
String msg = "Image path is invalid";
Log.e(TAG, msg);
if (fErrorCallback != null) {
fErrorCallback.callAsync(getKrollObject(), createErrorResponse(UNKNOWN_ERROR, msg));
}
return;
}
if (fSuccessCallback != null) {
fSuccessCallback.callAsync(getKrollObject(), createDictForImage(path, "image/jpeg"));
}
Expand Down