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
17cfe07f
Commit
17cfe07f
authored
Dec 18, 2019
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
proper list work
parent
43eaa412
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
17 deletions
+30
-17
AlbumsRepository.kt
...to/visual/roompark/data/data_provider/AlbumsRepository.kt
+4
-1
albums.kt
...a/com/biganto/visual/roompark/domain/interactor/albums.kt
+19
-11
ScreenController.kt
...l/roompark/presentation/screen/albums/ScreenController.kt
+2
-2
ScreenPresenter.kt
...al/roompark/presentation/screen/albums/ScreenPresenter.kt
+4
-3
AlbumListAdapter.kt
...mpark/presentation/screen/albums/util/AlbumListAdapter.kt
+1
-0
No files found.
app/src/main/java/com/biganto/visual/roompark/data/data_provider/AlbumsRepository.kt
View file @
17cfe07f
...
...
@@ -79,8 +79,10 @@ class AlbumsContractModule @Inject constructor(
private
fun
fetchAlbumsApi
(
parentAlbumId
:
Int
)
=
api
.
getAlbums
(
parentAlbumId
)
.
doOnNext
{
Timber
.
d
(
"raw0 $it"
)
}
.
doOnNext
{
Timber
.
d
(
"ablums ${it.size}"
)
}
.
map
{
fromRawList
(
it
,
::
fromRaw
)
}
.
doOnNext
(
db
::
blockingUpsert
)
.
doOnNext
{
Timber
.
d
(
"ablums ${it.size}"
)
}
.
doOnNext
{
it
.
asSequence
().
map
{
album
->
if
(
db
.
checkIfExistsAlbumJunction
(
album
.
id
,
parentAlbumId
)
!=
null
)
{
...
...
@@ -92,6 +94,7 @@ class AlbumsContractModule @Inject constructor(
entity
}.
filterNotNull
().
toList
().
also
{
junctions
->
db
.
blockingUpsert
(
junctions
)
}
}
.
doOnNext
{
Timber
.
d
(
"ablums ${it.size}"
)
}
.
subscribeOn
(
Schedulers
.
io
())
private
fun
fetchAlbumsDb
(
parentAlbumId
:
Int
)
=
...
...
@@ -113,7 +116,6 @@ class AlbumsContractModule @Inject constructor(
api
.
getWebCamsList
()
.
doOnNext
{
Timber
.
d
(
"raw0 $it"
)
}
.
map
{
fromRawList
(
it
)}
.
doOnNext
{
Timber
.
d
(
"mapped raw0 $it"
)
}
.
subscribeOn
(
Schedulers
.
io
())
private
fun
fetchWebCams
():
Observable
<
WebCamListModel
>
=
fetchWebCamsApi
...
...
@@ -134,6 +136,7 @@ class AlbumsContractModule @Inject constructor(
db
.
getPhotos
(
albumId
)
.
toList
()
.
toObservable
()
.
filter
{
it
.
isNotEmpty
()}
.
subscribeOn
(
Schedulers
.
io
())
private
fun
fetchAlbumPhotos
(
albumId
:
Int
):
Observable
<
List
<
PhotoModel
>>
=
...
...
app/src/main/java/com/biganto/visual/roompark/domain/interactor/albums.kt
View file @
17cfe07f
...
...
@@ -3,26 +3,34 @@ 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
io.reactivex.Observable
import
java.util.concurrent.TimeUnit
import
javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 09.10.2019.
*/
class
AlbumssInteractor
@Inject
constructor
(
private
val
useCase
:
AlbumsUseCase
)
{
class
AlbumsInteractor
@Inject
constructor
(
private
val
useCase
:
AlbumsUseCase
)
{
fun
fetchHeaderAlbums
()
=
useCase
.
getProgressAlbums
()
fun
fetchAlbumPhotos
(
parentId
:
Int
):
Observable
<
MutableList
<
AlbumSortedModel
>>
=
fun
fetchAlbumPhotos
(
parentId
:
Int
):
Observable
<
List
<
AlbumSortedModel
>>
=
useCase
.
getChildAlbum
(
parentId
)
.
flatMapIterable
{
it
}
.
flatMap
{
album
->
useCase
.
getPhotos
(
album
.
albumId
).
map
{
AlbumSortedModel
(
album
.
title
,
album
.
published
,
album
.
albumId
,
it
)
}
}
.
toList
()
.
toObservable
()
.
flatMap
{
Observable
.
fromIterable
(
it
).
flatMap
{
alb
->
useCase
.
getPhotos
(
alb
.
albumId
).
take
(
1
)
.
map
{
photos
->
AlbumSortedModel
(
alb
.
title
,
alb
.
published
,
alb
.
albumId
,
photos
)
}
}.
toList
().
toObservable
()
}
.
debounce
(
80L
,
TimeUnit
.
MILLISECONDS
)
// to reduce double list draw effect
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/ScreenController.kt
View file @
17cfe07f
...
...
@@ -159,7 +159,7 @@ class AlbumsScreenController :
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
AlbumsListLoaded
)
{
(
headersRecyclerView
.
adapter
as
AlbumsHeaderAdapter
).
setItems
(
viewState
.
list
.
sortedByDescending
{
it
.
published
}
viewState
.
list
.
asSequence
().
sortedByDescending
{
it
.
published
}.
toList
()
)
headersRecyclerView
.
let
{
...
...
@@ -180,7 +180,7 @@ class AlbumsScreenController :
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
AlbumsSelected
){
(
albumsRecyclerView
.
adapter
as
AlbumListAdapter
).
setItems
(
viewState
.
list
.
sortedByDescending
{
it
.
published
}
viewState
.
list
.
asSequence
().
sortedByDescending
{
it
.
published
}.
toList
()
)
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/ScreenPresenter.kt
View file @
17cfe07f
package
com.biganto.visual.roompark.presentation.screen.albums
import
com.biganto.visual.roompark.conductor.BigantoBasePresenter
import
com.biganto.visual.roompark.domain.interactor.Albums
s
Interactor
import
com.biganto.visual.roompark.domain.interactor.AlbumsInteractor
import
com.biganto.visual.roompark.util.monades.ExceptionString
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.schedulers.Schedulers
...
...
@@ -14,7 +14,7 @@ import javax.inject.Named
class
AlbumsScreenPresenter
@Inject
constructor
(
private
val
interactor
:
Albums
s
Interactor
private
val
interactor
:
AlbumsInteractor
,
@Named
(
SELECTED_ALBUM_INDEX_KEY
)
private
var
selectedIndex
:
Int
)
:
BigantoBasePresenter
<
AlbumsScreen
,
AlbumsScreenViewState
>()
{
...
...
@@ -28,7 +28,8 @@ class AlbumsScreenPresenter @Inject constructor(
.
map
{
AlbumsScreenViewState
.
AlbumsListLoaded
(
it
,
selectedIndex
)
}
val
fetchSelected
=
interactor
.
fetchAlbumPhotos
(
selectedIndex
)
.
map
{
AlbumsScreenViewState
.
AlbumsSelected
(
it
.
toList
())}
.
map
{
AlbumsScreenViewState
.
AlbumsSelected
(
it
)}
val
state
=
restoreStateObservable
.
mergeWith
(
fetchParents
)
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/util/AlbumListAdapter.kt
View file @
17cfe07f
...
...
@@ -24,6 +24,7 @@ class AlbumListAdapter : CommonRecyclerAdapter<AlbumViewHolder, AlbumSortedModel
override
val
vhKlazz
=
AlbumViewHolder
::
class
override
fun
getVhLayout
():
Int
=
R
.
layout
.
date_album_viewholder
}
class
AlbumViewHolder
(
itemView
:
View
)
:
CommonViewHolder
<
AlbumSortedModel
>(
itemView
)
{
...
...
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