Skip to content

Commit 3075463

Browse files
dlwetteronlineAndyScherzinger
authored andcommitted
add workaround for kotlin
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
1 parent 959e155 commit 3075463

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

lib/src/main/java/com/nextcloud/android/sso/api/NextcloudRetrofitServiceMethod.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public NextcloudRetrofitServiceMethod(String apiEndpoint, @NonNull Method method
8181
this.method = method;
8282
this.returnType = method.getGenericReturnType();
8383
Annotation[] methodAnnotations = method.getAnnotations();
84-
this.parameterAnnotationsArray = method.getParameterAnnotations();
84+
this.parameterAnnotationsArray = filterParameterAnnotations(method.getParameterAnnotations());
8585

8686
for (Annotation annotation : methodAnnotations) {
8787
parseMethodAnnotation(annotation);
@@ -104,8 +104,26 @@ public NextcloudRetrofitServiceMethod(String apiEndpoint, @NonNull Method method
104104

105105
}
106106

107+
/**
108+
* filter out empty parameter annotations (e.g. when using kotlin)
109+
* @param annotations
110+
* @return
111+
*/
112+
private Annotation[][] filterParameterAnnotations(Annotation[][] annotations) {
113+
List<Annotation[]> res = new ArrayList<>();
114+
115+
for(Annotation[] annotation : annotations) {
116+
if(annotation.length > 0) {
117+
res.add(annotation);
118+
}
119+
}
120+
121+
return res.toArray(new Annotation[res.size()][]);
122+
}
123+
107124
public T invoke(NextcloudAPI nextcloudAPI, Object[] args) throws Exception {
108-
if(parameterAnnotationsArray.length != args.length) {
125+
//if(parameterAnnotationsArray.length != args.length) {
126+
if(args.length < parameterAnnotationsArray.length) { // Ignore if too many parameters are given (e.g. when using kotlin)
109127
throw new InvalidParameterException("Expected: " + parameterAnnotationsArray.length + " params - were: " + args.length);
110128
}
111129

0 commit comments

Comments
 (0)