Skip to content

Commit

Permalink
[android] Fix invalid casting of quality option in Camera (expo#2692)
Browse files Browse the repository at this point in the history
* Fixed wrong type casting

* Add CHANGELOG entry
  • Loading branch information
Szymon20000 authored and sjchmiela committed Nov 16, 2018
1 parent 2662f50 commit 677dfd5
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public class ResolveTakenPictureAsyncTask extends AsyncTask<Void, Void, Bundle>
private static final String URI_KEY = "uri";
private static final String ID_KEY = "id";

private static final int DEFAULT_QUALITY = 1;

private Promise mPromise;
private byte[] mImageData;
private Bitmap mBitmap;
Expand All @@ -66,7 +68,12 @@ public ResolveTakenPictureAsyncTask(Bitmap bitmap, Promise promise, Map<String,
}

private int getQuality() {
return ((Number) mOptions.get(QUALITY_KEY)).intValue() * 100;
if (mOptions.get(QUALITY_KEY) instanceof Number) {
double requestedQuality = ((Number) mOptions.get(QUALITY_KEY)).doubleValue();
return (int)(requestedQuality * 100);
}

return DEFAULT_QUALITY * 100;
}

@Override
Expand Down

0 comments on commit 677dfd5

Please sign in to comment.