aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2015-01-17 15:27:12 -0800
committerScott Jackson <daneren2005@gmail.com>2015-01-17 15:27:12 -0800
commit59612891378b0799595ec7d4875da37af14cc423 (patch)
treede7ee528c3a2e20a238ec592b60fe56a77071fb6
parent8ddcb7446b42c7892982220170954d34996c11d6 (diff)
downloaddsub-59612891378b0799595ec7d4875da37af14cc423.tar.gz
dsub-59612891378b0799595ec7d4875da37af14cc423.tar.bz2
dsub-59612891378b0799595ec7d4875da37af14cc423.zip
Add onCompletionListener method
-rw-r--r--src/github/daneren2005/dsub/util/BackgroundTask.java10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/github/daneren2005/dsub/util/BackgroundTask.java b/src/github/daneren2005/dsub/util/BackgroundTask.java
index fda881c9..9b39ac82 100644
--- a/src/github/daneren2005/dsub/util/BackgroundTask.java
+++ b/src/github/daneren2005/dsub/util/BackgroundTask.java
@@ -23,6 +23,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -46,6 +47,7 @@ public abstract class BackgroundTask<T> implements ProgressListener {
private final Context context;
protected AtomicBoolean cancelled = new AtomicBoolean(false);
protected OnCancelListener cancelListener;
+ protected Runnable onCompletionListener = null;
protected Task task;
private static final int DEFAULT_CONCURRENCY = 8;
@@ -170,6 +172,10 @@ public abstract class BackgroundTask<T> implements ProgressListener {
updateProgress(context.getResources().getString(messageId));
}
+ public void setOnCompletionListener(Runnable onCompletionListener) {
+ this.onCompletionListener = onCompletionListener;
+ }
+
protected class Task {
private Thread thread;
private AtomicBoolean taskStart = new AtomicBoolean(false);
@@ -256,6 +262,10 @@ public abstract class BackgroundTask<T> implements ProgressListener {
}
public void onDone(T result) {
done(result);
+
+ if(onCompletionListener != null) {
+ onCompletionListener.run();
+ }
}
public void onError(Throwable t) {
error(t);