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
Show 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(
...
@@ -79,8 +79,10 @@ class AlbumsContractModule @Inject constructor(
private
fun
fetchAlbumsApi
(
parentAlbumId
:
Int
)
=
private
fun
fetchAlbumsApi
(
parentAlbumId
:
Int
)
=
api
.
getAlbums
(
parentAlbumId
)
api
.
getAlbums
(
parentAlbumId
)
.
doOnNext
{
Timber
.
d
(
"raw0 $it"
)
}
.
doOnNext
{
Timber
.
d
(
"raw0 $it"
)
}
.
doOnNext
{
Timber
.
d
(
"ablums ${it.size}"
)
}
.
map
{
fromRawList
(
it
,
::
fromRaw
)
}
.
map
{
fromRawList
(
it
,
::
fromRaw
)
}
.
doOnNext
(
db
::
blockingUpsert
)
.
doOnNext
(
db
::
blockingUpsert
)
.
doOnNext
{
Timber
.
d
(
"ablums ${it.size}"
)
}
.
doOnNext
{
.
doOnNext
{
it
.
asSequence
().
map
{
album
->
it
.
asSequence
().
map
{
album
->
if
(
db
.
checkIfExistsAlbumJunction
(
album
.
id
,
parentAlbumId
)
!=
null
)
{
if
(
db
.
checkIfExistsAlbumJunction
(
album
.
id
,
parentAlbumId
)
!=
null
)
{
...
@@ -92,6 +94,7 @@ class AlbumsContractModule @Inject constructor(
...
@@ -92,6 +94,7 @@ class AlbumsContractModule @Inject constructor(
entity
entity
}.
filterNotNull
().
toList
().
also
{
junctions
->
db
.
blockingUpsert
(
junctions
)
}
}.
filterNotNull
().
toList
().
also
{
junctions
->
db
.
blockingUpsert
(
junctions
)
}
}
}
.
doOnNext
{
Timber
.
d
(
"ablums ${it.size}"
)
}
.
subscribeOn
(
Schedulers
.
io
())
.
subscribeOn
(
Schedulers
.
io
())
private
fun
fetchAlbumsDb
(
parentAlbumId
:
Int
)
=
private
fun
fetchAlbumsDb
(
parentAlbumId
:
Int
)
=
...
@@ -113,7 +116,6 @@ class AlbumsContractModule @Inject constructor(
...
@@ -113,7 +116,6 @@ class AlbumsContractModule @Inject constructor(
api
.
getWebCamsList
()
api
.
getWebCamsList
()
.
doOnNext
{
Timber
.
d
(
"raw0 $it"
)
}
.
doOnNext
{
Timber
.
d
(
"raw0 $it"
)
}
.
map
{
fromRawList
(
it
)}
.
map
{
fromRawList
(
it
)}
.
doOnNext
{
Timber
.
d
(
"mapped raw0 $it"
)
}
.
subscribeOn
(
Schedulers
.
io
())
.
subscribeOn
(
Schedulers
.
io
())
private
fun
fetchWebCams
():
Observable
<
WebCamListModel
>
=
fetchWebCamsApi
private
fun
fetchWebCams
():
Observable
<
WebCamListModel
>
=
fetchWebCamsApi
...
@@ -134,6 +136,7 @@ class AlbumsContractModule @Inject constructor(
...
@@ -134,6 +136,7 @@ class AlbumsContractModule @Inject constructor(
db
.
getPhotos
(
albumId
)
db
.
getPhotos
(
albumId
)
.
toList
()
.
toList
()
.
toObservable
()
.
toObservable
()
.
filter
{
it
.
isNotEmpty
()}
.
subscribeOn
(
Schedulers
.
io
())
.
subscribeOn
(
Schedulers
.
io
())
private
fun
fetchAlbumPhotos
(
albumId
:
Int
):
Observable
<
List
<
PhotoModel
>>
=
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
...
@@ -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.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
io.reactivex.Observable
import
java.util.concurrent.TimeUnit
import
javax.inject.Inject
import
javax.inject.Inject
/**
/**
* Created by Vladislav Bogdashkin on 09.10.2019.
* Created by Vladislav Bogdashkin on 09.10.2019.
*/
*/
class
AlbumssInteractor
@Inject
constructor
(
class
AlbumsInteractor
@Inject
constructor
(
private
val
useCase
:
AlbumsUseCase
private
val
useCase
:
AlbumsUseCase
)
{
)
{
fun
fetchHeaderAlbums
()
=
useCase
.
getProgressAlbums
()
fun
fetchHeaderAlbums
()
=
useCase
.
getProgressAlbums
()
fun
fetchAlbumPhotos
(
parentId
:
Int
):
Observable
<
List
<
AlbumSortedModel
>>
=
fun
fetchAlbumPhotos
(
parentId
:
Int
):
Observable
<
MutableList
<
AlbumSortedModel
>>
=
useCase
.
getChildAlbum
(
parentId
)
useCase
.
getChildAlbum
(
parentId
)
.
flatMapIterable
{
it
}
.
flatMap
{
.
flatMap
{
album
->
useCase
.
getPhotos
(
album
.
albumId
).
map
{
Observable
.
fromIterable
(
it
).
flatMap
{
alb
->
AlbumSortedModel
(
album
.
title
,
album
.
published
,
album
.
albumId
,
it
)
useCase
.
getPhotos
(
alb
.
albumId
).
take
(
1
)
}
}
.
map
{
photos
->
.
toList
()
AlbumSortedModel
(
.
toObservable
()
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 :
...
@@ -159,7 +159,7 @@ class AlbumsScreenController :
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
AlbumsListLoaded
)
{
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
AlbumsListLoaded
)
{
(
headersRecyclerView
.
adapter
as
AlbumsHeaderAdapter
).
setItems
(
(
headersRecyclerView
.
adapter
as
AlbumsHeaderAdapter
).
setItems
(
viewState
.
list
.
sortedByDescending
{
it
.
published
}
viewState
.
list
.
asSequence
().
sortedByDescending
{
it
.
published
}.
toList
()
)
)
headersRecyclerView
.
let
{
headersRecyclerView
.
let
{
...
@@ -180,7 +180,7 @@ class AlbumsScreenController :
...
@@ -180,7 +180,7 @@ class AlbumsScreenController :
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
AlbumsSelected
){
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
AlbumsSelected
){
(
albumsRecyclerView
.
adapter
as
AlbumListAdapter
).
setItems
(
(
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
package
com.biganto.visual.roompark.presentation.screen.albums
import
com.biganto.visual.roompark.conductor.BigantoBasePresenter
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
com.biganto.visual.roompark.util.monades.ExceptionString
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.schedulers.Schedulers
import
io.reactivex.schedulers.Schedulers
...
@@ -14,7 +14,7 @@ import javax.inject.Named
...
@@ -14,7 +14,7 @@ import javax.inject.Named
class
AlbumsScreenPresenter
@Inject
constructor
(
class
AlbumsScreenPresenter
@Inject
constructor
(
private
val
interactor
:
Albums
s
Interactor
private
val
interactor
:
AlbumsInteractor
,
@Named
(
SELECTED_ALBUM_INDEX_KEY
)
private
var
selectedIndex
:
Int
,
@Named
(
SELECTED_ALBUM_INDEX_KEY
)
private
var
selectedIndex
:
Int
)
)
:
BigantoBasePresenter
<
AlbumsScreen
,
AlbumsScreenViewState
>()
{
:
BigantoBasePresenter
<
AlbumsScreen
,
AlbumsScreenViewState
>()
{
...
@@ -28,7 +28,8 @@ class AlbumsScreenPresenter @Inject constructor(
...
@@ -28,7 +28,8 @@ class AlbumsScreenPresenter @Inject constructor(
.
map
{
AlbumsScreenViewState
.
AlbumsListLoaded
(
it
,
selectedIndex
)
}
.
map
{
AlbumsScreenViewState
.
AlbumsListLoaded
(
it
,
selectedIndex
)
}
val
fetchSelected
=
interactor
.
fetchAlbumPhotos
(
selectedIndex
)
val
fetchSelected
=
interactor
.
fetchAlbumPhotos
(
selectedIndex
)
.
map
{
AlbumsScreenViewState
.
AlbumsSelected
(
it
.
toList
())}
.
map
{
AlbumsScreenViewState
.
AlbumsSelected
(
it
)}
val
state
=
restoreStateObservable
val
state
=
restoreStateObservable
.
mergeWith
(
fetchParents
)
.
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
...
@@ -24,6 +24,7 @@ class AlbumListAdapter : CommonRecyclerAdapter<AlbumViewHolder, AlbumSortedModel
override
val
vhKlazz
=
AlbumViewHolder
::
class
override
val
vhKlazz
=
AlbumViewHolder
::
class
override
fun
getVhLayout
():
Int
=
R
.
layout
.
date_album_viewholder
override
fun
getVhLayout
():
Int
=
R
.
layout
.
date_album_viewholder
}
}
class
AlbumViewHolder
(
itemView
:
View
)
:
CommonViewHolder
<
AlbumSortedModel
>(
itemView
)
{
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