Simplifications

This commit is contained in:
M66B 2019-06-23 10:28:33 +02:00
parent 6fb436155a
commit 935d2f0e60
2 changed files with 6 additions and 7 deletions

View File

@ -460,8 +460,8 @@ class Core {
DB db = DB.getInstance(context);
// Get arguments
long target = (jargs.length() > 0 ? jargs.getLong(0) : folder.id);
boolean autoread = (jargs.length() > 1 && jargs.getBoolean(1));
long target = jargs.optLong(0, folder.id);
boolean autoread = jargs.optBoolean(1, false);
if (target != folder.id)
throw new IllegalArgumentException("Invalid folder");
@ -582,7 +582,7 @@ class Core {
// Get arguments
long id = jargs.getLong(0);
boolean autoread = (jargs.length() > 1 && jargs.getBoolean(1));
boolean autoread = jargs.optBoolean(1, false);
// Get source message
Message imessage = ifolder.getMessageByUID(message.uid);
@ -947,8 +947,8 @@ class Core {
int sync_days = jargs.getInt(0);
int keep_days = jargs.getInt(1);
boolean download = (jargs.length() > 2 && jargs.getBoolean(2));
boolean auto_delete = (jargs.length() > 3 && jargs.getBoolean(3));
boolean download = jargs.optBoolean(2, false);
boolean auto_delete = jargs.optBoolean(3, false);
if (keep_days == sync_days)
keep_days++;

View File

@ -123,8 +123,7 @@ public class EntityOperation {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean autoread = prefs.getBoolean("autoread", false);
if (jargs.length() > 1)
autoread = (autoread && jargs.getBoolean(1));
autoread = (autoread && jargs.optBoolean(1, true));
jargs.put(1, autoread);
EntityFolder source = db.folder().getFolder(message.folder);