use of com.birbit.android.jobqueue.messaging.message.CancelResultMessage in project android-priority-jobqueue by yigit.
the class CallbackManager method start.
private void start() {
Thread callbackThread = new Thread(new Runnable() {
@Override
public void run() {
messageQueue.consume(new MessageQueueConsumer() {
long lastDelivery = Long.MIN_VALUE;
@Override
public void onStart() {
}
@Override
public void handleMessage(Message message) {
if (message.type == Type.CALLBACK) {
CallbackMessage cm = (CallbackMessage) message;
deliverMessage(cm);
lastDelivery = timer.nanoTime();
} else if (message.type == Type.CANCEL_RESULT_CALLBACK) {
deliverCancelResult((CancelResultMessage) message);
lastDelivery = timer.nanoTime();
} else if (message.type == Type.COMMAND) {
CommandMessage command = (CommandMessage) message;
final int what = command.getWhat();
if (what == CommandMessage.QUIT) {
messageQueue.stop();
started.set(false);
} else if (what == CommandMessage.RUNNABLE) {
command.getRunnable().run();
}
} else if (message.type == Type.PUBLIC_QUERY) {
((PublicQueryMessage) message).getCallback().onResult(0);
}
}
@Override
public void onIdle() {
}
});
}
}, "job-manager-callbacks");
try {
callbackThread.start();
} catch (InternalError error) {
// process is already dying, no reason to crash for this (and hide the real crash)
JqLog.e(error, "Cannot start a thread. Looks like app is shutting down." + "See issue #294 for details.");
}
}
use of com.birbit.android.jobqueue.messaging.message.CancelResultMessage in project android-priority-jobqueue by yigit.
the class CallbackManager method notifyCancelResult.
public void notifyCancelResult(@NonNull CancelResult result, @NonNull CancelResult.AsyncCancelCallback callback) {
CancelResultMessage message = factory.obtain(CancelResultMessage.class);
message.set(callback, result);
messageQueue.post(message);
startIfNeeded();
}
Aggregations