예제 #1
0
  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);
      }
    }
  }
예제 #2
0
  private void openDatabase() {

    logger.info("openDatabase");

    ThreadPoolService background = getService(ThreadPoolService.class);
    if (null != background) {
      background.submit(
          new BackgroundCallable<Void, Void>() {
            @Override
            public Void call(EffectContext controller, Void param) {
              CDSService cds = controller.getService(CDSService.class);
              cds.open();
              return param;
            }
          },
          null,
          null);
    }
  }
예제 #3
0
  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");
    }
  }