Added task breadcrumbs

This commit is contained in:
M66B 2019-08-22 08:44:22 +02:00
parent 4a3d266318
commit da65d6f264
3 changed files with 23 additions and 8 deletions

View File

@ -799,7 +799,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
protected void onException(Bundle args, Throwable ex) { protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(parentFragment.getFragmentManager(), ex); Helper.unexpectedError(parentFragment.getFragmentManager(), ex);
} }
}.execute(context, owner, aargs, "message:avatar"); }.setLog(false).execute(context, owner, aargs, "message:avatar");
} else } else
bindContactInfo(info, message); bindContactInfo(info, message);
@ -1122,7 +1122,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
protected void onException(Bundle args, Throwable ex) { protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(parentFragment.getFragmentManager(), ex); Helper.unexpectedError(parentFragment.getFragmentManager(), ex);
} }
}.execute(context, owner, sargs, "message:actions"); }.setLog(false).execute(context, owner, sargs, "message:actions");
// Message text // Message text
pbBody.setVisibility(suitable || message.content ? View.VISIBLE : View.GONE); pbBody.setVisibility(suitable || message.content ? View.VISIBLE : View.GONE);
@ -1309,7 +1309,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
protected void onException(Bundle args, Throwable ex) { protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(parentFragment.getFragmentManager(), ex); Helper.unexpectedError(parentFragment.getFragmentManager(), ex);
} }
}.execute(context, owner, args, "message:calendar"); }.setLog(false).execute(context, owner, args, "message:calendar");
} }
private void onActionCalendar(TupleMessageEx message, int action) { private void onActionCalendar(TupleMessageEx message, int action) {
@ -2379,7 +2379,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
args.putBoolean("show_images", show_images); args.putBoolean("show_images", show_images);
args.putBoolean("show_quotes", show_quotes); args.putBoolean("show_quotes", show_quotes);
args.putInt("zoom", zoom); args.putInt("zoom", zoom);
bodyTask.setCount(false).execute(context, owner, args, "message:body"); bodyTask.setLog(false).setCount(false).execute(context, owner, args, "message:body");
} }
} }

View File

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

View File

@ -35,7 +35,9 @@ 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.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
@ -44,6 +46,7 @@ import java.util.concurrent.Executors;
// Results will not be delivered to destroyed fragments // Results will not be delivered to destroyed fragments
public abstract class SimpleTask<T> implements LifecycleObserver { public abstract class SimpleTask<T> implements LifecycleObserver {
private boolean log = true;
private boolean count = true; private boolean count = true;
private int executing = 0; private int executing = 0;
@ -54,6 +57,11 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
static final String ACTION_TASK_COUNT = BuildConfig.APPLICATION_ID + ".ACTION_TASK_COUNT"; static final String ACTION_TASK_COUNT = BuildConfig.APPLICATION_ID + ".ACTION_TASK_COUNT";
public SimpleTask<T> setLog(boolean log) {
this.log = log;
return this;
}
public SimpleTask<T> setCount(boolean count) { public SimpleTask<T> setCount(boolean count) {
this.count = count; this.count = count;
return this; return this;
@ -158,9 +166,16 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
Log.e(ex); Log.e(ex);
} finally { } finally {
try { try {
if (ex == null) if (ex == null) {
if (log && BuildConfig.BETA_RELEASE) {
Log.i("Crumb " + name);
Map<String, String> crumb = new HashMap<>();
crumb.put("name", name);
Log.breadcrumb("task", crumb);
}
onExecuted(args, (T) data); onExecuted(args, (T) data);
else } else
onException(args, ex); onException(args, ex);
} catch (Throwable ex) { } catch (Throwable ex) {
onException(args, ex); onException(args, ex);