/** * Cancel running task if there is at the moment. * Launch new task specified as parameter. * * @param task task to start, also will be saved for future restarts */ public void restart(BackgroundTask<T, V> task) { cancel(); this.task = task; taskHandler = backgroundWorker.handle(task); taskHandler.execute(); }
@ExecutedOnUIThread protected final void process(List<T> chunks) { runnableTask.progress(chunks); // Notify listeners for (BackgroundTask.ProgressListener<T, V> listener : runnableTask.getProgressListeners()) { listener.onProgress(chunks); } }
@Override public T getItem() { backgroundWorker.checkUIAccess(); return state == State.VALID ? item : null; }
/** * Cancel running task if there is any. */ public void cancel() { if (taskHandler != null) taskHandler.cancel(); } }
public void asyncReloadAppFolders() { if (appFoldersTree == null) return; folderUpdateBackgroundTaskWrapper.restart(); }
@Override public void progress(List<T> changes) { wrappedTask.progress(changes); }
@Override public Map<String, Object> getParams() { return wrappedTask.getParams(); }
public void cancel() { connectionTaskWrapper.cancel(); }
@Override public V run(TaskLifeCycle<T> lifeCycle) throws Exception { return wrappedTask.run(lifeCycle); }
@ExecutedOnUIThread boolean cancelExecution();
protected LocalizedTaskWrapper(BackgroundTask<T, V> wrappedTask, Screen screen) { super(wrappedTask.getTimeoutSeconds(), screen); this.wrappedTask = wrappedTask; this.screen = screen; }
@Nullable @Override public T getItemIfValid() { backgroundWorker.checkUIAccess(); return state == State.VALID ? item : null; }
protected void cancelSearch() { if (handler != null) { log.debug("Cancel previous search"); handler.cancel(); handler = null; } }
@ExecutedOnUIThread void startExecution();
@Override public T getItem() { backgroundWorker.checkUIAccess(); return getState() == State.VALID ? item : null; }
@ExecutedOnUIThread V getResult();
@Override public ExceptionDialogBuilder createExceptionDialog() { backgroundWorker.checkUIAccess(); return new ExceptionDialogBuilderImpl(); }