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
2e3f93e6
Commit
2e3f93e6
authored
Dec 20, 2019
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
albums fetch , top headers items click listener
parent
4ccf07dd
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
6 deletions
+58
-6
ScreenContract.kt
...ual/roompark/presentation/screen/albums/ScreenContract.kt
+3
-1
ScreenController.kt
...l/roompark/presentation/screen/albums/ScreenController.kt
+28
-1
ScreenPresenter.kt
...al/roompark/presentation/screen/albums/ScreenPresenter.kt
+26
-4
ScreenViewState.kt
...al/roompark/presentation/screen/albums/ScreenViewState.kt
+1
-0
No files found.
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/ScreenContract.kt
View file @
2e3f93e6
package
com.biganto.visual.roompark.presentation.screen.albums
package
com.biganto.visual.roompark.presentation.screen.albums
import
com.biganto.visual.roompark.conductor.BigantoBaseContract
import
com.biganto.visual.roompark.conductor.BigantoBaseContract
import
com.biganto.visual.roompark.domain.model.AlbumPreviewModel
import
io.reactivex.Observable
/**
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
*/
interface
AlbumsScreen
:
BigantoBaseContract
<
AlbumsScreenViewState
>
{
interface
AlbumsScreen
:
BigantoBaseContract
<
AlbumsScreenViewState
>
{
fun
onAlbumSelected
():
Observable
<
AlbumPreviewModel
>
}
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/ScreenController.kt
View file @
2e3f93e6
...
@@ -15,15 +15,19 @@ import com.biganto.visual.roompark.base.IBottomNavigation
...
@@ -15,15 +15,19 @@ import com.biganto.visual.roompark.base.IBottomNavigation
import
com.biganto.visual.roompark.base.RoomParkApplication
import
com.biganto.visual.roompark.base.RoomParkApplication
import
com.biganto.visual.roompark.base.RoomParkMainActivity
import
com.biganto.visual.roompark.base.RoomParkMainActivity
import
com.biganto.visual.roompark.conductor.BigantoBaseController
import
com.biganto.visual.roompark.conductor.BigantoBaseController
import
com.biganto.visual.roompark.domain.model.AlbumPreviewModel
import
com.biganto.visual.roompark.presentation.screen.albums.util.AlbumsHeaderAdapter
import
com.biganto.visual.roompark.presentation.screen.albums.util.AlbumsHeaderAdapter
import
com.biganto.visual.roompark.presentation.screen.favorites.util.AlbumListAdapter
import
com.biganto.visual.roompark.presentation.screen.favorites.util.AlbumListAdapter
import
com.biganto.visual.roompark.util.extensions.scaleCenterCrop
import
com.biganto.visual.roompark.util.extensions.scaleCenterCrop
import
com.biganto.visual.roompark.util.view_utils.grid.CeilsDecoration
import
com.biganto.visual.roompark.util.view_utils.grid.CeilsDecoration
import
com.google.android.material.textview.MaterialTextView
import
com.google.android.material.textview.MaterialTextView
import
com.squareup.picasso.Picasso
import
com.squareup.picasso.Picasso
import
io.reactivex.Observable
import
io.reactivex.android.schedulers.AndroidSchedulers
import
jp.wasabeef.picasso.transformations.BlurTransformation
import
jp.wasabeef.picasso.transformations.BlurTransformation
import
jp.wasabeef.picasso.transformations.ColorFilterTransformation
import
jp.wasabeef.picasso.transformations.ColorFilterTransformation
import
timber.log.Timber
import
timber.log.Timber
import
java.util.concurrent.TimeUnit
import
javax.inject.Inject
import
javax.inject.Inject
...
@@ -62,7 +66,7 @@ class AlbumsScreenController :
...
@@ -62,7 +66,7 @@ class AlbumsScreenController :
private
val
photosBackgroundTarget
=
object
:
com
.
squareup
.
picasso
.
Target
{
private
val
photosBackgroundTarget
=
object
:
com
.
squareup
.
picasso
.
Target
{
override
fun
onPrepareLoad
(
placeHolderDrawable
:
Drawable
?)
{
override
fun
onPrepareLoad
(
placeHolderDrawable
:
Drawable
?)
{
nestedScrollView
.
background
=
placeHolderDrawable
//
nestedScrollView.background = placeHolderDrawable
}
}
override
fun
onBitmapFailed
(
e
:
Exception
?,
errorDrawable
:
Drawable
?)
{
override
fun
onBitmapFailed
(
e
:
Exception
?,
errorDrawable
:
Drawable
?)
{
...
@@ -134,6 +138,7 @@ class AlbumsScreenController :
...
@@ -134,6 +138,7 @@ class AlbumsScreenController :
is
AlbumsScreenViewState
.
Idle
->
render
(
viewState
)
is
AlbumsScreenViewState
.
Idle
->
render
(
viewState
)
is
AlbumsScreenViewState
.
AlbumsSelected
->
render
(
viewState
)
is
AlbumsScreenViewState
.
AlbumsSelected
->
render
(
viewState
)
is
AlbumsScreenViewState
.
AlbumsListLoaded
->
render
(
viewState
)
is
AlbumsScreenViewState
.
AlbumsListLoaded
->
render
(
viewState
)
is
AlbumsScreenViewState
.
HeaderAlbumChoosed
->
render
(
viewState
)
is
AlbumsScreenViewState
.
SomeError
->
render
(
viewState
)
is
AlbumsScreenViewState
.
SomeError
->
render
(
viewState
)
}
}
}
}
...
@@ -170,12 +175,34 @@ class AlbumsScreenController :
...
@@ -170,12 +175,34 @@ class AlbumsScreenController :
}
}
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
HeaderAlbumChoosed
)
{
(
headersRecyclerView
.
adapter
as
AlbumsHeaderAdapter
)
.
getItemPosition
(
viewState
.
item
.
albumId
).
let
{
headersRecyclerView
.
scrollToPosition
(
it
)
}
currentAlbomTitle
.
text
=
viewState
.
item
.
title
picassoAsync
.
load
(
viewState
.
item
.
previewUrl
)
.
transform
(
BlurTransformation
(
activity
,
13
,
2
))
.
transform
(
ColorFilterTransformation
(
0
xCC000000
.
toInt
()))
.
into
(
photosBackgroundTarget
)
}
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
AlbumsSelected
){
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
AlbumsSelected
){
(
albumsRecyclerView
.
adapter
as
AlbumListAdapter
).
setItems
(
(
albumsRecyclerView
.
adapter
as
AlbumListAdapter
).
setItems
(
viewState
.
list
.
asSequence
().
sortedByDescending
{
it
.
published
}.
toList
()
viewState
.
list
.
asSequence
().
sortedByDescending
{
it
.
published
}.
toList
()
)
)
}
}
override
fun
onAlbumSelected
():
Observable
<
AlbumPreviewModel
>
=
(
headersRecyclerView
.
adapter
as
AlbumsHeaderAdapter
)
.
onItemClicked
.
debounce
(
300L
,
TimeUnit
.
MILLISECONDS
)
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
doOnNext
{
(
albumsRecyclerView
.
adapter
as
AlbumListAdapter
).
setItems
(
arrayListOf
())}
override
fun
getLayoutId
():
Int
=
R
.
layout
.
albums_screen
override
fun
getLayoutId
():
Int
=
R
.
layout
.
albums_screen
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/ScreenPresenter.kt
View file @
2e3f93e6
...
@@ -3,6 +3,7 @@ package com.biganto.visual.roompark.presentation.screen.albums
...
@@ -3,6 +3,7 @@ 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.AlbumsInteractor
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.Observable
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.schedulers.Schedulers
import
io.reactivex.schedulers.Schedulers
import
javax.inject.Inject
import
javax.inject.Inject
...
@@ -22,20 +23,41 @@ class AlbumsScreenPresenter @Inject constructor(
...
@@ -22,20 +23,41 @@ class AlbumsScreenPresenter @Inject constructor(
override
fun
defaultErrorViewStateHandler
()
=
override
fun
defaultErrorViewStateHandler
()
=
{
e
:
ExceptionString
->
AlbumsScreenViewState
.
SomeError
(
e
)
}
{
e
:
ExceptionString
->
AlbumsScreenViewState
.
SomeError
(
e
)
}
private
fun
requestAlbum
(
id
:
Int
):
Observable
<
AlbumsScreenViewState
>
=
interactor
.
fetchAlbumPhotos
(
id
)
.
filter
{
!
it
.
isNullOrEmpty
()
}
.
map
{
AlbumsScreenViewState
.
AlbumsSelected
(
it
)}
override
fun
bindIntents
()
{
override
fun
bindIntents
()
{
val
fetchParents
=
interactor
.
fetchHeaderAlbums
()
val
fetchParents
=
interactor
.
fetchHeaderAlbums
()
.
filter
{
!
it
.
isNullOrEmpty
()
}
.
filter
{
!
it
.
isNullOrEmpty
()
}
.
map
{
AlbumsScreenViewState
.
AlbumsListLoaded
(
it
,
selectedIndex
)
}
.
map
{
AlbumsScreenViewState
.
AlbumsListLoaded
(
it
,
selectedIndex
)
}
// .concatMap<AlbumsScreenViewState> {
// Observable.just(
// AlbumsScreenViewState.HeaderAlbumChoosed(
// it.list.first { alb -> alb.albumId == selectedIndex })
// )
// }
val
fetchSelected
=
requestAlbum
(
selectedIndex
)
val
headerItemSelected
=
intent
(
AlbumsScreen
::
onAlbumSelected
)
.
doOnNext
{
selectedIndex
=
it
.
albumId
}
.
flatMap
<
AlbumsScreenViewState
>
{
model
->
requestAlbum
(
model
.
albumId
)
.
startWith
(
Observable
.
just
(
AlbumsScreenViewState
.
HeaderAlbumChoosed
(
item
=
model
)))
}
val
fetchSelected
=
interactor
.
fetchAlbumPhotos
(
selectedIndex
)
.
filter
{
!
it
.
isNullOrEmpty
()
}
.
map
{
AlbumsScreenViewState
.
AlbumsSelected
(
it
)}
val
state
=
restoreStateObservable
val
state
=
restoreStateObservable
.
mergeWith
(
fetchParents
)
.
mergeWith
(
fetchParents
)
.
mergeWith
(
fetchSelected
)
.
mergeWith
(
fetchSelected
)
.
mergeWith
(
headerItemSelected
)
.
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
)
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/ScreenViewState.kt
View file @
2e3f93e6
...
@@ -14,6 +14,7 @@ sealed class AlbumsScreenViewState : BigantoBaseViewState() {
...
@@ -14,6 +14,7 @@ sealed class AlbumsScreenViewState : BigantoBaseViewState() {
class
Idle
:
AlbumsScreenViewState
()
class
Idle
:
AlbumsScreenViewState
()
class
AlbumsListLoaded
(
val
list
:
List
<
AlbumPreviewModel
>,
val
selectedAlbumId
:
Int
)
:
AlbumsScreenViewState
()
class
AlbumsListLoaded
(
val
list
:
List
<
AlbumPreviewModel
>,
val
selectedAlbumId
:
Int
)
:
AlbumsScreenViewState
()
class
AlbumsSelected
(
val
list
:
List
<
AlbumSortedModel
>)
:
AlbumsScreenViewState
()
class
AlbumsSelected
(
val
list
:
List
<
AlbumSortedModel
>)
:
AlbumsScreenViewState
()
class
HeaderAlbumChoosed
(
val
item
:
AlbumPreviewModel
)
:
AlbumsScreenViewState
()
class
PhotoSelected
(
val
photoId
:
Int
)
:
AlbumsScreenViewState
()
class
PhotoSelected
(
val
photoId
:
Int
)
:
AlbumsScreenViewState
()
class
SomeError
(
val
exception
:
ExceptionString
)
:
AlbumsScreenViewState
()
class
SomeError
(
val
exception
:
ExceptionString
)
:
AlbumsScreenViewState
()
}
}
\ No newline at end of file
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