use of com.aviary.android.feather.library.services.LocalDataService in project mobile-android by photo.
the class FeatherActivity method doSave.
/**
* Do save.
*
* @param bitmap
* the bitmap
*/
protected void doSave(Bitmap bitmap) {
// result extras
Bundle extras = new Bundle();
LocalDataService service = mFilterManager.getService(LocalDataService.class);
Uri saveUri = service.getDestImageUri();
// then save the image into the output uri and return it
if (saveUri != null) {
OutputStream outputStream = null;
String scheme = saveUri.getScheme();
try {
if (scheme == null) {
outputStream = new FileOutputStream(saveUri.getPath());
} else {
outputStream = getContentResolver().openOutputStream(saveUri);
}
if (outputStream != null) {
int quality = Constants.getValueFromIntent(Constants.EXTRA_OUTPUT_QUALITY, 80);
bitmap.compress(service.getOutputFormat(), quality, outputStream);
}
} catch (IOException ex) {
logger.error("Cannot open file", saveUri, ex);
} finally {
IOUtils.closeSilently(outputStream);
}
onSetResult(RESULT_OK, new Intent().setData(saveUri).putExtras(extras));
} else {
// no output uri declared, save the image in a new path
// and return it
String url = Media.insertImage(getContentResolver(), bitmap, "title", "modified with Aviary Feather");
if (url != null) {
saveUri = Uri.parse(url);
getContentResolver().notifyChange(saveUri, null);
}
onSetResult(RESULT_OK, new Intent().setData(saveUri).putExtras(extras));
}
final Bitmap b = bitmap;
mHandler.post(new Runnable() {
@Override
public void run() {
mImageView.clear();
b.recycle();
}
});
if (null != saveUri) {
saveExif(saveUri);
}
mSaving = false;
finish();
}
Aggregations