Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Room Park Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vladislav Bogdashkin
Room Park Android
Commits
bf9e19df
Commit
bf9e19df
authored
Dec 12, 2019
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
collect photos to sorted list
parent
8ec0d81b
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
69 additions
and
33 deletions
+69
-33
AlbumsRepository.kt
...to/visual/roompark/data/data_provider/AlbumsRepository.kt
+8
-6
IDb.kt
...ava/com/biganto/visual/roompark/data/repository/db/IDb.kt
+1
-0
RequeryRepository.kt
.../roompark/data/repository/db/requrey/RequeryRepository.kt
+5
-0
GalleryPhoto.kt
...roompark/data/repository/db/requrey/model/GalleryPhoto.kt
+1
-1
raw2entity.kt
...anto/visual/roompark/data/repository/mapper/raw2entity.kt
+15
-13
DevProgressContract.kt
...to/visual/roompark/domain/contract/DevProgressContract.kt
+2
-0
albums.kt
...a/com/biganto/visual/roompark/domain/interactor/albums.kt
+9
-2
albums.kt
...n/java/com/biganto/visual/roompark/domain/model/albums.kt
+22
-7
feeds.kt
...in/java/com/biganto/visual/roompark/domain/model/feeds.kt
+2
-0
albumsUseCase.kt
.../biganto/visual/roompark/domain/use_case/albumsUseCase.kt
+1
-1
ScreenPresenter.kt
...al/roompark/presentation/screen/albums/ScreenPresenter.kt
+3
-3
No files found.
app/src/main/java/com/biganto/visual/roompark/data/data_provider/AlbumsRepository.kt
View file @
bf9e19df
...
@@ -42,6 +42,10 @@ class AlbumsContractModule @Inject constructor(
...
@@ -42,6 +42,10 @@ class AlbumsContractModule @Inject constructor(
TODO
(
"at current sight indeed function"
)
TODO
(
"at current sight indeed function"
)
}
}
override
fun
getAlbumPhotoList
(
albumId
:
Int
):
Observable
<
List
<
PhotoModel
>>
=
fetchAlbumPhotos
(
albumId
)
init
{
init
{
Timber
.
d
(
"Devs Repository Created"
)
Timber
.
d
(
"Devs Repository Created"
)
...
@@ -121,20 +125,18 @@ class AlbumsContractModule @Inject constructor(
...
@@ -121,20 +125,18 @@ class AlbumsContractModule @Inject constructor(
private
fun
fetchAlbumPhotosApi
(
albumId
:
Int
)
=
private
fun
fetchAlbumPhotosApi
(
albumId
:
Int
)
=
api
.
getPhotos
(
albumId
)
api
.
getPhotos
(
albumId
)
.
doOnNext
{
Timber
.
d
(
"raw0 $it"
)
}
.
doOnNext
{
Timber
.
d
(
"raw0 $it"
)
}
.
map
{
arrayListOf
<
AlbumPhotoPreviewModel
>()
}
.
map
{
fromRawList
(
it
,
::
fromRaw
)
}
// .map{ fromRawList(it,::fromRaw) }
// .map { it }
// .map { it }
//
.doOnNext(db::blockingUpsert)
.
doOnNext
(
db
::
blockingUpsert
)
.
subscribeOn
(
Schedulers
.
io
())
.
subscribeOn
(
Schedulers
.
io
())
private
fun
fetchAlbumsPhotosDb
(
albumId
:
Int
)
=
private
fun
fetchAlbumsPhotosDb
(
albumId
:
Int
)
=
db
.
get
ChildAlbum
s
(
albumId
)
db
.
get
Photo
s
(
albumId
)
.
toList
()
.
toList
()
.
toObservable
()
.
toObservable
()
.
map
{
arrayListOf
<
AlbumPhotoPreviewModel
>()
}
.
subscribeOn
(
Schedulers
.
io
())
.
subscribeOn
(
Schedulers
.
io
())
private
fun
fetchAlbumPhotos
(
albumId
:
Int
):
Observable
<
List
<
AlbumPhotoPreview
Model
>>
=
private
fun
fetchAlbumPhotos
(
albumId
:
Int
):
Observable
<
List
<
Photo
Model
>>
=
Observable
.
mergeDelayError
(
Observable
.
mergeDelayError
(
arrayListOf
(
fetchAlbumPhotosApi
(
albumId
),
fetchAlbumsPhotosDb
(
albumId
))
arrayListOf
(
fetchAlbumPhotosApi
(
albumId
),
fetchAlbumsPhotosDb
(
albumId
))
).
map
{
fromEntity
(
it
,
::
fromEntity
)
}
).
map
{
fromEntity
(
it
,
::
fromEntity
)
}
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/db/IDb.kt
View file @
bf9e19df
...
@@ -23,4 +23,5 @@ interface IDb {
...
@@ -23,4 +23,5 @@ interface IDb {
fun
checkIfExistsAlbumJunction
(
albumId
:
Int
,
parentAlbumId
:
Int
):
ImageAlbumJunctionEntity
?
fun
checkIfExistsAlbumJunction
(
albumId
:
Int
,
parentAlbumId
:
Int
):
ImageAlbumJunctionEntity
?
fun
getFeed
(
feedAlias
:
String
):
ReactiveResult
<
FeedEntity
>
fun
getFeed
(
feedAlias
:
String
):
ReactiveResult
<
FeedEntity
>
fun
getArticle
(
id
:
Int
):
ReactiveResult
<
ArticleEntity
>
fun
getArticle
(
id
:
Int
):
ReactiveResult
<
ArticleEntity
>
fun
getPhotos
(
albumId
:
Int
):
Observable
<
GalleryPhotoEntity
>
}
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/data/repository/db/requrey/RequeryRepository.kt
View file @
bf9e19df
...
@@ -82,6 +82,11 @@ class RequeryRepository @Inject constructor(
...
@@ -82,6 +82,11 @@ class RequeryRepository @Inject constructor(
.
where
(
ImageAlbumJunctionEntity
.
PARENT_ID
.
eq
(
parentId
))
.
where
(
ImageAlbumJunctionEntity
.
PARENT_ID
.
eq
(
parentId
))
.
get
().
observable
()
.
get
().
observable
()
override
fun
getPhotos
(
albumId
:
Int
):
Observable
<
GalleryPhotoEntity
>
=
store
.
select
(
GalleryPhotoEntity
::
class
)
.
where
(
GalleryPhotoEntity
.
ALBUM_ID
.
eq
(
albumId
))
.
get
().
observable
()
override
fun
fetchArticles
(
feedAlias
:
String
,
pageSize
:
Int
,
startIndex
:
Int
)
override
fun
fetchArticles
(
feedAlias
:
String
,
pageSize
:
Int
,
startIndex
:
Int
)
:
Observable
<
ArticleEntity
>
=
:
Observable
<
ArticleEntity
>
=
fetchAll
<
ArticleEntity
>()
fetchAll
<
ArticleEntity
>()
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/db/requrey/model/GalleryPhoto.kt
View file @
bf9e19df
...
@@ -21,6 +21,6 @@ interface GalleryPhoto : Persistable {
...
@@ -21,6 +21,6 @@ interface GalleryPhoto : Persistable {
val
sort
:
Int
val
sort
:
Int
val
album_id
:
Int
val
album_id
:
Int
@get
:
Convert
(
PhotoResolutionsConverter
::
class
)
@get
:
Convert
(
PhotoResolutionsConverter
::
class
)
va
l
resolutions
:
List
<
PhotoResolutions
>
va
r
resolutions
:
List
<
PhotoResolutions
>
}
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/data/repository/mapper/raw2entity.kt
View file @
bf9e19df
...
@@ -2,11 +2,9 @@ package com.biganto.visual.roompark.data.repository.mapper
...
@@ -2,11 +2,9 @@ package com.biganto.visual.roompark.data.repository.mapper
import
android.content.res.Resources
import
android.content.res.Resources
import
com.biganto.visual.roompark.data.repository.api.retrofit.raw.*
import
com.biganto.visual.roompark.data.repository.api.retrofit.raw.*
import
com.biganto.visual.roompark.data.repository.db.requrey.PhotoResolutions
import
com.biganto.visual.roompark.data.repository.db.requrey.TitledPhoto
import
com.biganto.visual.roompark.data.repository.db.requrey.TitledPhoto
import
com.biganto.visual.roompark.data.repository.db.requrey.model.ArticleEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.*
import
com.biganto.visual.roompark.data.repository.db.requrey.model.FeedEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.ImageAlbumEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.UserEntity
import
kotlin.math.max
import
kotlin.math.max
/**
/**
...
@@ -79,15 +77,19 @@ fun fromRaw(raw:ImageAlbumRaw) : ImageAlbumEntity {
...
@@ -79,15 +77,19 @@ fun fromRaw(raw:ImageAlbumRaw) : ImageAlbumEntity {
}
}
//fun fromRaw(raw:GalleryImageRaw) : GalleryPhotoEntity {
fun
fromRaw
(
raw
:
GalleryImageRaw
)
:
GalleryPhotoEntity
{
// val entity = GalleryPhotoEntity()
val
entity
=
GalleryPhotoEntity
()
// entity.setId(raw.id)
entity
.
setId
(
raw
.
id
)
// entity.setTitle(raw.title)
entity
.
setTitle
(
raw
.
title
)
// entity.setPublished(raw.date)
entity
.
setDescription
(
raw
.
description
)
// entity.setSort(raw.sort)
entity
.
setSort
(
raw
.
sort
)
// entity.setPreview(raw.preview)
entity
.
setAlbum_id
(
raw
.
album_id
)
// return entity
entity
.
resolutions
=
fromRawList
(
raw
.
resolutions
,
::
fromRaw
)
//}
return
entity
}
fun
fromRaw
(
raw
:
ResolutionRaw
)
=
PhotoResolutions
(
raw
.
res_name
,
raw
.
url
,
raw
.
width
,
raw
.
height
)
...
...
app/src/main/java/com/biganto/visual/roompark/domain/contract/DevProgressContract.kt
View file @
bf9e19df
package
com.biganto.visual.roompark.domain.contract
package
com.biganto.visual.roompark.domain.contract
import
com.biganto.visual.roompark.domain.model.*
import
com.biganto.visual.roompark.domain.model.*
import
io.reactivex.Observable
/**
/**
* Created by Vladislav Bogdashkin on 24.09.2019.
* Created by Vladislav Bogdashkin on 24.09.2019.
...
@@ -14,4 +15,5 @@ interface DevProgressContract{
...
@@ -14,4 +15,5 @@ interface DevProgressContract{
fun
getAlbumPhoto
(
photoId
:
Int
):
io
.
reactivex
.
Observable
<
PhotoModel
>
fun
getAlbumPhoto
(
photoId
:
Int
):
io
.
reactivex
.
Observable
<
PhotoModel
>
fun
getWebCamsList
():
io
.
reactivex
.
Observable
<
WebCamListModel
>
fun
getWebCamsList
():
io
.
reactivex
.
Observable
<
WebCamListModel
>
fun
getWebCamStream
(
camId
:
Int
):
io
.
reactivex
.
Observable
<
WebCamModel
>
fun
getWebCamStream
(
camId
:
Int
):
io
.
reactivex
.
Observable
<
WebCamModel
>
fun
getAlbumPhotoList
(
albumId
:
Int
):
Observable
<
List
<
PhotoModel
>>
}
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/domain/interactor/albums.kt
View file @
bf9e19df
package
com.biganto.visual.roompark.domain.interactor
package
com.biganto.visual.roompark.domain.interactor
import
com.biganto.visual.roompark.domain.model.AlbumSortedModel
import
com.biganto.visual.roompark.domain.use_case.AlbumsUseCase
import
com.biganto.visual.roompark.domain.use_case.AlbumsUseCase
import
io.reactivex.Observable
import
javax.inject.Inject
import
javax.inject.Inject
/**
/**
...
@@ -13,9 +15,14 @@ class AlbumssInteractor @Inject constructor(
...
@@ -13,9 +15,14 @@ class AlbumssInteractor @Inject constructor(
fun
fetchHeaderAlbums
()
=
useCase
.
getProgressAlbums
()
fun
fetchHeaderAlbums
()
=
useCase
.
getProgressAlbums
()
fun
fetchAlbumPhotos
(
parentId
:
Int
)
=
fun
fetchAlbumPhotos
(
parentId
:
Int
)
:
Observable
<
MutableList
<
AlbumSortedModel
>>
=
useCase
.
getChildAlbum
(
parentId
)
useCase
.
getChildAlbum
(
parentId
)
.
flatMapIterable
{
it
}
.
flatMap
{
album
->
useCase
.
getPhotos
(
album
.
albumId
).
map
{
AlbumSortedModel
(
album
.
title
,
album
.
published
,
album
.
albumId
,
it
)
}
}
.
toList
()
.
toObservable
()
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/domain/model/albums.kt
View file @
bf9e19df
package
com.biganto.visual.roompark.domain.model
package
com.biganto.visual.roompark.domain.model
import
com.biganto.visual.roompark.data.repository.db.requrey.model.GalleryPhotoEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.ImageAlbumEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.ImageAlbumEntity
import
java.util.*
import
java.util.*
...
@@ -12,6 +13,7 @@ data class AlbumPreviewModel(
...
@@ -12,6 +13,7 @@ data class AlbumPreviewModel(
val
albumId
:
Int
,
val
albumId
:
Int
,
val
parentId
:
Int
,
val
parentId
:
Int
,
val
title
:
String
,
val
title
:
String
,
val
published
:
Date
,
val
isRead
:
Boolean
val
isRead
:
Boolean
)
)
...
@@ -25,15 +27,12 @@ data class AlbumPhotoPreviewModel(
...
@@ -25,15 +27,12 @@ data class AlbumPhotoPreviewModel(
)
)
data class
AlbumSortedModel
(
data class
AlbumSortedModel
(
val
title
:
Date
,
val
title
:
String
,
val
items
:
List
<
AlbumPhotoPreviewModel
>
val
published
:
Date
,
val
albumId
:
Int
,
val
items
:
List
<
PhotoModel
>
)
)
fun
List
<
AlbumPhotoPreviewModel
>.
sortedByPublished
()
=
this
.
asSequence
().
groupBy
{
it
.
published
}.
map
{
map
->
AlbumSortedModel
(
map
.
key
,
map
.
value
)
}.
sortedByDescending
{
it
.
title
}
data class
PhotoListModel
(
val
items
:
List
<
PhotoModel
>)
data class
PhotoListModel
(
val
items
:
List
<
PhotoModel
>)
...
@@ -59,5 +58,21 @@ fun fromEntity(entity: ImageAlbumEntity):AlbumPreviewModel =
...
@@ -59,5 +58,21 @@ fun fromEntity(entity: ImageAlbumEntity):AlbumPreviewModel =
albumId
=
entity
.
id
,
albumId
=
entity
.
id
,
parentId
=
-
1
,
parentId
=
-
1
,
title
=
entity
.
title
,
title
=
entity
.
title
,
published
=
entity
.
published
,
isRead
=
false
isRead
=
false
)
)
fun
fromEntity
(
entity
:
GalleryPhotoEntity
)
=
PhotoModel
(
photoId
=
entity
.
id
,
albumId
=
entity
.
album_id
,
description
=
entity
.
description
,
sort
=
entity
.
sort
,
resolutionList
=
List
(
entity
.
resolutions
.
size
){
PhotoResolutionModel
(
resName
=
entity
.
resolutions
[
it
].
res_name
,
url
=
entity
.
resolutions
[
it
].
url
,
resWidth
=
entity
.
resolutions
[
it
].
width
,
resHeight
=
entity
.
resolutions
[
it
].
height
)}
)
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/domain/model/feeds.kt
View file @
bf9e19df
...
@@ -74,4 +74,6 @@ fun fromEntity(entity: ArticleEntity,read:Boolean) : ArticleModel =
...
@@ -74,4 +74,6 @@ fun fromEntity(entity: ArticleEntity,read:Boolean) : ArticleModel =
isRead
=
read
isRead
=
read
)
)
fun
<
E
,
M
>
fromEntity
(
raw
:
List
<
E
>,
block
:(
E
)->
M
):
List
<
M
>
=
List
(
raw
.
size
)
{
index
->
block
(
raw
[
index
])}
fun
<
E
,
M
>
fromEntity
(
raw
:
List
<
E
>,
block
:(
E
)->
M
):
List
<
M
>
=
List
(
raw
.
size
)
{
index
->
block
(
raw
[
index
])}
app/src/main/java/com/biganto/visual/roompark/domain/use_case/albumsUseCase.kt
View file @
bf9e19df
...
@@ -17,7 +17,7 @@ class AlbumsUseCase @Inject constructor(
...
@@ -17,7 +17,7 @@ class AlbumsUseCase @Inject constructor(
contract
.
getProgressAlbumList
(
parentAlbumId
)
contract
.
getProgressAlbumList
(
parentAlbumId
)
fun
getPhotos
(
parentAlbumId
:
Int
)
=
fun
getPhotos
(
parentAlbumId
:
Int
)
=
contract
.
get
ProgressAlbum
List
(
parentAlbumId
)
contract
.
get
AlbumPhoto
List
(
parentAlbumId
)
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/ScreenPresenter.kt
View file @
bf9e19df
...
@@ -28,12 +28,12 @@ class AlbumsScreenPresenter @Inject constructor(
...
@@ -28,12 +28,12 @@ class AlbumsScreenPresenter @Inject constructor(
val
fetchParents
=
interactor
.
fetchHeaderAlbums
()
val
fetchParents
=
interactor
.
fetchHeaderAlbums
()
.
map
{
AlbumsScreenViewState
.
AlbumsListLoaded
(
it
,
selectedIndex
)
}
.
map
{
AlbumsScreenViewState
.
AlbumsListLoaded
(
it
,
selectedIndex
)
}
// val fetchSelected = interactor.fetchAlbumPhotos(selectedIndex)
val
fetchSelected
=
interactor
.
fetchAlbumPhotos
(
selectedIndex
)
// .map { it.s}
.
map
{
AlbumsScreenViewState
.
AlbumsSelected
(
it
.
toList
())}
// .map { AlbumsScreenViewState.AlbumsSelected(it}
val
state
=
restoreStateObservable
val
state
=
restoreStateObservable
.
mergeWith
(
fetchParents
)
.
mergeWith
(
fetchParents
)
.
mergeWith
(
fetchSelected
)
.
subscribeOn
(
Schedulers
.
io
())
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
subscribeViewState
(
state
.
cast
(
AlbumsScreenViewState
::
class
.
java
),
AlbumsScreen
::
render
)
subscribeViewState
(
state
.
cast
(
AlbumsScreenViewState
::
class
.
java
),
AlbumsScreen
::
render
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment