|
|
@ -35,6 +35,7 @@ import androidx.lifecycle.OnLifecycleEvent;
|
|
|
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
|
|
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
@ -118,13 +119,16 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
|
|
|
|
|
|
|
|
|
|
|
|
future = executor.submit(new Runnable() {
|
|
|
|
future = executor.submit(new Runnable() {
|
|
|
|
private Object data;
|
|
|
|
private Object data;
|
|
|
|
|
|
|
|
private long elapse;
|
|
|
|
private Throwable ex;
|
|
|
|
private Throwable ex;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|
// Run in background thread
|
|
|
|
// Run in background thread
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
long start = new Date().getTime();
|
|
|
|
data = onExecute(context, args);
|
|
|
|
data = onExecute(context, args);
|
|
|
|
|
|
|
|
elapse = new Date().getTime() - start;
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
if (!(ex instanceof IllegalArgumentException))
|
|
|
|
if (!(ex instanceof IllegalArgumentException))
|
|
|
|
Log.e(ex);
|
|
|
|
Log.e(ex);
|
|
|
@ -141,7 +145,7 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
|
|
|
|
cleanup(context);
|
|
|
|
cleanup(context);
|
|
|
|
} else if (state.isAtLeast(Lifecycle.State.RESUMED)) {
|
|
|
|
} else if (state.isAtLeast(Lifecycle.State.RESUMED)) {
|
|
|
|
// Inline delivery
|
|
|
|
// Inline delivery
|
|
|
|
Log.i("Deliver task " + name + " state=" + state);
|
|
|
|
Log.i("Deliver task " + name + " state=" + state + " elapse=" + elapse + " ms");
|
|
|
|
deliver();
|
|
|
|
deliver();
|
|
|
|
cleanup(context);
|
|
|
|
cleanup(context);
|
|
|
|
} else
|
|
|
|
} else
|
|
|
|