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
6478b8b0
Commit
6478b8b0
authored
Mar 10, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added restore model to albums screeen
parent
a9d211a1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
9 deletions
+59
-9
ScreenController.kt
...l/roompark/presentation/screen/albums/ScreenController.kt
+34
-1
ScreenPresenter.kt
...al/roompark/presentation/screen/albums/ScreenPresenter.kt
+17
-7
ScreenViewState.kt
...al/roompark/presentation/screen/albums/ScreenViewState.kt
+1
-0
ScreenPresenter.kt
...ual/roompark/presentation/screen/photo/ScreenPresenter.kt
+7
-0
Renderer.kt
...isual/roompark/presentation/screen/photo/util/Renderer.kt
+0
-1
No files found.
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/ScreenController.kt
View file @
6478b8b0
...
@@ -22,6 +22,8 @@ import com.biganto.visual.roompark.presentation.screen.photo.PhotoScreenControll
...
@@ -22,6 +22,8 @@ import com.biganto.visual.roompark.presentation.screen.photo.PhotoScreenControll
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.bluelinelabs.conductor.RouterTransaction
import
com.bluelinelabs.conductor.RouterTransaction
import
com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import
com.bluelinelabs.conductor.changehandler.VerticalChangeHandler
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.Observable
...
@@ -140,6 +142,7 @@ class AlbumsScreenController :
...
@@ -140,6 +142,7 @@ class AlbumsScreenController :
is
AlbumsScreenViewState
.
HeaderAlbumChoosed
->
render
(
viewState
)
is
AlbumsScreenViewState
.
HeaderAlbumChoosed
->
render
(
viewState
)
is
AlbumsScreenViewState
.
PhotoSelected
->
render
(
viewState
)
is
AlbumsScreenViewState
.
PhotoSelected
->
render
(
viewState
)
is
AlbumsScreenViewState
.
SomeError
->
render
(
viewState
)
is
AlbumsScreenViewState
.
SomeError
->
render
(
viewState
)
is
AlbumsScreenViewState
.
RestoreView
->
render
(
viewState
)
}
}
}
}
...
@@ -148,7 +151,11 @@ class AlbumsScreenController :
...
@@ -148,7 +151,11 @@ class AlbumsScreenController :
}
}
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
PhotoSelected
){
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
PhotoSelected
){
router
.
pushController
(
RouterTransaction
.
with
(
PhotoScreenController
(
viewState
.
photoId
)))
router
.
pushController
(
RouterTransaction
.
with
(
PhotoScreenController
(
viewState
.
photoId
))
.
pushChangeHandler
(
VerticalChangeHandler
())
.
popChangeHandler
(
FadeChangeHandler
(
false
))
)
}
}
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
SomeError
)
=
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
SomeError
)
=
...
@@ -199,6 +206,32 @@ class AlbumsScreenController :
...
@@ -199,6 +206,32 @@ class AlbumsScreenController :
)
)
}
}
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
RestoreView
){
(
albumsRecyclerView
.
adapter
as
AlbumListAdapter
).
setItems
(
viewState
.
restore
.
albumList
.
asSequence
().
sortedByDescending
{
it
.
published
}.
toList
()
)
(
headersRecyclerView
.
adapter
as
AlbumsHeaderAdapter
).
setItems
(
viewState
.
restore
.
albumsPreview
.
asSequence
().
sortedByDescending
{
it
.
published
}.
toList
()
)
headersRecyclerView
.
let
{
it
.
scrollToPosition
(
(
it
.
adapter
as
AlbumsHeaderAdapter
).
getItemPosition
(
viewState
.
restore
.
currentIndex
)
)
}
viewState
.
restore
.
albumsPreview
.
first
{
it
.
albumId
==
viewState
.
restore
.
currentIndex
}
.
let
{
currentAlbomTitle
.
text
=
it
.
title
picassoAsync
.
load
(
it
.
previewUrl
)
.
transform
(
BlurTransformation
(
activity
,
13
,
2
))
.
transform
(
ColorFilterTransformation
(
0
xCC000000
.
toInt
()))
.
into
(
photosBackgroundTarget
)
}
}
override
fun
onAlbumSelected
():
Observable
<
AlbumPreviewModel
>
override
fun
onAlbumSelected
():
Observable
<
AlbumPreviewModel
>
=
(
headersRecyclerView
.
adapter
as
AlbumsHeaderAdapter
)
=
(
headersRecyclerView
.
adapter
as
AlbumsHeaderAdapter
)
.
onItemClicked
.
onItemClicked
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/ScreenPresenter.kt
View file @
6478b8b0
...
@@ -2,6 +2,8 @@ package com.biganto.visual.roompark.presentation.screen.albums
...
@@ -2,6 +2,8 @@ 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.domain.model.AlbumPreviewModel
import
com.biganto.visual.roompark.domain.model.AlbumSortedModel
import
com.biganto.visual.roompark.util.monades.ExceptionString
import
com.biganto.visual.roompark.util.monades.ExceptionString
import
io.reactivex.Observable
import
io.reactivex.Observable
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.android.schedulers.AndroidSchedulers
...
@@ -13,32 +15,35 @@ import javax.inject.Named
...
@@ -13,32 +15,35 @@ import javax.inject.Named
* Created by Vladislav Bogdashkin on 30.09.2019.
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
*/
class
AlbumsScreenPresenter
@Inject
constructor
(
class
AlbumsScreenPresenter
@Inject
constructor
(
private
val
interactor
:
AlbumsInteractor
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
>()
{
private
var
restoreModel
=
RestoreModel
(
listOf
(),
listOf
(),
selectedIndex
)
override
fun
defaultErrorViewStateHandler
()
=
override
fun
defaultErrorViewStateHandler
()
=
{
e
:
ExceptionString
->
AlbumsScreenViewState
.
SomeError
(
e
)
}
{
e
:
ExceptionString
->
AlbumsScreenViewState
.
SomeError
(
e
)
}
private
fun
requestAlbum
(
id
:
Int
):
Observable
<
AlbumsScreenViewState
>
=
private
fun
requestAlbum
(
id
:
Int
):
Observable
<
AlbumsScreenViewState
>
=
interactor
.
fetchAlbumPhotos
(
id
)
interactor
.
fetchAlbumPhotos
(
id
)
.
filter
{
!
it
.
isNullOrEmpty
()
}
.
filter
{
!
it
.
isNullOrEmpty
()
}
.
map
{
AlbumsScreenViewState
.
AlbumsSelected
(
it
)}
.
doOnNext
{
restoreModel
.
albumList
=
it
}
.
map
{
AlbumsScreenViewState
.
AlbumsSelected
(
it
)}
override
fun
bindIntents
()
{
override
fun
bindIntents
()
{
val
fetchParents
=
interactor
.
fetchHeaderAlbums
()
val
fetchParents
=
interactor
.
fetchHeaderAlbums
()
.
filter
{
!
it
.
isNullOrEmpty
()
}
.
filter
{
!
it
.
isNullOrEmpty
()
}
.
doOnNext
{
restoreModel
.
albumsPreview
=
it
}
.
map
{
AlbumsScreenViewState
.
AlbumsListLoaded
(
it
,
selectedIndex
)
}
.
map
{
AlbumsScreenViewState
.
AlbumsListLoaded
(
it
,
selectedIndex
)
}
val
fetchSelected
=
requestAlbum
(
selectedIndex
)
val
fetchSelected
=
requestAlbum
(
selectedIndex
)
val
headerItemSelected
=
intent
(
AlbumsScreen
::
onAlbumSelected
)
val
headerItemSelected
=
intent
(
AlbumsScreen
::
onAlbumSelected
)
.
doOnNext
{
selectedIndex
=
it
.
albumId
}
.
doOnNext
{
selectedIndex
=
it
.
albumId
}
.
doOnNext
{
restoreModel
.
currentIndex
=
it
.
albumId
}
.
flatMap
<
AlbumsScreenViewState
>
{
model
->
.
flatMap
<
AlbumsScreenViewState
>
{
model
->
requestAlbum
(
model
.
albumId
)
requestAlbum
(
model
.
albumId
)
.
startWith
(
Observable
.
just
(
AlbumsScreenViewState
.
HeaderAlbumChoosed
(
item
=
model
)))
.
startWith
(
Observable
.
just
(
AlbumsScreenViewState
.
HeaderAlbumChoosed
(
item
=
model
)))
...
@@ -47,9 +52,6 @@ class AlbumsScreenPresenter @Inject constructor(
...
@@ -47,9 +52,6 @@ class AlbumsScreenPresenter @Inject constructor(
val
photoSelected
=
intent
(
AlbumsScreen
::
onPhotoSelected
)
val
photoSelected
=
intent
(
AlbumsScreen
::
onPhotoSelected
)
.
map
{
AlbumsScreenViewState
.
PhotoSelected
(
it
.
photoId
)
}
.
map
{
AlbumsScreenViewState
.
PhotoSelected
(
it
.
photoId
)
}
val
state
=
restoreStateObservable
val
state
=
restoreStateObservable
.
mergeWith
(
fetchParents
)
.
mergeWith
(
fetchParents
)
.
mergeWith
(
fetchSelected
)
.
mergeWith
(
fetchSelected
)
...
@@ -60,4 +62,12 @@ class AlbumsScreenPresenter @Inject constructor(
...
@@ -60,4 +62,12 @@ class AlbumsScreenPresenter @Inject constructor(
subscribeViewState
(
state
.
cast
(
AlbumsScreenViewState
::
class
.
java
),
AlbumsScreen
::
render
)
subscribeViewState
(
state
.
cast
(
AlbumsScreenViewState
::
class
.
java
),
AlbumsScreen
::
render
)
}
}
}
override
fun
detachView
()
{
\ No newline at end of file
super
.
detachView
()
restoreStateObservable
.
accept
(
AlbumsScreenViewState
.
RestoreView
(
restoreModel
))
}
}
data class
RestoreModel
(
var
albumList
:
List
<
AlbumSortedModel
>
,
var
albumsPreview
:
List
<
AlbumPreviewModel
>
,
var
currentIndex
:
Int
)
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/ScreenViewState.kt
View file @
6478b8b0
...
@@ -17,4 +17,5 @@ sealed class AlbumsScreenViewState : BigantoBaseViewState() {
...
@@ -17,4 +17,5 @@ sealed class AlbumsScreenViewState : BigantoBaseViewState() {
class
HeaderAlbumChoosed
(
val
item
:
AlbumPreviewModel
)
:
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
()
class
RestoreView
(
val
restore
:
RestoreModel
)
:
AlbumsScreenViewState
()
}
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/presentation/screen/photo/ScreenPresenter.kt
View file @
6478b8b0
...
@@ -45,4 +45,11 @@ class PhotoScreenPresenter @Inject constructor(
...
@@ -45,4 +45,11 @@ class PhotoScreenPresenter @Inject constructor(
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
subscribeViewState
(
state
.
cast
(
PhotoScreenViewState
::
class
.
java
),
PhotoScreen
::
render
)
subscribeViewState
(
state
.
cast
(
PhotoScreenViewState
::
class
.
java
),
PhotoScreen
::
render
)
}
}
override
fun
detachView
()
{
super
.
detachView
()
restoreStateObservable
.
accept
(
PhotoScreenViewState
.
Idle
())
}
}
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/presentation/screen/photo/util/Renderer.kt
View file @
6478b8b0
...
@@ -321,7 +321,6 @@ class RendererThread(val context: Context, val surface: SurfaceTexture)
...
@@ -321,7 +321,6 @@ class RendererThread(val context: Context, val surface: SurfaceTexture)
timerDecay
(
SLEEP_THRESHOLD
)
timerDecay
(
SLEEP_THRESHOLD
)
if
(
bmpCache
.
size
>
0
)
calcBorders
()
if
(
bmpCache
.
size
>
0
)
calcBorders
()
Timber
.
d
(
"bmpCache ${bmpCache.size}"
)
bmpCache
.
forEachIndexed
{
index
,
bitmap
->
bmpCache
.
forEachIndexed
{
index
,
bitmap
->
// Timber.d("bitmap ${bitmap} / $index")
// Timber.d("bitmap ${bitmap} / $index")
bitmap
?.
let
{
bitmap
?.
let
{
...
...
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