Prevent crash

pull/156/head
M66B 6 years ago
parent 6703cb80ac
commit b13a7d62e2

@ -236,11 +236,23 @@ public class EntityRule {
private void onActionMove(Context context, EntityMessage message, JSONObject jargs) throws JSONException {
long target = jargs.getLong("target");
DB db = DB.getInstance(context);
EntityFolder folder = db.folder().getFolder(target);
if (folder == null)
throw new IllegalArgumentException("Rule move to folder not found");
EntityOperation.queue(context, message, EntityOperation.MOVE, target, false);
}
private void onActionCopy(Context context, EntityMessage message, JSONObject jargs) throws JSONException {
long target = jargs.getLong("target");
DB db = DB.getInstance(context);
EntityFolder folder = db.folder().getFolder(target);
if (folder == null)
throw new IllegalArgumentException("Rule copy to folder not found");
EntityOperation.queue(context, message, EntityOperation.COPY, target, false);
}

@ -837,15 +837,15 @@ public class FragmentRule extends FragmentBase {
case EntityRule.TYPE_MOVE:
case EntityRule.TYPE_COPY:
EntityFolder target = (EntityFolder) spTarget.getSelectedItem();
jaction.put("target", target.id);
jaction.put("target", target == null ? -1 : target.id);
break;
case EntityRule.TYPE_ANSWER:
EntityIdentity identity = (EntityIdentity) spIdent.getSelectedItem();
EntityAnswer answer = (EntityAnswer) spAnswer.getSelectedItem();
boolean cc = cbCc.isChecked();
jaction.put("identity", identity.id);
jaction.put("answer", answer.id);
jaction.put("identity", identity == null ? -1 : identity.id);
jaction.put("answer", answer == null ? -1 : answer.id);
jaction.put("cc", cc);
break;
}

Loading…
Cancel
Save