Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit 7402c89

Browse files
theScrabiabelgardep
authored andcommitted
get flat representation from ShareeOcsResponse
1 parent fe425c8 commit 7402c89

File tree

1 file changed

+31
-2
lines changed
  • owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/responses

1 file changed

+31
-2
lines changed

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/responses/ShareeResponse.kt

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,23 @@ data class ShareeOcsResponse(
4040
val remotes: List<ShareeItem>?,
4141
@Json(name = "users")
4242
val users: List<ShareeItem>?
43-
)
43+
) {
44+
fun getFlatRepresentation()
45+
= ArrayList<ShareeItem>().apply {
46+
if(exact != null) {
47+
addAll(exact.getFlatRepresentation())
48+
}
49+
if(users != null) {
50+
addAll(users)
51+
}
52+
if(remotes != null) {
53+
addAll(remotes)
54+
}
55+
if(groups != null) {
56+
addAll(groups)
57+
}
58+
}
59+
}
4460

4561
@JsonClass(generateAdapter = true)
4662
data class ExactSharees(
@@ -50,7 +66,20 @@ data class ExactSharees(
5066
val remotes: List<ShareeItem>?,
5167
@Json(name = "users")
5268
val users: List<ShareeItem>?
53-
)
69+
) {
70+
fun getFlatRepresentation()
71+
= ArrayList<ShareeItem>().apply {
72+
if(users != null) {
73+
addAll(users)
74+
}
75+
if(remotes != null) {
76+
addAll(remotes)
77+
}
78+
if(groups != null) {
79+
addAll(groups)
80+
}
81+
}
82+
}
5483

5584
@JsonClass(generateAdapter = true)
5685
data class ShareeItem(

0 commit comments

Comments
 (0)