Merge pull request #7215 from osmandapp/voiceMessageParams

extract add command code to method addToCommandList()
This commit is contained in:
vshcherb 2019-07-09 17:47:43 +02:00 committed by GitHub
commit 8d4a8c4f84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 10 deletions

View file

@ -67,8 +67,13 @@ public class CommandBuilder {
}
private CommandBuilder addCommand(String name, Object... args){
addToCommandList(name, args);
Struct struct = prepareStruct(name, args);
listStruct.add(struct);
return this;
}
protected void addToCommandList(String name, Object... args) {
listCommands.add(name);
for(Object o : args) {
if(o != null) {
@ -77,7 +82,6 @@ public class CommandBuilder {
listCommands.add("");
}
}
return this;
}
public List<String> getListCommands() {

View file

@ -55,15 +55,8 @@ public class JSCommandBuilder extends CommandBuilder {
}
private JSCommandBuilder addCommand(String name, Object... args){
listCommands.add(name);
for(Object o : args) {
if(o != null) {
listCommands.add(o.toString());
} else {
listCommands.add("");
}
}
Object obj = jsScope.get(name);
addToCommandList(name, args);
Object obj = jsScope.get(name);
if (obj instanceof Function) {
Function jsFunction = (Function) obj;
Object jsResult = jsFunction.call(jsContext, jsScope, jsScope, args);