@@ -2,38 +2,40 @@ package kz.zhombie.bazaar.ui.model
2
2
3
3
import kz.garage.multimedia.store.model.*
4
4
5
- internal fun List<UIContent>.convert (contents : List <Content >): List <UIFolder > {
6
- return contents.mapNotNull { media ->
5
+ internal fun List<UIContent>.convert (contents : List <Content >): List <UIFolder > =
6
+ contents.mapNotNull { media ->
7
7
val folderId = media.folder?.id ? : return @mapNotNull null
8
- val folderDisplayName = media.folder?.displayName ? : return @mapNotNull null
9
8
val items = mapNotNull { if (it.content.folder?.id == folderId) it.content else null }
10
- UIFolder (Folder (id = folderId, displayName = folderDisplayName, items = items))
9
+ UIFolder (
10
+ folder = Folder (
11
+ id = folderId,
12
+ displayName = media.folder?.displayName ? : return @mapNotNull null ,
13
+ items = items
14
+ )
15
+ )
11
16
}
12
- }
13
17
14
- internal fun List<UIContent>.onlyImages (): UIFolder {
15
- return UIFolder (
16
- Folder (
18
+ internal fun List<UIContent>.onlyImages (): UIFolder =
19
+ UIFolder (
20
+ folder = Folder (
17
21
id = UIFolder .ALL_MEDIA_ID ,
18
22
items = mapNotNull { if (it is UIMedia && it.media is Image ) it.media else null }
19
23
),
20
- UIFolder .DisplayType .IMAGES
24
+ displayType = UIFolder .DisplayType .IMAGES
21
25
)
22
- }
23
26
24
- internal fun List<UIContent>.onlyVideos (): UIFolder {
25
- return UIFolder (
26
- Folder (
27
+ internal fun List<UIContent>.onlyVideos (): UIFolder =
28
+ UIFolder (
29
+ folder = Folder (
27
30
id = UIFolder .ALL_MEDIA_ID ,
28
31
items = mapNotNull { if (it is UIMedia && it.media is Video ) it.media else null }
29
32
),
30
- UIFolder .DisplayType .VIDEOS
33
+ displayType = UIFolder .DisplayType .VIDEOS
31
34
)
32
- }
33
35
34
- internal fun List<UIContent>.onlyImagesAndVideos (): UIFolder {
35
- return UIFolder (
36
- Folder (
36
+ internal fun List<UIContent>.onlyImagesAndVideos (): UIFolder =
37
+ UIFolder (
38
+ folder = Folder (
37
39
id = UIFolder .ALL_MEDIA_ID ,
38
40
items = mapNotNull {
39
41
if (it is UIMedia && (it.media is Image || it.media is Video )) {
@@ -43,26 +45,23 @@ internal fun List<UIContent>.onlyImagesAndVideos(): UIFolder {
43
45
}
44
46
}
45
47
),
46
- UIFolder .DisplayType .MEDIA
48
+ displayType = UIFolder .DisplayType .MEDIA
47
49
)
48
- }
49
50
50
- internal fun List<UIContent>.onlyAudios (): UIFolder {
51
- return UIFolder (
52
- Folder (
51
+ internal fun List<UIContent>.onlyAudios (): UIFolder =
52
+ UIFolder (
53
+ folder = Folder (
53
54
id = UIFolder .ALL_MEDIA_ID ,
54
55
items = mapNotNull { if (it.content is Audio ) it.content else null }
55
56
),
56
- UIFolder .DisplayType .AUDIOS
57
+ displayType = UIFolder .DisplayType .AUDIOS
57
58
)
58
- }
59
59
60
- internal fun List<UIContent>.onlyDocuments (): UIFolder {
61
- return UIFolder (
62
- Folder (
60
+ internal fun List<UIContent>.onlyDocuments (): UIFolder =
61
+ UIFolder (
62
+ folder = Folder (
63
63
id = UIFolder .ALL_MEDIA_ID ,
64
64
items = mapNotNull { if (it.content is Document ) it.content else null }
65
65
),
66
- UIFolder .DisplayType .DOCUMENTS
66
+ displayType = UIFolder .DisplayType .DOCUMENTS
67
67
)
68
- }
0 commit comments