use of com.aviary.android.feather.library.services.LocalDataService in project mobile-android by photo.
the class FilterManager method onActivate.
/**
* On activate.
*
* @param bitmap
* the bitmap
*/
public void onActivate(final Bitmap bitmap, int[] originalSize) {
if (mCurrentState != STATE.DISABLED)
throw new IllegalStateException("Cannot activate. Already active!");
if ((mBitmap != null) && !mBitmap.isRecycled()) {
mBitmap = null;
}
mBitmap = bitmap;
LocalDataService dataService = getService(LocalDataService.class);
dataService.setSourceImageSize(originalSize);
mChanged = false;
setCurrentState(STATE.CLOSED_CONFIRMED);
initHiResService();
}
use of com.aviary.android.feather.library.services.LocalDataService in project mobile-android by photo.
the class FeatherActivity method computeOriginalFilePath.
/**
* Try to compute the original file absolute path
*/
protected void computeOriginalFilePath() {
final LocalDataService data = mFilterManager.getService(LocalDataService.class);
if (null != data) {
data.setSourceImagePath(null);
Uri uri = data.getSourceImageUri();
if (null != uri) {
String path = IOUtils.getRealFilePath(this, uri);
if (null != path) {
data.setSourceImagePath(path);
}
}
}
}
use of com.aviary.android.feather.library.services.LocalDataService in project mobile-android by photo.
the class FilterManager method initHiResService.
private void initHiResService() {
logger.info("initHiResService");
LocalDataService dataService = getService(LocalDataService.class);
if (Constants.containsValue(Constants.EXTRA_OUTPUT_HIRES_SESSION_ID)) {
mSessionId = Constants.getValueFromIntent(Constants.EXTRA_OUTPUT_HIRES_SESSION_ID, "");
logger.info("session-id: " + mSessionId + ", length: " + mSessionId.length());
if (mSessionId != null && mSessionId.length() == 64) {
mHiResEnabled = true;
HiResService service = getService(HiResService.class);
if (!service.isRunning()) {
service.start();
}
service.load(mSessionId, mApiKey, dataService.getSourceImageUri());
} else {
logger.error("session id is invalid");
}
} else {
logger.warning("missing session id");
}
if (null != mHiResListener) {
mHiResListener.OnLoad(dataService.getSourceImageUri());
}
}
use of com.aviary.android.feather.library.services.LocalDataService in project mobile-android by photo.
the class FilterManager method onReplaceImage.
/**
* Replace the current bitmap.
*
* @param bitmap
* the bitmap
*/
public void onReplaceImage(final Bitmap bitmap, int[] originalSize) {
if (!getEnabled() || !isClosed())
throw new IllegalStateException("Cannot replace bitmap. Not active nor closed!");
LocalDataService dataService = getService(LocalDataService.class);
if ((mBitmap != null) && !mBitmap.isRecycled()) {
logger.warning("[recycle] original Bitmap: " + mBitmap);
mBitmap.recycle();
mBitmap = null;
}
mChanged = false;
mBitmap = bitmap;
dataService.setSourceImageSize(originalSize);
HiResService service = getService(HiResService.class);
if (mHiResEnabled && service.isRunning()) {
service.replace(mSessionId, mApiKey, dataService.getSourceImageUri());
}
if (null != mHiResListener) {
mHiResListener.OnLoad(dataService.getSourceImageUri());
}
}
use of com.aviary.android.feather.library.services.LocalDataService in project mobile-android by photo.
the class FeatherActivity method performSave.
/**
* Perform save.
*
* @param bitmap
* the bitmap
*/
protected void performSave(final Bitmap bitmap) {
if (mSaving)
return;
mSaving = true;
Tracker.recordTag("feather: saved");
// disable the filter manager...
mFilterManager.setEnabled(false);
LocalDataService service = mFilterManager.getService(LocalDataService.class);
// Release bitmap memory
Bundle myExtras = getIntent().getExtras();
// will be encoded into the result itent
if (myExtras != null && myExtras.getBoolean(Constants.EXTRA_RETURN_DATA)) {
Bundle extras = new Bundle();
extras.putParcelable("data", bitmap);
onSetResult(RESULT_OK, new Intent().setData(service.getDestImageUri()).setAction("inline-data").putExtras(extras));
finish();
} else {
ThreadUtils.startBackgroundJob(this, null, "Saving...", new Runnable() {
@Override
public void run() {
doSave(bitmap);
}
}, mHandler);
}
}
Aggregations