From 8d78200d2e345760d86893e41f3039b2fac352bc Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 2 Feb 2021 12:59:59 +0100 Subject: [PATCH] Check for header conditions on execute now --- app/src/main/java/eu/faircode/email/AdapterRule.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterRule.java b/app/src/main/java/eu/faircode/email/AdapterRule.java index fc26ed5e26..5f3832dcdf 100644 --- a/app/src/main/java/eu/faircode/email/AdapterRule.java +++ b/app/src/main/java/eu/faircode/email/AdapterRule.java @@ -309,7 +309,7 @@ public class AdapterRule extends RecyclerView.Adapter { JSONObject jcondition = new JSONObject(rule.condition); JSONObject jheader = jcondition.optJSONObject("header"); if (jheader != null) - return 0; + throw new IllegalArgumentException(context.getString(R.string.title_rule_no_headers)); int applied = 0; List ids = @@ -347,7 +347,12 @@ public class AdapterRule extends RecyclerView.Adapter { @Override protected void onException(Bundle args, Throwable ex) { - Log.unexpectedError(parentFragment.getParentFragmentManager(), ex, false); + if (ex instanceof IllegalArgumentException) + Snackbar.make( + parentFragment.getView(), ex.getMessage(), Snackbar.LENGTH_LONG) + .setGestureInsetBottomIgnored(true).show(); + else + Log.unexpectedError(parentFragment.getParentFragmentManager(), ex, false); } }.execute(context, owner, args, "rule:execute"); }