/** * 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()); } }
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()); } }
@Override public void onComplete( final Bitmap result, MoaActionList actions, HashMap<String, String> trackingAttributes) { logger.info("onComplete: " + android.os.Debug.getNativeHeapAllocatedSize()); Tracker.recordTag( mCurrentEntry.name.name().toLowerCase(Locale.US) + ": applied", trackingAttributes); if (result != null) { if (mCurrentEffect instanceof ContentPanel) { ContentPanel panel = (ContentPanel) mCurrentEffect; final boolean changed = BitmapUtils.compareBySize(mBitmap, result); setNextBitmap(result, true, changed ? null : panel.getContentDisplayMatrix()); } else { setNextBitmap(result, false); } } else { logger.error("Error: returned bitmap is null!"); setNextBitmap(mBitmap, true); } onClose(true); if (mHiResEnabled) { // send the actions... if (null == actions) logger.error("WTF actionlist is null!!!!"); HiResService service = getService(HiResService.class); if (service.isRunning()) { service.execute(mSessionId, mApiKey, actions); } } if (null != mHiResListener) { mHiResListener.OnApplyActions(actions); } }