Skip to content

Commit

Permalink
Add async post.
Browse files Browse the repository at this point in the history
  • Loading branch information
androidquery committed Nov 19, 2012
1 parent bce6b73 commit 5cefd3d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/com/androidquery/util/AQUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -275,6 +276,11 @@ public static void post(Runnable run){
getHandler().post(run);
}

public static void post(Object handler, String method){
post(handler, method, new Class[0]);
}


public static void post(final Object handler, final String method, final Class<?>[] sig, final Object... params){
post(new Runnable() {

Expand All @@ -287,6 +293,25 @@ public void run() {
});
}

public static void postAsync(Object handler, String method){
postAsync(handler, method, new Class[0]);
}

public static void postAsync(final Object handler, final String method, final Class<?>[] sig, final Object... params){

ExecutorService exe = getFileStoreExecutor();

exe.execute(new Runnable() {

@Override
public void run() {

AQUtility.invokeHandler(handler, method, false, true, sig, params);

}
});
}

public static void removePost(Runnable run){
getHandler().removeCallbacks(run);
}
Expand Down

0 comments on commit 5cefd3d

Please sign in to comment.