From 7402c89a18ae8f08401ffa5d9b65d98c4c178f8d Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Tue, 13 Oct 2020 11:21:37 +0200 Subject: [PATCH] get flat representation from ShareeOcsResponse --- .../shares/responses/ShareeResponse.kt | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/responses/ShareeResponse.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/responses/ShareeResponse.kt index fe3ed67c..ab779eac 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/responses/ShareeResponse.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/responses/ShareeResponse.kt @@ -40,7 +40,23 @@ data class ShareeOcsResponse( val remotes: List?, @Json(name = "users") val users: List? -) +) { + fun getFlatRepresentation() + = ArrayList().apply { + if(exact != null) { + addAll(exact.getFlatRepresentation()) + } + if(users != null) { + addAll(users) + } + if(remotes != null) { + addAll(remotes) + } + if(groups != null) { + addAll(groups) + } + } +} @JsonClass(generateAdapter = true) data class ExactSharees( @@ -50,7 +66,20 @@ data class ExactSharees( val remotes: List?, @Json(name = "users") val users: List? -) +) { + fun getFlatRepresentation() + = ArrayList().apply { + if(users != null) { + addAll(users) + } + if(remotes != null) { + addAll(remotes) + } + if(groups != null) { + addAll(groups) + } + } +} @JsonClass(generateAdapter = true) data class ShareeItem(