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

Compatibility with Uri added to constant IMAGE_PATH #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,14 @@ public void onCreate(Bundle icicle) {

mImagePath = extras.getString(IMAGE_PATH);

mSaveUri = getImageUri(mImagePath);
mBitmap = getBitmap(mImagePath);
if (mImagePath != null) {
mSaveUri = getImageUri(mImagePath);
mBitmap = getBitmap(mImagePath);
}
else if (extras.containsKey(IMAGE_PATH)) {
mSaveUri = extras.getParcelable(IMAGE_PATH);
mBitmap = getBitmap(mSaveUri);
}

if (extras.containsKey(ASPECT_X) && extras.get(ASPECT_X) instanceof Integer) {

Expand Down Expand Up @@ -208,14 +214,23 @@ public void onClick(View v) {
startFaceDetection();
}

private Uri getImageUri(String path) {

return Uri.fromFile(new File(path));
private Uri getImageUri(Object path) {
if (path instanceof Uri) {
return (Uri)path;
}
else {
return Uri.fromFile(new File((String)path));
}
}

private Bitmap getBitmap(String path) {

Uri uri = getImageUri(path);
private Bitmap getBitmap(Object path) {
Uri uri = null;
if (path instanceof Uri) {
uri = (Uri)path;
}
else {
uri = getImageUri(path);
}
InputStream in = null;
try {
in = mContentResolver.openInputStream(uri);
Expand Down