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
99b3335f
Commit
99b3335f
authored
Mar 31, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
deal subscription
parent
20e57d95
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
110 additions
and
21 deletions
+110
-21
ScreenController.kt
...l/roompark/presentation/screen/albums/ScreenController.kt
+7
-0
ScreenPresenter.kt
...al/roompark/presentation/screen/albums/ScreenPresenter.kt
+4
-4
ScreenContract.kt
...isual/roompark/presentation/screen/deal/ScreenContract.kt
+2
-0
ScreenController.kt
...ual/roompark/presentation/screen/deal/ScreenController.kt
+58
-0
ScreenPresenter.kt
...sual/roompark/presentation/screen/deal/ScreenPresenter.kt
+36
-17
ScreenViewState.kt
...sual/roompark/presentation/screen/deal/ScreenViewState.kt
+3
-0
No files found.
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/ScreenController.kt
View file @
99b3335f
...
@@ -265,6 +265,13 @@ class AlbumsScreenController :
...
@@ -265,6 +265,13 @@ class AlbumsScreenController :
loadGlideBlurred
(
it
.
previewUrl
,
ctx
,
nestedBgTarget
)
loadGlideBlurred
(
it
.
previewUrl
,
ctx
,
nestedBgTarget
)
}
}
}
}
val
sw
=
toolBar
.
headerToolbar
.
findViewById
<
SwitchMaterial
>(
R
.
id
.
switch1
)
if
(
sw
.
isChecked
!=
viewState
.
restore
.
sub
?.
state
)
{
silentCheck
=
true
sw
.
isChecked
!=
sw
.
isChecked
}
}
}
private
val
nestedBgTarget
=
object
:
SimpleTarget
<
Drawable
>(){
private
val
nestedBgTarget
=
object
:
SimpleTarget
<
Drawable
>(){
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/ScreenPresenter.kt
View file @
99b3335f
...
@@ -51,6 +51,10 @@ class AlbumsScreenPresenter @Inject constructor(
...
@@ -51,6 +51,10 @@ class AlbumsScreenPresenter @Inject constructor(
.
onErrorReturn
{
AlbumsScreenViewState
.
SubscriptionError
(!
newState
)
}
.
onErrorReturn
{
AlbumsScreenViewState
.
SubscriptionError
(!
newState
)
}
}
}
val
fetchSubscription
=
interactor
.
getSubscriptions
(
currentAlbumTopic
)
.
doAfterNext
{
restoreModel
.
sub
=
it
}
.
map
<
AlbumsScreenViewState
>
{
AlbumsScreenViewState
.
SubscriptionStatus
(
it
.
state
)
}
.
startWith
(
Observable
.
just
<
AlbumsScreenViewState
>(
AlbumsScreenViewState
.
Idle
()))
val
fetchParents
=
interactor
.
fetchHeaderAlbums
()
val
fetchParents
=
interactor
.
fetchHeaderAlbums
()
.
filter
{
!
it
.
isNullOrEmpty
()
}
.
filter
{
!
it
.
isNullOrEmpty
()
}
...
@@ -68,10 +72,6 @@ class AlbumsScreenPresenter @Inject constructor(
...
@@ -68,10 +72,6 @@ class AlbumsScreenPresenter @Inject constructor(
}
}
val
fetchSubscription
=
interactor
.
getSubscriptions
(
currentAlbumTopic
)
.
doAfterNext
{
restoreModel
.
sub
=
it
}
.
map
<
AlbumsScreenViewState
>
{
AlbumsScreenViewState
.
SubscriptionStatus
(
it
.
state
)
}
.
startWith
(
Observable
.
just
<
AlbumsScreenViewState
>(
AlbumsScreenViewState
.
Idle
()))
val
photoSelected
=
intent
(
AlbumsScreen
::
onPhotoSelected
)
val
photoSelected
=
intent
(
AlbumsScreen
::
onPhotoSelected
)
.
map
{
AlbumsScreenViewState
.
PhotoSelected
(
it
.
photoId
)
}
.
map
{
AlbumsScreenViewState
.
PhotoSelected
(
it
.
photoId
)
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/deal/ScreenContract.kt
View file @
99b3335f
package
com.biganto.visual.roompark.presentation.screen.deal
package
com.biganto.visual.roompark.presentation.screen.deal
import
com.biganto.visual.roompark.conductor.BigantoBaseContract
import
com.biganto.visual.roompark.conductor.BigantoBaseContract
import
io.reactivex.Observable
/**
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
*/
interface
DealScreen
:
BigantoBaseContract
<
DealScreenViewState
>
{
interface
DealScreen
:
BigantoBaseContract
<
DealScreenViewState
>
{
fun
onSubscription
():
Observable
<
Boolean
>
}
}
app/src/main/java/com/biganto/visual/roompark/presentation/screen/deal/ScreenController.kt
View file @
99b3335f
...
@@ -17,6 +17,7 @@ import com.biganto.visual.roompark.domain.model.typeDoubleString
...
@@ -17,6 +17,7 @@ import com.biganto.visual.roompark.domain.model.typeDoubleString
import
com.biganto.visual.roompark.domain.model.typeShortString
import
com.biganto.visual.roompark.domain.model.typeShortString
import
com.biganto.visual.roompark.presentation.screen.estate.EstateScreenController
import
com.biganto.visual.roompark.presentation.screen.estate.EstateScreenController
import
com.biganto.visual.roompark.util.extensions.toRubly
import
com.biganto.visual.roompark.util.extensions.toRubly
import
com.biganto.visual.roompark.util.monades.ExceptionString
import
com.biganto.visual.roompark.util.view_utils.image_view.RoundedImageView
import
com.biganto.visual.roompark.util.view_utils.image_view.RoundedImageView
import
com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusProgressAnimationState
import
com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusProgressAnimationState
import
com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusProgressCeil
import
com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusProgressCeil
...
@@ -24,11 +25,15 @@ import com.bluelinelabs.conductor.RouterTransaction
...
@@ -24,11 +25,15 @@ import com.bluelinelabs.conductor.RouterTransaction
import
com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import
com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import
com.bumptech.glide.Glide
import
com.bumptech.glide.Glide
import
com.bumptech.glide.load.engine.DiskCacheStrategy
import
com.bumptech.glide.load.engine.DiskCacheStrategy
import
com.google.android.material.switchmaterial.SwitchMaterial
import
com.google.android.material.textview.MaterialTextView
import
com.google.android.material.textview.MaterialTextView
import
com.jakewharton.rxbinding3.view.clicks
import
com.jakewharton.rxbinding3.view.clicks
import
com.jakewharton.rxbinding3.view.scrollChangeEvents
import
com.jakewharton.rxbinding3.view.scrollChangeEvents
import
com.jakewharton.rxbinding3.widget.checkedChanges
import
io.reactivex.Observable
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.android.schedulers.AndroidSchedulers
import
timber.log.Timber
import
timber.log.Timber
import
java.util.concurrent.TimeUnit
import
javax.inject.Inject
import
javax.inject.Inject
...
@@ -140,6 +145,20 @@ class DealScreenController :
...
@@ -140,6 +145,20 @@ class DealScreenController :
)
)
}
}
override
fun
onSubscription
():
Observable
<
Boolean
>
=
toolBar
.
headerToolbar
.
findViewById
<
SwitchMaterial
>(
R
.
id
.
switch1
)
.
checkedChanges
()
.
skip
(
1
)
//skip init switcher check state
.
filter
{
if
(!
silentCheck
)
return
@filter
!
silentCheck
else
silentCheck
=
false
silentCheck
}
.
doOnNext
{
}
.
debounce
(
600L
,
TimeUnit
.
MILLISECONDS
)
.
observeOn
(
AndroidSchedulers
.
mainThread
())
private
fun
setToolbar
(){
private
fun
setToolbar
(){
toolBar
.
setToolbar
(
HeaderToolbarModel
(
toolBar
.
setToolbar
(
HeaderToolbarModel
(
true
true
...
@@ -167,6 +186,9 @@ class DealScreenController :
...
@@ -167,6 +186,9 @@ class DealScreenController :
is
DealScreenViewState
.
Idle
->
render
(
viewState
)
is
DealScreenViewState
.
Idle
->
render
(
viewState
)
is
DealScreenViewState
.
LoadDeal
->
render
(
viewState
)
is
DealScreenViewState
.
LoadDeal
->
render
(
viewState
)
is
DealScreenViewState
.
SomeError
->
render
(
viewState
)
is
DealScreenViewState
.
SomeError
->
render
(
viewState
)
is
DealScreenViewState
.
RestoreView
->
render
(
viewState
)
is
DealScreenViewState
.
SubscriptionStatus
->
render
(
viewState
)
is
DealScreenViewState
.
SubscriptionError
->
render
(
viewState
)
}
}
}
}
...
@@ -174,6 +196,42 @@ class DealScreenController :
...
@@ -174,6 +196,42 @@ class DealScreenController :
}
}
private
var
silentCheck
=
false
private
fun
render
(
viewState
:
DealScreenViewState
.
SubscriptionStatus
)
{
val
sw
=
toolBar
.
headerToolbar
.
findViewById
<
SwitchMaterial
>(
R
.
id
.
switch1
)
if
(
sw
.
isChecked
!=
viewState
.
subState
)
{
silentCheck
=
true
sw
.
isChecked
!=
sw
.
isChecked
}
}
private
fun
render
(
viewState
:
DealScreenViewState
.
SubscriptionError
)
{
val
sw
=
toolBar
.
headerToolbar
.
findViewById
<
SwitchMaterial
>(
R
.
id
.
switch1
)
if
(
sw
.
isChecked
!=
viewState
.
subState
)
{
silentCheck
=
true
sw
.
isChecked
=
viewState
.
subState
}
if
(
viewState
.
subState
)
showError
(
ExceptionString
(
R
.
string
.
unsubscribe_error_message
,
null
))
else
showError
(
ExceptionString
(
R
.
string
.
subscribe_error_message
,
null
))
}
private
fun
render
(
viewState
:
DealScreenViewState
.
RestoreView
)
{
val
sw
=
toolBar
.
headerToolbar
.
findViewById
<
SwitchMaterial
>(
R
.
id
.
switch1
)
if
(
sw
.
isChecked
!=
viewState
.
restore
.
sub
?.
state
)
{
silentCheck
=
true
sw
.
isChecked
!=
sw
.
isChecked
}
}
private
fun
render
(
viewState
:
DealScreenViewState
.
SomeError
)
=
private
fun
render
(
viewState
:
DealScreenViewState
.
SomeError
)
=
showError
(
viewState
.
exception
)
showError
(
viewState
.
exception
)
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/deal/ScreenPresenter.kt
View file @
99b3335f
package
com.biganto.visual.roompark.presentation.screen.deal
package
com.biganto.visual.roompark.presentation.screen.deal
import
android.content.Context
import
android.content.Context
import
androidx.annotation.StringRes
import
com.biganto.visual.roompark.conductor.BigantoBasePresenter
import
com.biganto.visual.roompark.conductor.BigantoBasePresenter
import
com.biganto.visual.roompark.domain.interactor.DealInteractor
import
com.biganto.visual.roompark.domain.interactor.DealInteractor
import
com.biganto.visual.roompark.domain.model.DealModel
import
com.biganto.visual.roompark.domain.model.SubscriptionModel
import
com.biganto.visual.roompark.domain.model.PlanPresetModel
import
com.biganto.visual.roompark.presentation.screen.estate.InfoShowType
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
...
@@ -27,15 +24,16 @@ class DealScreenPresenter @Inject constructor(
...
@@ -27,15 +24,16 @@ class DealScreenPresenter @Inject constructor(
)
)
:
BigantoBasePresenter
<
DealScreen
,
DealScreenViewState
>()
{
:
BigantoBasePresenter
<
DealScreen
,
DealScreenViewState
>()
{
private
var
planList
:
List
<
PlanPresetModel
>?
=
null
private
var
estate
:
DealModel
?
=
null
private
var
showType
:
InfoShowType
=
InfoShowType
.
COMMON_INFO
override
fun
defaultErrorViewStateHandler
()
=
override
fun
defaultErrorViewStateHandler
()
=
{
e
:
ExceptionString
->
DealScreenViewState
.
SomeError
(
e
)
}
{
e
:
ExceptionString
->
DealScreenViewState
.
SomeError
(
e
)
}
private
var
restoreModel
=
RestoreModel
(
null
)
override
fun
detachView
()
{
super
.
detachView
()
restoreStateObservable
.
accept
(
DealScreenViewState
.
RestoreView
(
restoreModel
))
}
override
fun
bindIntents
()
{
override
fun
bindIntents
()
{
...
@@ -48,20 +46,41 @@ class DealScreenPresenter @Inject constructor(
...
@@ -48,20 +46,41 @@ class DealScreenPresenter @Inject constructor(
val
setRead
=
interactor
.
setDealRead
(
dealId
)
val
setRead
=
interactor
.
setDealRead
(
dealId
)
.
andThen
(
Observable
.
just
(
DealScreenViewState
.
Idle
()))
.
andThen
(
Observable
.
just
(
DealScreenViewState
.
Idle
()))
val
state
=
restoreStateObservable
.
mergeWith
(
fetchDeal
)
val
onSubChecked
=
intent
(
DealScreen
::
onSubscription
)
.
mergeWith
(
setRead
)
.
filter
{
restoreModel
.
sub
!=
null
}
.
flatMap
{
newState
->
interactor
.
switchSubscription
(
restoreModel
.
sub
!!
,
newState
)
.
andThen
(
Observable
.
just
<
DealScreenViewState
>(
DealScreenViewState
.
SubscriptionStatus
(
newState
)
)
)
.
onErrorReturn
{
DealScreenViewState
.
SubscriptionError
(!
newState
)
}
}
val
fetchSubscription
=
interactor
.
getSubscriptions
(
dealId
)
.
doAfterNext
{
restoreModel
.
sub
=
it
}
.
map
<
DealScreenViewState
>
{
DealScreenViewState
.
SubscriptionStatus
(
it
.
state
)
}
.
startWith
(
Observable
.
just
<
DealScreenViewState
>(
DealScreenViewState
.
Idle
()))
val
state
=
Observable
.
mergeDelayError
(
arrayListOf
(
restoreStateObservable
,
fetchDeal
,
setRead
,
onSubChecked
,
fetchSubscription
))
.
doOnError
{
Timber
.
e
(
it
)
}
.
doOnError
{
Timber
.
e
(
it
)
}
.
onErrorReturn
(
::
parseError
)
.
subscribeOn
(
Schedulers
.
io
())
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
subscribeViewState
(
state
.
cast
(
DealScreenViewState
::
class
.
java
),
DealScreen
::
render
)
subscribeViewState
(
state
.
cast
(
DealScreenViewState
::
class
.
java
),
DealScreen
::
render
)
}
}
}
private
fun
langString
(
@StringRes
id
:
Int
)
=
context
.
resources
.
getString
(
id
)
private
fun
langString
(
@StringRes
id
:
Int
,
vararg
args
:
Any
)
=
context
.
resources
.
getString
(
id
,*
args
)
}
data class
RestoreModel
(
var
sub
:
SubscriptionModel
?)
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/presentation/screen/deal/ScreenViewState.kt
View file @
99b3335f
...
@@ -14,4 +14,7 @@ sealed class DealScreenViewState : BigantoBaseViewState() {
...
@@ -14,4 +14,7 @@ sealed class DealScreenViewState : BigantoBaseViewState() {
class
Idle
:
DealScreenViewState
()
class
Idle
:
DealScreenViewState
()
class
LoadDeal
(
val
estate
:
DealModel
,
val
statusList
:
List
<
StatusModel
>)
:
DealScreenViewState
()
class
LoadDeal
(
val
estate
:
DealModel
,
val
statusList
:
List
<
StatusModel
>)
:
DealScreenViewState
()
class
SomeError
(
val
exception
:
ExceptionString
)
:
DealScreenViewState
()
class
SomeError
(
val
exception
:
ExceptionString
)
:
DealScreenViewState
()
class
RestoreView
(
val
restore
:
RestoreModel
)
:
DealScreenViewState
()
class
SubscriptionStatus
(
val
subState
:
Boolean
)
:
DealScreenViewState
()
class
SubscriptionError
(
val
subState
:
Boolean
)
:
DealScreenViewState
()
}
}
\ 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