Fix unnecessary refreshes while loading lists

The list change listeners were called for each rule in the list

Partially addresses #284
This commit is contained in:
emanuele-f 2022-11-27 17:43:14 +01:00
parent 60460880af
commit b8561d7316

View File

@ -247,8 +247,10 @@ public class MatchList {
}
}
addRule(new Rule(type, val));
addRule(new Rule(type, val), false);
}
notifyListeners();
} catch (IllegalArgumentException | ClassCastException e) {
e.printStackTrace();
return false;
@ -292,7 +294,7 @@ public class MatchList {
return tp + "@" + val;
}
private boolean addRule(Rule rule) {
private boolean addRule(Rule rule, boolean notify) {
String value = rule.getValue().toString();
String key = matchKey(rule.getType(), value);
@ -310,17 +312,22 @@ public class MatchList {
mRules.add(rule);
mMatches.put(key, rule);
notifyListeners();
if(notify)
notifyListeners();
return true;
}
private boolean addRule(Rule rule) {
return addRule(rule, true);
}
public int addRules(MatchList to_add) {
int num_added = 0;
for(Iterator<Rule> it = to_add.iterRules(); it.hasNext(); ) {
Rule rule = it.next();
if(addRule(rule))
if(addRule(rule, false))
num_added++;
}