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
936097b5
Commit
936097b5
authored
Apr 28, 2020
by
Vladislav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
subs move to titledsubs models;
fetch api and update states
parent
3d63a790
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
151 additions
and
80 deletions
+151
-80
SubscriptionRepository.kt
...ual/roompark/data/data_provider/SubscriptionRepository.kt
+39
-3
Subscribtions.kt
.../biganto/visual/roompark/domain/contract/Subscribtions.kt
+16
-0
albums.kt
...a/com/biganto/visual/roompark/domain/interactor/albums.kt
+1
-2
articles.kt
...com/biganto/visual/roompark/domain/interactor/articles.kt
+1
-2
deal.kt
...ava/com/biganto/visual/roompark/domain/interactor/deal.kt
+1
-1
settings.kt
...com/biganto/visual/roompark/domain/interactor/settings.kt
+1
-2
subscriptionUseCase.kt
...to/visual/roompark/domain/use_case/subscriptionUseCase.kt
+48
-29
ScreenPresenter.kt
...al/roompark/presentation/screen/albums/ScreenPresenter.kt
+8
-7
ScreenPresenter.kt
...sual/roompark/presentation/screen/deal/ScreenPresenter.kt
+9
-5
ScreenPresenter.kt
...ual/roompark/presentation/screen/deals/ScreenPresenter.kt
+0
-1
ScreenPresenter.kt
...roompark/presentation/screen/feed_list/ScreenPresenter.kt
+8
-7
ScreenPresenter.kt
.../roompark/presentation/screen/settings/ScreenPresenter.kt
+19
-21
No files found.
app/src/main/java/com/biganto/visual/roompark/data/data_provider/SubscriptionRepository.kt
View file @
936097b5
...
@@ -6,6 +6,8 @@ import com.biganto.visual.roompark.data.repository.db.IDb
...
@@ -6,6 +6,8 @@ import com.biganto.visual.roompark.data.repository.db.IDb
import
com.biganto.visual.roompark.data.repository.db.requrey.model.SubscriptionEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.SubscriptionEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.UserEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.UserEntity
import
com.biganto.visual.roompark.domain.contract.SubscriptionContract
import
com.biganto.visual.roompark.domain.contract.SubscriptionContract
import
com.biganto.visual.roompark.domain.model.SubscriptionModel
import
com.biganto.visual.roompark.domain.model.fromEntity
import
io.reactivex.Completable
import
io.reactivex.Completable
import
io.reactivex.Observable
import
io.reactivex.Observable
import
timber.log.Timber
import
timber.log.Timber
...
@@ -43,7 +45,7 @@ class SubscriptionRepository @Inject constructor(
...
@@ -43,7 +45,7 @@ class SubscriptionRepository @Inject constructor(
val
userSubs
=
userEntity
.
subscriptions
val
userSubs
=
userEntity
.
subscriptions
val
sub
=
subInnerId
?.
let
{
id
->
val
sub
=
subInnerId
?.
let
{
id
->
user
Entity
.
subscription
s
?.
firstOrNull
{
sub
->
sub
.
id
==
id
}
as
SubscriptionEntity
?
user
Sub
s
?.
firstOrNull
{
sub
->
sub
.
id
==
id
}
as
SubscriptionEntity
?
}
?:
SubscriptionEntity
()
}
?:
SubscriptionEntity
()
.
apply
{
.
apply
{
setOwner
(
userEntity
)
setOwner
(
userEntity
)
...
@@ -59,7 +61,7 @@ class SubscriptionRepository @Inject constructor(
...
@@ -59,7 +61,7 @@ class SubscriptionRepository @Inject constructor(
fun
saveSubscribtions
(
fun
saveSubscribtions
(
userEntity
:
UserEntity
,
userEntity
:
UserEntity
,
apiSubs
:
List
<
SubscriptionStatusRaw
>
apiSubs
:
List
<
SubscriptionStatusRaw
>
):
Observable
<
SubscriptionEntity
>
{
):
Observable
<
List
<
SubscriptionModel
>>?
{
val
userSubs
=
userEntity
.
subscriptions
val
userSubs
=
userEntity
.
subscriptions
val
newSubList
=
mutableListOf
<
SubscriptionEntity
>()
val
newSubList
=
mutableListOf
<
SubscriptionEntity
>()
...
@@ -77,10 +79,44 @@ class SubscriptionRepository @Inject constructor(
...
@@ -77,10 +79,44 @@ class SubscriptionRepository @Inject constructor(
newSubList
.
add
(
cachedSub
)
newSubList
.
add
(
cachedSub
)
}
}
userSubs
?.
let
{
db
.
deleteSubscriptions
(
it
)
}
userSubs
?.
let
{
db
.
deleteSubscriptions
(
it
)
}
return
db
.
upsert
(
newSubList
).
map
{
it
as
SubscriptionEntity
}.
toObservable
()
return
db
.
upsert
(
newSubList
)
.
map
{
list
->
list
.
map
{
fromEntity
(
it
as
SubscriptionEntity
)
}}
.
toObservable
()
}
}
override
fun
subscribeTopicResult
(
user
:
UserEntity
,
subInnerId
:
Int
,
deviceToken
:
String
,
topic
:
String
,
topic_id
:
String
?
):
Observable
<
List
<
SubscriptionModel
>>
=
api
.
subscribeTopic
(
userToken
=
user
.
authToken
,
deviceToken
=
deviceToken
,
topicName
=
topic
,
topicId
=
topic_id
)
.
flatMap
{
saveSubscribtions
(
user
,
it
.
subscriptions
?:
arrayListOf
())
}
override
fun
unSubscribeTopicResult
(
user
:
UserEntity
,
subInnerId
:
Int
,
deviceToken
:
String
,
topic
:
String
,
topic_id
:
String
?
):
Observable
<
List
<
SubscriptionModel
>>
=
api
.
unSuubscribeTopic
(
userToken
=
user
.
authToken
,
deviceToken
=
deviceToken
,
topicName
=
topic
,
topicId
=
topic_id
)
.
flatMap
{
saveSubscribtions
(
user
,
it
.
subscriptions
?:
arrayListOf
())
}
override
fun
subscribeTopic
(
override
fun
subscribeTopic
(
user
:
UserEntity
,
user
:
UserEntity
,
subInnerId
:
Int
,
subInnerId
:
Int
,
...
...
app/src/main/java/com/biganto/visual/roompark/domain/contract/Subscribtions.kt
View file @
936097b5
...
@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.domain.contract
...
@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.domain.contract
import
com.biganto.visual.roompark.data.repository.db.requrey.model.SubscriptionEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.SubscriptionEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.UserEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.UserEntity
import
com.biganto.visual.roompark.domain.model.SubscriptionModel
import
io.reactivex.Completable
import
io.reactivex.Completable
import
io.reactivex.Observable
import
io.reactivex.Observable
...
@@ -36,4 +37,19 @@ interface SubscriptionContract{
...
@@ -36,4 +37,19 @@ interface SubscriptionContract{
):
Observable
<
SubscriptionEntity
>
):
Observable
<
SubscriptionEntity
>
fun
saveSubscribeState
(
sub
:
SubscriptionEntity
):
Observable
<
SubscriptionEntity
>
fun
saveSubscribeState
(
sub
:
SubscriptionEntity
):
Observable
<
SubscriptionEntity
>
fun
subscribeTopicResult
(
user
:
UserEntity
,
subInnerId
:
Int
,
deviceToken
:
String
,
topic
:
String
,
topic_id
:
String
?
):
Observable
<
List
<
SubscriptionModel
>>
fun
unSubscribeTopicResult
(
user
:
UserEntity
,
subInnerId
:
Int
,
deviceToken
:
String
,
topic
:
String
,
topic_id
:
String
?
):
Observable
<
List
<
SubscriptionModel
>>
}
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/domain/interactor/albums.kt
View file @
936097b5
...
@@ -5,7 +5,6 @@ import com.biganto.visual.roompark.domain.model.SubscriptionModel
...
@@ -5,7 +5,6 @@ import com.biganto.visual.roompark.domain.model.SubscriptionModel
import
com.biganto.visual.roompark.domain.model.SubscriptionTopic
import
com.biganto.visual.roompark.domain.model.SubscriptionTopic
import
com.biganto.visual.roompark.domain.use_case.AlbumsUseCase
import
com.biganto.visual.roompark.domain.use_case.AlbumsUseCase
import
com.biganto.visual.roompark.domain.use_case.SubscriptionUseCase
import
com.biganto.visual.roompark.domain.use_case.SubscriptionUseCase
import
io.reactivex.Completable
import
io.reactivex.Observable
import
io.reactivex.Observable
import
java.util.concurrent.TimeUnit
import
java.util.concurrent.TimeUnit
import
javax.inject.Inject
import
javax.inject.Inject
...
@@ -41,7 +40,7 @@ class AlbumsInteractor @Inject constructor(
...
@@ -41,7 +40,7 @@ class AlbumsInteractor @Inject constructor(
fun
getSubscriptions
(
topic
:
SubscriptionTopic
)
=
fun
getSubscriptions
(
topic
:
SubscriptionTopic
)
=
subUc
.
getSubscriptions
(
topic
)
subUc
.
getSubscriptions
(
topic
)
fun
switchSubscription
(
model
:
SubscriptionModel
,
newState
:
Boolean
)
:
Completable
=
fun
switchSubscription
(
model
:
SubscriptionModel
,
newState
:
Boolean
)
=
when
(
newState
){
when
(
newState
){
true
->
subUc
.
subscribeTopic
(
model
.
id
,
model
.
topic
)
true
->
subUc
.
subscribeTopic
(
model
.
id
,
model
.
topic
)
false
->
subUc
.
unSubscribeTopic
(
model
.
id
,
model
.
topic
)
false
->
subUc
.
unSubscribeTopic
(
model
.
id
,
model
.
topic
)
...
...
app/src/main/java/com/biganto/visual/roompark/domain/interactor/articles.kt
View file @
936097b5
...
@@ -4,7 +4,6 @@ import com.biganto.visual.roompark.domain.model.SubscriptionModel
...
@@ -4,7 +4,6 @@ import com.biganto.visual.roompark.domain.model.SubscriptionModel
import
com.biganto.visual.roompark.domain.model.SubscriptionTopic
import
com.biganto.visual.roompark.domain.model.SubscriptionTopic
import
com.biganto.visual.roompark.domain.use_case.FeedUseCase
import
com.biganto.visual.roompark.domain.use_case.FeedUseCase
import
com.biganto.visual.roompark.domain.use_case.SubscriptionUseCase
import
com.biganto.visual.roompark.domain.use_case.SubscriptionUseCase
import
io.reactivex.Completable
import
javax.inject.Inject
import
javax.inject.Inject
/**
/**
...
@@ -25,7 +24,7 @@ class ArticlesInteractor @Inject constructor(
...
@@ -25,7 +24,7 @@ class ArticlesInteractor @Inject constructor(
fun
getSubscriptions
(
feed
:
String
)
=
fun
getSubscriptions
(
feed
:
String
)
=
subUc
.
getSubscriptions
(
feedSubType
(
feed
))
subUc
.
getSubscriptions
(
feedSubType
(
feed
))
fun
switchSubscription
(
model
:
SubscriptionModel
,
newState
:
Boolean
)
:
Completable
=
fun
switchSubscription
(
model
:
SubscriptionModel
,
newState
:
Boolean
)
=
when
(
newState
){
when
(
newState
){
true
->
subUc
.
subscribeTopic
(
model
.
id
,
model
.
topic
)
true
->
subUc
.
subscribeTopic
(
model
.
id
,
model
.
topic
)
false
->
subUc
.
unSubscribeTopic
(
model
.
id
,
model
.
topic
)
false
->
subUc
.
unSubscribeTopic
(
model
.
id
,
model
.
topic
)
...
...
app/src/main/java/com/biganto/visual/roompark/domain/interactor/deal.kt
View file @
936097b5
...
@@ -34,7 +34,7 @@ class DealInteractor @Inject constructor(
...
@@ -34,7 +34,7 @@ class DealInteractor @Inject constructor(
fun
getSubscriptions
(
dealId
:
String
)
=
fun
getSubscriptions
(
dealId
:
String
)
=
subUc
.
getSubscriptions
(
SubscriptionTopic
.
Deals
(
dealId
=
dealId
))
subUc
.
getSubscriptions
(
SubscriptionTopic
.
Deals
(
dealId
=
dealId
))
fun
switchSubscription
(
model
:
SubscriptionModel
,
newState
:
Boolean
)
:
Completable
=
fun
switchSubscription
(
model
:
SubscriptionModel
,
newState
:
Boolean
)
=
when
(
newState
){
when
(
newState
){
true
->
subUc
.
subscribeTopic
(
model
.
id
,
model
.
topic
)
true
->
subUc
.
subscribeTopic
(
model
.
id
,
model
.
topic
)
false
->
subUc
.
unSubscribeTopic
(
model
.
id
,
model
.
topic
)
false
->
subUc
.
unSubscribeTopic
(
model
.
id
,
model
.
topic
)
...
...
app/src/main/java/com/biganto/visual/roompark/domain/interactor/settings.kt
View file @
936097b5
...
@@ -12,7 +12,6 @@ import com.biganto.visual.roompark.domain.model.PushSwitchModel
...
@@ -12,7 +12,6 @@ import com.biganto.visual.roompark.domain.model.PushSwitchModel
import
com.biganto.visual.roompark.domain.model.SettingsModel
import
com.biganto.visual.roompark.domain.model.SettingsModel
import
com.biganto.visual.roompark.domain.model.SubscriptionModel
import
com.biganto.visual.roompark.domain.model.SubscriptionModel
import
com.biganto.visual.roompark.domain.use_case.*
import
com.biganto.visual.roompark.domain.use_case.*
import
io.reactivex.Completable
import
io.reactivex.Observable
import
io.reactivex.Observable
import
io.reactivex.schedulers.Schedulers
import
io.reactivex.schedulers.Schedulers
import
timber.log.Timber
import
timber.log.Timber
...
@@ -85,7 +84,7 @@ class SettingsInteractor @Inject constructor(
...
@@ -85,7 +84,7 @@ class SettingsInteractor @Inject constructor(
fun
getSubscriptions
()
=
fun
getSubscriptions
()
=
subUc
.
getCurrentUserSubscriptions
()
subUc
.
getCurrentUserSubscriptions
()
fun
switchSubscription
(
model
:
SubscriptionModel
,
newState
:
Boolean
)
:
Completable
=
fun
switchSubscription
(
model
:
SubscriptionModel
,
newState
:
Boolean
)
=
when
(
newState
){
when
(
newState
){
true
->
subUc
.
subscribeTopic
(
model
.
id
,
model
.
topic
)
true
->
subUc
.
subscribeTopic
(
model
.
id
,
model
.
topic
)
false
->
subUc
.
unSubscribeTopic
(
model
.
id
,
model
.
topic
)
false
->
subUc
.
unSubscribeTopic
(
model
.
id
,
model
.
topic
)
...
...
app/src/main/java/com/biganto/visual/roompark/domain/use_case/subscriptionUseCase.kt
View file @
936097b5
...
@@ -11,7 +11,6 @@ import com.biganto.visual.roompark.domain.model.SubscriptionModel
...
@@ -11,7 +11,6 @@ import com.biganto.visual.roompark.domain.model.SubscriptionModel
import
com.biganto.visual.roompark.domain.model.SubscriptionTopic
import
com.biganto.visual.roompark.domain.model.SubscriptionTopic
import
com.biganto.visual.roompark.domain.model.TitledSubscriptionModel
import
com.biganto.visual.roompark.domain.model.TitledSubscriptionModel
import
com.biganto.visual.roompark.domain.model.fromEntity
import
com.biganto.visual.roompark.domain.model.fromEntity
import
io.reactivex.Completable
import
io.reactivex.Observable
import
io.reactivex.Observable
import
io.reactivex.functions.BiFunction
import
io.reactivex.functions.BiFunction
import
io.reactivex.schedulers.Schedulers
import
io.reactivex.schedulers.Schedulers
...
@@ -28,55 +27,75 @@ class SubscriptionUseCase @Inject constructor(
...
@@ -28,55 +27,75 @@ class SubscriptionUseCase @Inject constructor(
private
val
utils
:
DeviceUtilsContract
,
private
val
utils
:
DeviceUtilsContract
,
private
val
auth
:
AuthContract
private
val
auth
:
AuthContract
)
{
)
{
fun
subscribeTopic
(
subId
:
Int
,
topic
:
SubscriptionTopic
):
Completable
=
fun
subscribeTopic
(
subId
:
Int
,
topic
:
SubscriptionTopic
):
Observable
<
List
<
TitledSubscriptionModel
>>
=
Observable
.
zip
(
auth
.
currentUser
(),
utils
.
getDeviceId
()
Observable
.
zip
(
auth
.
currentUser
(),
utils
.
getDeviceId
()
,
BiFunction
<
UserEntity
,
String
,
SubscribeRequestModel
>
{
,
BiFunction
<
UserEntity
,
String
,
SubscribeRequestModel
>
{
user
,
token
->
SubscribeRequestModel
(
user
,
token
)
user
,
token
->
SubscribeRequestModel
(
user
,
token
)
})
})
.
flatMap
Completable
{
.
flatMap
{
requestModel
->
subscription
.
subscribeTopic
(
subscription
.
subscribeTopic
Result
(
it
.
user
requestModel
.
user
,
subId
,
subId
,
it
.
deviceToken
,
requestModel
.
deviceToken
,
topic
=
topic
.
topicName
,
,
topic
=
topic
.
topicName
topic_id
=
topic
.
topicId
,
topic_id
=
topic
.
topicId
).
subscribeOn
(
Schedulers
.
io
())
)
.
map
{
subs
->
subsToTitle
(
requestModel
.
user
,
subs
)}
.
subscribeOn
(
Schedulers
.
io
())
}
}
fun
unSubscribeTopic
(
subId
:
Int
,
topic
:
SubscriptionTopic
):
Completable
=
fun
unSubscribeTopic
(
subId
:
Int
,
topic
:
SubscriptionTopic
):
Observable
<
List
<
TitledSubscriptionModel
>>
=
Observable
.
zip
(
auth
.
currentUser
(),
utils
.
getDeviceId
()
Observable
.
zip
(
auth
.
currentUser
(),
utils
.
getDeviceId
()
,
BiFunction
<
UserEntity
,
String
,
SubscribeRequestModel
>
{
,
BiFunction
<
UserEntity
,
String
,
SubscribeRequestModel
>
{
user
,
token
->
SubscribeRequestModel
(
user
,
token
)
user
,
token
->
SubscribeRequestModel
(
user
,
token
)
})
})
.
flatMap
Completable
{
.
flatMap
{
requestModel
->
subscription
.
unSubscribeTopic
(
subscription
.
unSubscribeTopic
Result
(
it
.
user
requestModel
.
user
,
subId
,
subId
,
it
.
deviceToken
,
requestModel
.
deviceToken
,
topic
=
topic
.
topicName
,
,
topic
=
topic
.
topicName
,
topic_id
=
topic
.
topicId
topic_id
=
topic
.
topicId
).
subscribeOn
(
Schedulers
.
io
())
)
.
map
{
subs
->
subsToTitle
(
requestModel
.
user
,
subs
)}
.
subscribeOn
(
Schedulers
.
io
())
}
}
fun
getCurrentUserSubscriptions
():
Observable
<
List
<
TitledSubscriptionModel
>>
=
private
fun
subsToTitle
(
user
:
UserEntity
,
subs
:
List
<
SubscriptionModel
>?)
auth
.
currentUser
()
:
List
<
TitledSubscriptionModel
>
{
.
map
{
user
->
val
subList
=
val
subList
=
user
.
subscriptions
?:
arrayListOf
()
subs
val
list
=
List
<
TitledSubscriptionModel
>(
subList
.
size
){
i
->
?:
user
.
subscriptions
val
sub
:
SubscriptionModel
=
fromEntity
(
subList
[
i
]
as
SubscriptionEntity
)
?.
asSequence
()
?.
map
{
it
as
SubscriptionEntity
}
?.
map
(
::
fromEntity
)
?.
toList
()
?:
arrayListOf
()
return
List
(
subList
.
size
){
i
->
subToTitledSub
(
user
.
deals
?.
map
{
it
as
DealEntity
}
?:
arrayListOf
(),
subList
[
i
])
}
}
private
fun
subToTitledSub
(
deals
:
List
<
DealEntity
>,
sub
:
SubscriptionModel
)
:
TitledSubscriptionModel
{
var
title
=
SubscriptionTopic
.
titleByTopic
(
sub
.
topic
)
var
title
=
SubscriptionTopic
.
titleByTopic
(
sub
.
topic
)
if
(
sub
.
topic
is
SubscriptionTopic
.
Deals
)
{
if
(
sub
.
topic
is
SubscriptionTopic
.
Deals
)
{
val
deal
=
val
deal
=
user
.
deals
?.
firstOrNull
{
d
->
d
.
estateCrmId
==
sub
.
topic
.
topicId
}
as
DealEntity
deals
.
firstOrNull
{
d
->
d
.
estateCrmId
==
sub
.
topic
.
topicId
}
title
=
"$title № ${deal.estate.number}"
if
(
deal
==
null
)
Timber
.
e
(
"Deal not recognized: $sub ; $deals"
)
title
=
"$title № ${deal?.estate?.number}"
}
}
TitledSubscriptionModel
(
title
,
sub
)
return
TitledSubscriptionModel
(
title
,
sub
)
}
list
}
}
fun
getCurrentUserSubscriptions
():
Observable
<
List
<
TitledSubscriptionModel
>>
=
auth
.
currentUser
()
.
map
{
user
->
subsToTitle
(
user
,
null
)}
fun
getSubscriptions
(
topic
:
SubscriptionTopic
):
Observable
<
SubscriptionModel
>
=
fun
getSubscriptions
(
topic
:
SubscriptionTopic
):
Observable
<
SubscriptionModel
>
=
auth
.
currentUser
()
auth
.
currentUser
()
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/ScreenPresenter.kt
View file @
936097b5
...
@@ -48,13 +48,14 @@ class AlbumsScreenPresenter @Inject constructor(
...
@@ -48,13 +48,14 @@ class AlbumsScreenPresenter @Inject constructor(
.
filter
{
restoreModel
.
sub
!=
null
}
.
filter
{
restoreModel
.
sub
!=
null
}
.
flatMap
{
newState
->
.
flatMap
{
newState
->
interactor
.
switchSubscription
(
restoreModel
.
sub
!!
,
newState
)
interactor
.
switchSubscription
(
restoreModel
.
sub
!!
,
newState
)
.
andThen
(
.
map
{
subs
->
Observable
.
just
<
AlbumsScreenViewState
>(
val
s
=
subs
.
map
{
it
.
subModel
}.
firstOrNull
{
it
.
id
==
restoreModel
.
sub
?.
id
}
AlbumsScreenViewState
.
SubscriptionStatus
(
restoreModel
.
sub
=
s
newState
if
(
s
!=
null
)
)
return
@map
AlbumsScreenViewState
.
SubscriptionStatus
(
s
.
state
)
)
else
)
return
@map
AlbumsScreenViewState
.
SubscriptionError
(!
newState
)
}
.
onErrorReturn
{
AlbumsScreenViewState
.
SubscriptionError
(!
newState
)
}
.
onErrorReturn
{
AlbumsScreenViewState
.
SubscriptionError
(!
newState
)
}
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/deal/ScreenPresenter.kt
View file @
936097b5
...
@@ -55,14 +55,18 @@ class DealScreenPresenter @Inject constructor(
...
@@ -55,14 +55,18 @@ class DealScreenPresenter @Inject constructor(
.
filter
{
restoreModel
.
sub
!=
null
}
.
filter
{
restoreModel
.
sub
!=
null
}
.
flatMap
{
newState
->
.
flatMap
{
newState
->
interactor
.
switchSubscription
(
restoreModel
.
sub
!!
,
newState
)
interactor
.
switchSubscription
(
restoreModel
.
sub
!!
,
newState
)
.
andThen
(
.
map
{
subs
->
Observable
.
just
<
DealScreenViewState
>(
val
s
=
subs
.
map
{
it
.
subModel
}.
firstOrNull
{
it
.
id
==
restoreModel
.
sub
?.
id
}
DealScreenViewState
.
SubscriptionStatus
(
newState
)
restoreModel
.
sub
=
s
)
if
(
s
!=
null
)
)
return
@map
DealScreenViewState
.
SubscriptionStatus
(
s
.
state
)
else
return
@map
DealScreenViewState
.
SubscriptionError
(!
newState
)
}
.
onErrorReturn
{
DealScreenViewState
.
SubscriptionError
(!
newState
)
}
.
onErrorReturn
{
DealScreenViewState
.
SubscriptionError
(!
newState
)
}
}
}
val
fetchSubscription
=
val
fetchSubscription
=
fetchDeal
.
flatMap
{
fetchedDealViewState
->
fetchDeal
.
flatMap
{
fetchedDealViewState
->
interactor
.
getSubscriptions
(
interactor
.
getSubscriptions
(
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/deals/ScreenPresenter.kt
View file @
936097b5
...
@@ -39,7 +39,6 @@ class DealsScreenPresenter @Inject constructor(
...
@@ -39,7 +39,6 @@ class DealsScreenPresenter @Inject constructor(
)
)
}
}
}
}
.
doOnError
{
Timber
.
e
(
" ERORORO "
)
}
}
}
.
map
<
DealsScreenViewState
>(
DealsScreenViewState
::
DealsLoaded
)
.
map
<
DealsScreenViewState
>(
DealsScreenViewState
::
DealsLoaded
)
.
onErrorReturn
(
::
parseError
)
.
onErrorReturn
(
::
parseError
)
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feed_list/ScreenPresenter.kt
View file @
936097b5
...
@@ -43,13 +43,14 @@ class ArticlesScreenPresenter @Inject constructor(
...
@@ -43,13 +43,14 @@ class ArticlesScreenPresenter @Inject constructor(
.
filter
{
restoreModel
.
sub
!=
null
}
.
filter
{
restoreModel
.
sub
!=
null
}
.
flatMap
{
newState
->
.
flatMap
{
newState
->
interactor
.
switchSubscription
(
restoreModel
.
sub
!!
,
newState
)
interactor
.
switchSubscription
(
restoreModel
.
sub
!!
,
newState
)
.
andThen
(
.
map
{
subs
->
Observable
.
just
<
ArticlesScreenViewState
>(
val
s
=
subs
.
map
{
it
.
subModel
}.
firstOrNull
{
it
.
id
==
restoreModel
.
sub
?.
id
}
ArticlesScreenViewState
.
SubscriptionStatus
(
restoreModel
.
sub
=
s
newState
if
(
s
!=
null
)
)
return
@map
ArticlesScreenViewState
.
SubscriptionStatus
(
s
.
state
)
)
else
)
return
@map
ArticlesScreenViewState
.
SubscriptionError
(!
newState
)
}
.
onErrorReturn
{
ArticlesScreenViewState
.
SubscriptionError
(!
newState
)
}
.
onErrorReturn
{
ArticlesScreenViewState
.
SubscriptionError
(!
newState
)
}
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenPresenter.kt
View file @
936097b5
...
@@ -67,12 +67,12 @@ class SettingsScreenPresenter @Inject constructor(
...
@@ -67,12 +67,12 @@ class SettingsScreenPresenter @Inject constructor(
val
onSubChecked
=
intent
(
SettingsScreen
::
onSubscription
)
val
onSubChecked
=
intent
(
SettingsScreen
::
onSubscription
)
.
flatMap
{
sub
->
.
flatMap
{
sub
->
interactor
.
switchSubscription
(
sub
,
!
sub
.
state
)
interactor
.
switchSubscription
(
sub
,
!
sub
.
state
)
.
andThen
(
.
map
<
SettingsScreenViewState
>
{
Observable
.
just
<
SettingsScreenViewState
>(
restoreModel
.
subs
=
it
.
toMutableList
()
SettingsScreenViewState
.
SubscriptionStatus
(
SettingsScreenViewState
.
SubscriptionStatus
(
sub
.
id
,
!
sub
.
state
sub
.
id
,
!
sub
.
state
)
)
)
}
.
doOnNext
{
.
doOnNext
{
val
ind
=
restoreModel
val
ind
=
restoreModel
.
subs
.
subs
...
@@ -87,8 +87,6 @@ class SettingsScreenPresenter @Inject constructor(
...
@@ -87,8 +87,6 @@ class SettingsScreenPresenter @Inject constructor(
)
)
)
)
}
}
)
.
doOnError
{
Timber
.
e
(
it
)
}
.
doOnError
{
Timber
.
e
(
it
)
}
.
onErrorReturn
{
SettingsScreenViewState
.
SubscriptionError
(
sub
.
id
,
sub
.
state
)
}
.
onErrorReturn
{
SettingsScreenViewState
.
SubscriptionError
(
sub
.
id
,
sub
.
state
)
}
}
}
...
...
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