Search in sources :

Example 1 with FutureListener

use of com.aviary.android.feather.library.services.FutureListener in project mobile-android by photo.

the class FeatherActivity method loadExif.

/**
	 * load the original file EXIF data and store the result into the local data instance
	 */
protected void loadExif() {
    logger.log("loadExif");
    final LocalDataService data = mFilterManager.getService(LocalDataService.class);
    ThreadPoolService thread = mFilterManager.getService(ThreadPoolService.class);
    if (null != data && thread != null) {
        final String path = data.getSourceImagePath();
        FutureListener<Bundle> listener = new FutureListener<Bundle>() {

            @Override
            public void onFutureDone(Future<Bundle> future) {
                try {
                    Bundle result = future.get();
                    if (null != result) {
                        data.setOriginalExifBundle(result);
                    }
                } catch (Throwable e) {
                    e.printStackTrace();
                }
            }
        };
        if (null != path) {
            thread.submit(new ExifTask(), listener, path);
        } else {
            logger.warning("orinal file path not available");
        }
    }
}
Also used : FutureListener(com.aviary.android.feather.library.services.FutureListener) LocalDataService(com.aviary.android.feather.library.services.LocalDataService) Bundle(android.os.Bundle) ThreadPoolService(com.aviary.android.feather.library.services.ThreadPoolService) Future(java.util.concurrent.Future) ExifTask(com.aviary.android.feather.async_tasks.ExifTask)

Example 2 with FutureListener

use of com.aviary.android.feather.library.services.FutureListener in project mobile-android by photo.

the class FilterManager method updateInstalledPlugins.

private void updateInstalledPlugins(Bundle extras) {
    logger.info("updateInstalledPlugins");
    ThreadPoolService background = getService(ThreadPoolService.class);
    if (background != null) {
        final boolean externalItemsEnabled = Constants.getExternalPacksEnabled();
        FutureListener<PluginFetchTask.Result> listener = new FutureListener<PluginFetchTask.Result>() {

            @Override
            public void onFutureDone(Future<PluginFetchTask.Result> future) {
                PluginFetchTask.Result result;
                try {
                    result = future.get();
                } catch (Throwable t) {
                    logger.error(t.getMessage());
                    return;
                }
                mPluingsHandler.post(new PluginTaskCompletedRunnable(result));
            }
        };
        BackgroundCallable<Bundle, PluginFetchTask.Result> task;
        if (null == extras) {
            // first time
            task = new PluginFetchTask();
        } else {
            // when a plugin is changed
            task = new PluginUpdaterTask(externalItemsEnabled ? mPluingsHandler : null);
        }
        background.submit(task, listener, extras);
    } else {
        logger.error("failed to retrieve ThreadPoolService");
    }
}
Also used : FutureListener(com.aviary.android.feather.library.services.FutureListener) PluginFetchTask(com.aviary.android.feather.library.plugins.PluginFetchTask) Bundle(android.os.Bundle) PluginUpdaterTask(com.aviary.android.feather.library.plugins.PluginUpdaterTask) ThreadPoolService(com.aviary.android.feather.library.services.ThreadPoolService) Future(java.util.concurrent.Future)

Example 3 with FutureListener

use of com.aviary.android.feather.library.services.FutureListener in project mobile-android by photo.

the class FilterManager method updateAvailablePlugins.

private void updateAvailablePlugins() {
    logger.info("updateAvailablePlugins");
    ThreadPoolService background = getService(ThreadPoolService.class);
    if (null != background) {
        if (Constants.getExternalPacksEnabled()) {
            FutureListener<Bundle> listener = new FutureListener<Bundle>() {

                @Override
                public void onFutureDone(Future<Bundle> future) {
                    logger.log("updateAvailablePlugins::completed");
                    Bundle result = null;
                    try {
                        result = future.get();
                    } catch (Throwable t) {
                        logger.error(t.getMessage());
                        return;
                    }
                    mPluingsHandler.post(new ExternalPluginTaskCompletedRunnable(result));
                }
            };
            // submit the task to download the list of external content
            background.submit(new ExternalPacksTask(), listener, null);
        }
    }
}
Also used : FutureListener(com.aviary.android.feather.library.services.FutureListener) ExternalPacksTask(com.aviary.android.feather.library.plugins.ExternalPacksTask) Bundle(android.os.Bundle) ThreadPoolService(com.aviary.android.feather.library.services.ThreadPoolService) Future(java.util.concurrent.Future)

Aggregations

Bundle (android.os.Bundle)3 FutureListener (com.aviary.android.feather.library.services.FutureListener)3 ThreadPoolService (com.aviary.android.feather.library.services.ThreadPoolService)3 Future (java.util.concurrent.Future)3 ExifTask (com.aviary.android.feather.async_tasks.ExifTask)1 ExternalPacksTask (com.aviary.android.feather.library.plugins.ExternalPacksTask)1 PluginFetchTask (com.aviary.android.feather.library.plugins.PluginFetchTask)1 PluginUpdaterTask (com.aviary.android.feather.library.plugins.PluginUpdaterTask)1 LocalDataService (com.aviary.android.feather.library.services.LocalDataService)1