|
|
@ -456,30 +456,36 @@ public class FragmentRules extends FragmentBase {
|
|
|
|
boolean all = args.getBoolean("all");
|
|
|
|
boolean all = args.getBoolean("all");
|
|
|
|
|
|
|
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
db.beginTransaction();
|
|
|
|
|
|
|
|
|
|
|
|
if (all) {
|
|
|
|
if (all)
|
|
|
|
db.rule().deleteRules(fid);
|
|
|
|
db.rule().deleteRules(fid);
|
|
|
|
return null;
|
|
|
|
else {
|
|
|
|
}
|
|
|
|
EntityFolder folder = db.folder().getFolder(fid);
|
|
|
|
|
|
|
|
if (folder == null)
|
|
|
|
EntityFolder folder = db.folder().getFolder(fid);
|
|
|
|
return null;
|
|
|
|
if (folder == null)
|
|
|
|
|
|
|
|
return null;
|
|
|
|
EntityFolder junk = db.folder().getFolderByType(folder.account, EntityFolder.JUNK);
|
|
|
|
|
|
|
|
if (junk == null)
|
|
|
|
EntityFolder junk = db.folder().getFolderByType(folder.account, EntityFolder.JUNK);
|
|
|
|
return null;
|
|
|
|
if (junk == null)
|
|
|
|
|
|
|
|
return null;
|
|
|
|
List<EntityRule> rules = db.rule().getRules(fid);
|
|
|
|
|
|
|
|
if (rules == null)
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (EntityRule rule : rules) {
|
|
|
|
|
|
|
|
JSONObject jaction = new JSONObject(rule.action);
|
|
|
|
|
|
|
|
int type = jaction.optInt("type", -1);
|
|
|
|
|
|
|
|
long target = jaction.optLong("target", -1);
|
|
|
|
|
|
|
|
if (type == TYPE_MOVE && target == junk.id)
|
|
|
|
|
|
|
|
db.rule().deleteRule(rule.id);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<EntityRule> rules = db.rule().getRules(fid);
|
|
|
|
db.setTransactionSuccessful();
|
|
|
|
if (rules == null)
|
|
|
|
} finally {
|
|
|
|
return null;
|
|
|
|
db.endTransaction();
|
|
|
|
|
|
|
|
|
|
|
|
for (EntityRule rule : rules) {
|
|
|
|
|
|
|
|
JSONObject jaction = new JSONObject(rule.action);
|
|
|
|
|
|
|
|
int type = jaction.optInt("type", -1);
|
|
|
|
|
|
|
|
long target = jaction.optLong("target", -1);
|
|
|
|
|
|
|
|
if (type == TYPE_MOVE && target == junk.id)
|
|
|
|
|
|
|
|
db.rule().deleteRule(rule.id);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|