Log task execution

pull/184/head
M66B 4 years ago
parent 1c46e16905
commit 1bd3b123d4

@ -4785,7 +4785,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
protected void onException(Bundle args, Throwable ex) { protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(getParentFragmentManager(), ex); Log.unexpectedError(getParentFragmentManager(), ex);
} }
}.setLog(false).execute(this, args, "messages:expand"); }.execute(this, args, "messages:expand");
} }
private void handleAutoClose() { private void handleAutoClose() {

@ -126,16 +126,20 @@ 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 long elapsed;
private Throwable ex; private Throwable ex;
@Override @Override
public void run() { public void run() {
// Run in background thread // Run in background thread
try { try {
if (log)
Log.i("Executing task=" + name);
long start = new Date().getTime(); long start = new Date().getTime();
data = onExecute(context, args); data = onExecute(context, args);
elapse = new Date().getTime() - start; elapsed = new Date().getTime() - start;
if (log)
Log.i("Executed task=" + name + " elapsed=" + elapsed);
} catch (Throwable ex) { } catch (Throwable ex) {
if (!(ex instanceof IllegalArgumentException)) if (!(ex instanceof IllegalArgumentException))
Log.e(ex); Log.e(ex);
@ -152,7 +156,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 + " elapse=" + elapse + " ms"); Log.i("Deliver task " + name + " state=" + state + " elapse=" + elapsed + " ms");
deliver(); deliver();
cleanup(context); cleanup(context);
} else } else

Loading…
Cancel
Save