mirror of
https://github.com/emanuele-f/PCAPdroid.git
synced 2026-07-03 21:21:12 +08:00
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:
parent
60460880af
commit
b8561d7316
@ -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++;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user