Search in sources :

Example 6 with LocalDataService

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();
}
Also used : LocalDataService(com.aviary.android.feather.library.services.LocalDataService)

Example 7 with LocalDataService

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);
            }
        }
    }
}
Also used : LocalDataService(com.aviary.android.feather.library.services.LocalDataService) Uri(android.net.Uri)

Example 8 with LocalDataService

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());
    }
}
Also used : LocalDataService(com.aviary.android.feather.library.services.LocalDataService) HiResService(com.aviary.android.feather.library.services.HiResService)

Example 9 with LocalDataService

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());
    }
}
Also used : LocalDataService(com.aviary.android.feather.library.services.LocalDataService) HiResService(com.aviary.android.feather.library.services.HiResService)

Example 10 with LocalDataService

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);
    }
}
Also used : LocalDataService(com.aviary.android.feather.library.services.LocalDataService) Bundle(android.os.Bundle) FeatherIntent(com.aviary.android.feather.library.content.FeatherIntent) Intent(android.content.Intent)

Aggregations

LocalDataService (com.aviary.android.feather.library.services.LocalDataService)11 Bundle (android.os.Bundle)5 Uri (android.net.Uri)4 Intent (android.content.Intent)2 FeatherIntent (com.aviary.android.feather.library.content.FeatherIntent)2 HiResService (com.aviary.android.feather.library.services.HiResService)2 IOException (java.io.IOException)2 Bitmap (android.graphics.Bitmap)1 CompressFormat (android.graphics.Bitmap.CompressFormat)1 ExifTask (com.aviary.android.feather.async_tasks.ExifTask)1 ExifInterfaceWrapper (com.aviary.android.feather.library.media.ExifInterfaceWrapper)1 FutureListener (com.aviary.android.feather.library.services.FutureListener)1 ThreadPoolService (com.aviary.android.feather.library.services.ThreadPoolService)1 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 Future (java.util.concurrent.Future)1