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
80becc0d
Commit
80becc0d
authored
Apr 29, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
deals list merge
parent
0c141bec
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
111 additions
and
70 deletions
+111
-70
EstateRepository.kt
...to/visual/roompark/data/data_provider/EstateRepository.kt
+24
-35
SubscriptionRepository.kt
...ual/roompark/data/data_provider/SubscriptionRepository.kt
+0
-3
IDb.kt
...ava/com/biganto/visual/roompark/data/repository/db/IDb.kt
+3
-0
RequeryRepository.kt
.../roompark/data/repository/db/requrey/RequeryRepository.kt
+9
-0
DealContract.kt
...m/biganto/visual/roompark/domain/contract/DealContract.kt
+3
-3
deal.kt
...ava/com/biganto/visual/roompark/domain/interactor/deal.kt
+1
-2
deals.kt
...va/com/biganto/visual/roompark/domain/interactor/deals.kt
+4
-1
dealUseCase.kt
...om/biganto/visual/roompark/domain/use_case/dealUseCase.kt
+21
-2
planTypesUseCase.kt
...ganto/visual/roompark/domain/use_case/planTypesUseCase.kt
+4
-1
subscriptionUseCase.kt
...to/visual/roompark/domain/use_case/subscriptionUseCase.kt
+6
-11
ScreenPresenter.kt
...sual/roompark/presentation/screen/deal/ScreenPresenter.kt
+13
-10
ScreenPresenter.kt
...ual/roompark/presentation/screen/deals/ScreenPresenter.kt
+17
-0
ScreenPresenter.kt
...al/roompark/presentation/screen/estate/ScreenPresenter.kt
+6
-2
No files found.
app/src/main/java/com/biganto/visual/roompark/data/data_provider/EstateRepository.kt
View file @
80becc0d
...
@@ -11,7 +11,6 @@ import com.biganto.visual.roompark.data.repository.mapper.fromRaw
...
@@ -11,7 +11,6 @@ import com.biganto.visual.roompark.data.repository.mapper.fromRaw
import
com.biganto.visual.roompark.data.repository.mapper.fromRawList
import
com.biganto.visual.roompark.data.repository.mapper.fromRawList
import
com.biganto.visual.roompark.domain.contract.DealContract
import
com.biganto.visual.roompark.domain.contract.DealContract
import
com.biganto.visual.roompark.domain.custom_exception.CustomApiException
import
com.biganto.visual.roompark.domain.custom_exception.CustomApiException
import
com.biganto.visual.roompark.domain.model.DealModel
import
com.biganto.visual.roompark.domain.model.EstateModel
import
com.biganto.visual.roompark.domain.model.EstateModel
import
com.biganto.visual.roompark.domain.model.fromEntity
import
com.biganto.visual.roompark.domain.model.fromEntity
import
io.reactivex.Completable
import
io.reactivex.Completable
...
@@ -51,7 +50,6 @@ class EstateRepository @Inject constructor(
...
@@ -51,7 +50,6 @@ class EstateRepository @Inject constructor(
estate
.
setFavorite
(
true
)
estate
.
setFavorite
(
true
)
estate
.
user
=
user
estate
.
user
=
user
}
}
dbList
dbList
.
filterNotNull
()
.
filterNotNull
()
.
filter
{
dbFav
->!
apiList
.
map
{
it
.
id
}.
contains
(
dbFav
.
id
)
}
.
filter
{
dbFav
->!
apiList
.
map
{
it
.
id
}.
contains
(
dbFav
.
id
)
}
...
@@ -63,13 +61,8 @@ class EstateRepository @Inject constructor(
...
@@ -63,13 +61,8 @@ class EstateRepository @Inject constructor(
.
map
{
it
.
toList
()
}
.
map
{
it
.
toList
()
}
.
doOnNext
{
db
.
refreshUser
(
user
)
}
.
doOnNext
{
db
.
refreshUser
(
user
)
}
override
fun
fetchDeals
(
user
:
UserEntity
):
Observable
<
List
<
EstateEntity
>>
=
override
fun
fetchDeals
(
user
:
UserEntity
):
Observable
<
List
<
DealEntity
>>
=
api
.
getDeals
(
user
.
authToken
)
//api.getDeals(user.authToken)
getDealsApi
(
user
)
.
doOnError
(
Timber
::
e
)
.
map
{
List
(
it
.
size
){
index
->
fromRaw
(
it
[
index
],
user
)}
}
.
flatMap
(
db
::
upsertDeals
)
.
map
{
it
.
map
{
deal
->
deal
.
estate
as
EstateEntity
}
}
.
doOnNext
{
db
.
refreshUser
(
user
)
}
private
fun
fetchEstateDb
(
id
:
Int
)
=
db
.
getEstate
(
id
)
private
fun
fetchEstateDb
(
id
:
Int
)
=
db
.
getEstate
(
id
)
...
@@ -80,23 +73,29 @@ class EstateRepository @Inject constructor(
...
@@ -80,23 +73,29 @@ class EstateRepository @Inject constructor(
private
val
getDealsApi
:
Observable
<
List
<
DealEntity
>>
=
override
fun
getDealsApi
(
user
:
UserEntity
):
Observable
<
List
<
DealEntity
>>
=
local
.
recentUser
()
Observables
.
zip
(
.
doOnError
(
Timber
::
e
)
api
.
getDeals
(
user
.
authToken
)
.
flatMap
{
.
doOnError
(
Timber
::
e
)
when
(
it
)
{
.
map
{
List
(
it
.
size
){
index
->
fromRaw
(
it
[
index
],
user
)}
}
is
UserState
.
Authenticated
->
db
.
fetchUser
(
it
.
uuid
.
toInt
())
,
db
.
getUserDeals
(
user
.
uuid
)
else
->
throw
CustomApiException
.
NotAuthorizedException
()
.
toList
().
toObservable
()
.
doOnError
(
Timber
::
e
)
){
apiList
,
dbList
->
apiList
.
forEach
{
deal
->
dbList
?.
firstOrNull
{
dbDeal
->
dbDeal
?.
id
==
deal
.
id
}
?.
let
{
deal
.
setRead
(
it
.
read
)
}
}
deal
.
user
=
user
}
}
.
doOnError
(
Timber
::
e
)
dbList
.
flatMap
{
user
->
.
filterNotNull
()
api
.
getDeals
(
user
.
authToken
)
//api.getDeals(user.authToken)
.
filter
{
dbFav
->!
apiList
.
map
{
it
.
id
}.
contains
(
dbFav
.
id
)
}
.
doOnError
(
Timber
::
e
)
.
let
{
db
.
deleteDeal
(
it
)
}
.
map
{
List
(
it
.
size
){
index
->
fromRaw
(
it
[
index
],
user
)}
}
return
@zip
apiList
.
doOnNext
(
db
::
blockingUpsert
)
}
.
doOnNext
{
db
.
refreshUser
(
user
)
}
.
doOnNext
(
db
::
blockingUpsert
)
}
.
doOnNext
{
db
.
refreshUser
(
user
)
}
private
val
getDealsDb
:
Observable
<
List
<
DealEntity
>>
=
private
val
getDealsDb
:
Observable
<
List
<
DealEntity
>>
=
local
.
recentUser
()
local
.
recentUser
()
...
@@ -109,21 +108,11 @@ class EstateRepository @Inject constructor(
...
@@ -109,21 +108,11 @@ class EstateRepository @Inject constructor(
.
map
{
it
.
deals
?.
map
{
deal
->
deal
as
DealEntity
}
}
.
map
{
it
.
deals
?.
map
{
deal
->
deal
as
DealEntity
}
}
override
fun
getDeals
():
Observable
<
List
<
DealModel
>>
{
return
Observable
.
mergeDelayError
(
arrayListOf
(
getDealsDb
,
getDealsApi
)
)
.
map
{
fromEntity
(
it
,
::
fromEntity
)
}
.
doOnError
(
Timber
::
e
)
.
subscribeOn
(
Schedulers
.
io
())
}
override
fun
setDealRead
(
dealId
:
String
):
Completable
=
override
fun
setDealRead
(
dealId
:
String
):
Completable
=
db
.
setDealReadState
(
dealId
,
true
)
db
.
setDealReadState
(
dealId
,
true
)
.
doOnError
{
Timber
.
e
(
it
)
}
...
...
app/src/main/java/com/biganto/visual/roompark/data/data_provider/SubscriptionRepository.kt
View file @
80becc0d
...
@@ -66,10 +66,8 @@ class SubscriptionRepository @Inject constructor(
...
@@ -66,10 +66,8 @@ class SubscriptionRepository @Inject constructor(
val
newSubList
=
mutableListOf
<
SubscriptionEntity
>()
val
newSubList
=
mutableListOf
<
SubscriptionEntity
>()
apiSubs
.
forEach
{
apiSub
->
apiSubs
.
forEach
{
apiSub
->
Timber
.
d
(
"api sub state: ${apiSub.active}"
)
val
cachedSub
=
val
cachedSub
=
userSubs
?.
firstOrNull
{
s
->
userSubs
?.
firstOrNull
{
s
->
Timber
.
w
(
"hehe ${s.topic} == ${apiSub.topic} && ${s.number} == ${apiSub.estate_id}"
)
s
.
topic
==
apiSub
.
topic
&&
s
.
number
==
apiSub
.
estate_id
s
.
topic
==
apiSub
.
topic
&&
s
.
number
==
apiSub
.
estate_id
}
}
as
SubscriptionEntity
?
as
SubscriptionEntity
?
...
@@ -88,7 +86,6 @@ class SubscriptionRepository @Inject constructor(
...
@@ -88,7 +86,6 @@ class SubscriptionRepository @Inject constructor(
db
.
deleteSubscriptions
(
it
)
db
.
deleteSubscriptions
(
it
)
}
}
Timber
.
w
(
"to newSubList; ${newSubList}"
)
return
db
.
upsert
(
newSubList
)
return
db
.
upsert
(
newSubList
)
.
map
{
list
->
list
.
map
{
.
map
{
list
->
list
.
map
{
fromEntity
(
fromEntity
(
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/db/IDb.kt
View file @
80becc0d
...
@@ -80,4 +80,7 @@ interface IDb {
...
@@ -80,4 +80,7 @@ interface IDb {
fun
deleteSubscriptions
(
entities
:
List
<
Subscription
>)
fun
deleteSubscriptions
(
entities
:
List
<
Subscription
>)
fun
deleteEstate
(
entity
:
List
<
EstateEntity
>)
fun
deleteEstate
(
entity
:
List
<
EstateEntity
>)
fun
deleteEstate
(
entity
:
EstateEntity
)
fun
deleteEstate
(
entity
:
EstateEntity
)
fun
getUserDeals
(
uuid
:
Int
):
Observable
<
DealEntity
?
>
fun
deleteDeal
(
entity
:
DealEntity
)
fun
deleteDeal
(
entity
:
List
<
DealEntity
>)
}
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/data/repository/db/requrey/RequeryRepository.kt
View file @
80becc0d
...
@@ -196,6 +196,11 @@ class RequeryRepository @Inject constructor(
...
@@ -196,6 +196,11 @@ class RequeryRepository @Inject constructor(
.
and
(
EstateEntity
.
FAVORITE
.
eq
(
true
))
.
and
(
EstateEntity
.
FAVORITE
.
eq
(
true
))
.
get
().
observable
()
.
get
().
observable
()
override
fun
getUserDeals
(
uuid
:
Int
):
Observable
<
DealEntity
?
>
=
store
.
select
(
DealEntity
::
class
)
.
where
(
DealEntity
.
USER_ID
.
eq
(
uuid
))
.
get
().
observable
()
override
fun
setArticleReadState
(
id
:
Int
,
state
:
Boolean
):
Completable
=
override
fun
setArticleReadState
(
id
:
Int
,
state
:
Boolean
):
Completable
=
store
.
update
(
ArticleEntity
::
class
)
store
.
update
(
ArticleEntity
::
class
)
.
set
(
ArticleEntity
.
READ
,
state
)
.
set
(
ArticleEntity
.
READ
,
state
)
...
@@ -411,8 +416,12 @@ class RequeryRepository @Inject constructor(
...
@@ -411,8 +416,12 @@ class RequeryRepository @Inject constructor(
override
fun
deleteEstate
(
entity
:
EstateEntity
)
=
deleteBlocking
(
entity
)
override
fun
deleteEstate
(
entity
:
EstateEntity
)
=
deleteBlocking
(
entity
)
override
fun
deleteDeal
(
entity
:
DealEntity
)
=
deleteBlocking
(
entity
)
override
fun
deleteEstate
(
entity
:
List
<
EstateEntity
>)
=
deleteBlocking
(
entity
)
override
fun
deleteEstate
(
entity
:
List
<
EstateEntity
>)
=
deleteBlocking
(
entity
)
override
fun
deleteDeal
(
entity
:
List
<
DealEntity
>)
=
deleteBlocking
(
entity
)
override
fun
deleteFile
(
entity
:
FileEntity
)
=
deleteBlocking
(
entity
)
override
fun
deleteFile
(
entity
:
FileEntity
)
=
deleteBlocking
(
entity
)
override
fun
deleteFiles
(
entity
:
List
<
FileEntity
>)
=
deleteBlocking
(
entity
)
override
fun
deleteFiles
(
entity
:
List
<
FileEntity
>)
=
deleteBlocking
(
entity
)
...
...
app/src/main/java/com/biganto/visual/roompark/domain/contract/DealContract.kt
View file @
80becc0d
package
com.biganto.visual.roompark.domain.contract
package
com.biganto.visual.roompark.domain.contract
import
com.biganto.visual.roompark.data.repository.db.requrey.model.DealEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.EstateEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.EstateEntity
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.DealModel
import
com.biganto.visual.roompark.domain.model.EstateModel
import
com.biganto.visual.roompark.domain.model.EstateModel
import
io.reactivex.Completable
import
io.reactivex.Completable
import
io.reactivex.Observable
import
io.reactivex.Observable
...
@@ -16,9 +16,9 @@ interface DealContract{
...
@@ -16,9 +16,9 @@ interface DealContract{
// fun getFavorites() : Observable<List<EstateModel>>
// fun getFavorites() : Observable<List<EstateModel>>
fun
getEstate
(
estateId
:
Int
):
Observable
<
EstateModel
>
fun
getEstate
(
estateId
:
Int
):
Observable
<
EstateModel
>
fun
getDeals
():
Observable
<
List
<
DealModel
>>
fun
fetchEstate
(
building
:
Int
,
number
:
Int
):
Observable
<
EstateModel
>
fun
fetchEstate
(
building
:
Int
,
number
:
Int
):
Observable
<
EstateModel
>
fun
setDealRead
(
dealId
:
String
):
Completable
fun
setDealRead
(
dealId
:
String
):
Completable
fun
fetchDeals
(
user
:
UserEntity
):
Observable
<
List
<
Estate
Entity
>>
fun
fetchDeals
(
user
:
UserEntity
):
Observable
<
List
<
Deal
Entity
>>
fun
fetchFavorites
(
user
:
UserEntity
):
Observable
<
List
<
EstateEntity
>>
fun
fetchFavorites
(
user
:
UserEntity
):
Observable
<
List
<
EstateEntity
>>
fun
getDealsApi
(
user
:
UserEntity
):
Observable
<
List
<
DealEntity
>>
}
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/domain/interactor/deal.kt
View file @
80becc0d
...
@@ -20,8 +20,7 @@ class DealInteractor @Inject constructor(
...
@@ -20,8 +20,7 @@ class DealInteractor @Inject constructor(
){
){
fun
getDeal
(
id
:
String
):
Observable
<
DealModel
>
=
fun
getDeal
(
id
:
String
):
Observable
<
DealModel
>
=
useCase
.
getDeals
()
useCase
.
prefetchDeal
()
.
doOnNext
{
Timber
.
d
(
"$it"
)
}
.
map
{
deals
->
deals
.
first
{
it
.
id
==
id
}
}
.
map
{
deals
->
deals
.
first
{
it
.
id
==
id
}
}
fun
getStatusList
()
=
Observable
.
just
(
statusList
.
sortedBy
{
it
.
orderId
})
fun
getStatusList
()
=
Observable
.
just
(
statusList
.
sortedBy
{
it
.
orderId
})
...
...
app/src/main/java/com/biganto/visual/roompark/domain/interactor/deals.kt
View file @
80becc0d
package
com.biganto.visual.roompark.domain.interactor
package
com.biganto.visual.roompark.domain.interactor
import
com.biganto.visual.roompark.domain.model.DealModel
import
com.biganto.visual.roompark.domain.model.StatusModel
import
com.biganto.visual.roompark.domain.model.StatusModel
import
com.biganto.visual.roompark.domain.use_case.DealseUseCase
import
com.biganto.visual.roompark.domain.use_case.DealseUseCase
import
io.reactivex.Observable
import
io.reactivex.Observable
...
@@ -13,7 +14,9 @@ class DealsInteractor @Inject constructor(
...
@@ -13,7 +14,9 @@ class DealsInteractor @Inject constructor(
val
useCase
:
DealseUseCase
val
useCase
:
DealseUseCase
){
){
fun
fetchDeals
()
=
useCase
.
getDeals
()
fun
fetchDeals
():
Observable
<
List
<
DealModel
>>
=
useCase
.
prefetchDeal
()
fun
getDealsApi
():
Observable
<
List
<
DealModel
>>
=
useCase
.
getDeals
()
// Single.just(arrayListOf(dealFlat, dealParkign))
// Single.just(arrayListOf(dealFlat, dealParkign))
fun
getStatusList
()
=
Observable
.
just
(
statusList
.
sortedBy
{
it
.
orderId
})
fun
getStatusList
()
=
Observable
.
just
(
statusList
.
sortedBy
{
it
.
orderId
})
...
...
app/src/main/java/com/biganto/visual/roompark/domain/use_case/dealUseCase.kt
View file @
80becc0d
package
com.biganto.visual.roompark.domain.use_case
package
com.biganto.visual.roompark.domain.use_case
import
com.biganto.visual.roompark.data.repository.db.requrey.model.DealEntity
import
com.biganto.visual.roompark.domain.contract.AuthContract
import
com.biganto.visual.roompark.domain.contract.DealContract
import
com.biganto.visual.roompark.domain.contract.DealContract
import
com.biganto.visual.roompark.domain.model.DealModel
import
com.biganto.visual.roompark.domain.model.fromEntity
import
io.reactivex.Observable
import
timber.log.Timber
import
javax.inject.Inject
import
javax.inject.Inject
/**
/**
...
@@ -8,10 +14,23 @@ import javax.inject.Inject
...
@@ -8,10 +14,23 @@ import javax.inject.Inject
*/
*/
class
DealseUseCase
@Inject
constructor
(
class
DealseUseCase
@Inject
constructor
(
private
val
contract
:
DealContract
private
val
contract
:
DealContract
,
private
val
authContract
:
AuthContract
)
{
)
{
fun
getDeals
()
=
contract
.
getDeals
()
fun
prefetchDeal
():
Observable
<
List
<
DealModel
>>
=
authContract
.
currentUser
()
.
map
{
user
->
user
.
deals
?.
asSequence
()
?.
map
{
it
as
DealEntity
}
?.
filterNotNull
()
?.
toList
()
}
.
map
{
fromEntity
(
it
,
::
fromEntity
)
}
fun
getDeals
():
Observable
<
List
<
DealModel
>>
=
authContract
.
currentUser
()
.
flatMap
(
contract
::
getDealsApi
)
.
map
{
fromEntity
(
it
,
::
fromEntity
)
}
fun
setDealRead
(
id
:
String
)
=
contract
.
setDealRead
(
id
)
fun
setDealRead
(
id
:
String
)
=
contract
.
setDealRead
(
id
)
...
...
app/src/main/java/com/biganto/visual/roompark/domain/use_case/planTypesUseCase.kt
View file @
80becc0d
...
@@ -21,7 +21,10 @@ class PlanTypesUseCase @Inject constructor(
...
@@ -21,7 +21,10 @@ class PlanTypesUseCase @Inject constructor(
)
{
)
{
private
fun
fetchUserEstates
(
user
:
UserEntity
):
Observable
<
List
<
EstateEntity
>>
=
private
fun
fetchUserEstates
(
user
:
UserEntity
):
Observable
<
List
<
EstateEntity
>>
=
Observables
.
zip
(
dealContract
.
fetchDeals
(
user
),
dealContract
.
fetchFavorites
(
user
))
Observables
.
zip
(
dealContract
.
fetchDeals
(
user
)
.
map
{
it
.
map
{
deal
->
deal
.
estate
as
EstateEntity
}
}
,
dealContract
.
fetchFavorites
(
user
))
{
t1
,
t2
->
t1
+
t2
}
{
t1
,
t2
->
t1
+
t2
}
private
val
fetchAllPlanTypes
=
private
val
fetchAllPlanTypes
=
...
...
app/src/main/java/com/biganto/visual/roompark/domain/use_case/subscriptionUseCase.kt
View file @
80becc0d
...
@@ -12,7 +12,7 @@ import com.biganto.visual.roompark.domain.model.SubscriptionTopic
...
@@ -12,7 +12,7 @@ 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.Observable
import
io.reactivex.Observable
import
io.reactivex.
functions.BiFunction
import
io.reactivex.
rxkotlin.Observables
import
io.reactivex.schedulers.Schedulers
import
io.reactivex.schedulers.Schedulers
import
timber.log.Timber
import
timber.log.Timber
import
javax.inject.Inject
import
javax.inject.Inject
...
@@ -31,10 +31,9 @@ class SubscriptionUseCase @Inject constructor(
...
@@ -31,10 +31,9 @@ class SubscriptionUseCase @Inject constructor(
fun
subscribeTopic
(
subId
:
Int
,
topic
:
SubscriptionTopic
):
Observable
<
List
<
TitledSubscriptionModel
>>
=
fun
subscribeTopic
(
subId
:
Int
,
topic
:
SubscriptionTopic
):
Observable
<
List
<
TitledSubscriptionModel
>>
=
Observable
.
zip
(
auth
.
currentUser
(),
utils
.
getDeviceId
()
Observables
.
zip
(
auth
.
currentUser
(),
utils
.
getDeviceId
()){
,
BiFunction
<
UserEntity
,
String
,
SubscribeRequestModel
>
{
user
,
token
->
SubscribeRequestModel
(
user
,
token
)
user
,
token
->
SubscribeRequestModel
(
user
,
token
)
}
})
.
flatMap
{
requestModel
->
.
flatMap
{
requestModel
->
subscription
.
subscribeTopicResult
(
subscription
.
subscribeTopicResult
(
requestModel
.
user
requestModel
.
user
...
@@ -50,10 +49,9 @@ class SubscriptionUseCase @Inject constructor(
...
@@ -50,10 +49,9 @@ class SubscriptionUseCase @Inject constructor(
fun
unSubscribeTopic
(
subId
:
Int
,
topic
:
SubscriptionTopic
):
Observable
<
List
<
TitledSubscriptionModel
>>
=
fun
unSubscribeTopic
(
subId
:
Int
,
topic
:
SubscriptionTopic
):
Observable
<
List
<
TitledSubscriptionModel
>>
=
Observable
.
zip
(
auth
.
currentUser
(),
utils
.
getDeviceId
()
Observables
.
zip
(
auth
.
currentUser
(),
utils
.
getDeviceId
()){
,
BiFunction
<
UserEntity
,
String
,
SubscribeRequestModel
>
{
user
,
token
->
SubscribeRequestModel
(
user
,
token
)
user
,
token
->
SubscribeRequestModel
(
user
,
token
)
}
)
}
.
flatMap
{
requestModel
->
.
flatMap
{
requestModel
->
subscription
.
unSubscribeTopicResult
(
subscription
.
unSubscribeTopicResult
(
requestModel
.
user
requestModel
.
user
...
@@ -102,7 +100,6 @@ class SubscriptionUseCase @Inject constructor(
...
@@ -102,7 +100,6 @@ class SubscriptionUseCase @Inject constructor(
.
map
{
user
->
.
map
{
user
->
var
sub
=
user
.
subscriptions
var
sub
=
user
.
subscriptions
?.
firstOrNull
{
it
.
topic
==
topic
.
topicName
&&
it
.
number
==
topic
.
topicId
}
?.
firstOrNull
{
it
.
topic
==
topic
.
topicName
&&
it
.
number
==
topic
.
topicId
}
Timber
.
d
(
"fetched topic: $sub"
)
if
(
sub
==
null
)
{
if
(
sub
==
null
)
{
sub
=
SubscriptionEntity
()
sub
=
SubscriptionEntity
()
sub
.
setOwner
(
user
)
sub
.
setOwner
(
user
)
...
@@ -110,9 +107,7 @@ class SubscriptionUseCase @Inject constructor(
...
@@ -110,9 +107,7 @@ class SubscriptionUseCase @Inject constructor(
sub
.
setNumber
(
topic
.
topicId
)
sub
.
setNumber
(
topic
.
topicId
)
sub
.
setState
(
false
)
sub
.
setState
(
false
)
}
}
Timber
.
w
(
"sub is : $sub"
)
subscription
.
saveSubscribeState
(
sub
as
SubscriptionEntity
)
subscription
.
saveSubscribeState
(
sub
as
SubscriptionEntity
)
.
doOnNext
{
Timber
.
d
(
"zzz blocking $it"
)
}
.
blockingFirst
()
.
blockingFirst
()
}
}
.
map
(
::
fromEntity
)
.
map
(
::
fromEntity
)
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/deal/ScreenPresenter.kt
View file @
80becc0d
...
@@ -38,28 +38,29 @@ class DealScreenPresenter @Inject constructor(
...
@@ -38,28 +38,29 @@ class DealScreenPresenter @Inject constructor(
restoreStateObservable
.
accept
(
DealScreenViewState
.
RestoreView
(
restoreModel
))
restoreStateObservable
.
accept
(
DealScreenViewState
.
RestoreView
(
restoreModel
))
}
}
private
val
fetchDeal
=
interactor
.
getDeal
(
dealId
)
.
doOnNext
{
restoreModel
.
deal
=
it
}
.
map
<
DealScreenViewState
>{
deal
->
DealScreenViewState
.
LoadDeal
(
deal
,
interactor
.
getStatusListSync
())
}
override
fun
bindIntents
()
{
override
fun
bindIntents
()
{
val
fetchDeal
=
interactor
.
getDeal
(
dealId
)
.
doOnNext
{
restoreModel
.
deal
=
it
}
.
map
<
DealScreenViewState
>{
deal
->
DealScreenViewState
.
LoadDeal
(
deal
,
interactor
.
getStatusListSync
())
}.
share
()
val
setRead
=
interactor
.
setDealRead
(
dealId
)
val
setRead
=
interactor
.
setDealRead
(
dealId
)
.
andThen
(
Observable
.
just
(
DealScreenViewState
.
Idle
()))
.
andThen
(
Observable
.
just
(
DealScreenViewState
.
Idle
()))
val
onSubChecked
=
intent
(
DealScreen
::
onSubscription
)
val
onSubChecked
=
intent
(
DealScreen
::
onSubscription
)
.
filter
{
restoreModel
.
sub
!=
null
}
.
filter
{
restoreModel
.
sub
!=
null
}
.
flatMap
{
newState
->
.
flatMap
{
newState
->
interactor
.
switchSubscription
(
restoreModel
.
sub
!!
,
newState
)
interactor
.
switchSubscription
(
restoreModel
.
sub
!!
,
newState
)
.
map
{
subs
->
.
map
{
subs
->
Timber
.
d
(
"Got subs: $subs"
)
val
s
=
subs
.
map
{
it
.
subModel
}.
firstOrNull
{
it
.
id
==
restoreModel
.
sub
?.
id
}
val
s
=
subs
.
map
{
it
.
subModel
}.
firstOrNull
{
it
.
id
==
restoreModel
.
sub
?.
id
}
restoreModel
.
sub
=
s
restoreModel
.
sub
=
s
Timber
.
d
(
"Got s: $s"
)
if
(
s
!=
null
)
if
(
s
!=
null
)
return
@map
DealScreenViewState
.
SubscriptionStatus
(
s
.
state
)
return
@map
DealScreenViewState
.
SubscriptionStatus
(
s
.
state
)
else
else
...
@@ -74,17 +75,19 @@ class DealScreenPresenter @Inject constructor(
...
@@ -74,17 +75,19 @@ class DealScreenPresenter @Inject constructor(
interactor
.
getSubscriptions
(
interactor
.
getSubscriptions
(
(
fetchedDealViewState
as
DealScreenViewState
.
LoadDeal
).
estate
.
estate_id
(
fetchedDealViewState
as
DealScreenViewState
.
LoadDeal
).
estate
.
estate_id
)
)
.
do
After
Next
{
restoreModel
.
sub
=
it
}
.
do
On
Next
{
restoreModel
.
sub
=
it
}
.
map
<
DealScreenViewState
>
{
DealScreenViewState
.
SubscriptionStatus
(
it
.
state
)
}
.
map
<
DealScreenViewState
>
{
DealScreenViewState
.
SubscriptionStatus
(
it
.
state
)
}
.
startWith
(
Observable
.
just
<
DealScreenViewState
>(
DealScreenViewState
.
Idle
()))
.
startWith
(
Observable
.
just
<
DealScreenViewState
>(
DealScreenViewState
.
Idle
()))
}
}
.
onErrorReturn
(
::
parseError
)
val
onStartTours
=
intent
(
DealScreen
::
tourCardClicked
)
val
onStartTours
=
intent
(
DealScreen
::
tourCardClicked
)
.
map
{
restoreModel
.
deal
}
.
map
{
restoreModel
.
deal
}
.
map
{
it
.
estate
}
.
map
{
it
.
estate
}
.
flatMap
{
estate
->
toursInteractor
.
getEstateTourList
(
estate
)
.
flatMap
{
estate
->
toursInteractor
.
getEstateTourList
(
estate
)
.
map
{
DealScreenViewState
.
ToursLoaded
(
it
)
}
.
map
<
DealScreenViewState
>
{
DealScreenViewState
.
ToursLoaded
(
it
)
}
.
onErrorReturn
(
::
parseError
)
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/deals/ScreenPresenter.kt
View file @
80becc0d
...
@@ -53,6 +53,22 @@ class DealsScreenPresenter @Inject constructor(
...
@@ -53,6 +53,22 @@ class DealsScreenPresenter @Inject constructor(
.
onErrorReturn
(
::
parseError
)
.
onErrorReturn
(
::
parseError
)
val
getDeals
=
interactor
.
getDealsApi
()
.
flatMap
{
deals
->
getStatusList
.
map
{
List
(
deals
.
size
)
{
index
->
DealPreviewModel
(
Pair
(
deals
[
index
],
it
)
)
}
}
}
.
doOnNext
{
restoreModel
.
list
=
it
.
toMutableList
()
}
.
map
<
DealsScreenViewState
>(
DealsScreenViewState
::
DealsLoaded
)
.
onErrorReturn
(
::
parseError
)
val
onStartTours
=
intent
(
DealsScreen
::
tourCardClicked
)
val
onStartTours
=
intent
(
DealsScreen
::
tourCardClicked
)
.
flatMap
{
dealPreview
->
.
flatMap
{
dealPreview
->
toursInteractor
.
getEstateTourList
(
dealPreview
.
tourId
,
dealPreview
.
estateId
)
toursInteractor
.
getEstateTourList
(
dealPreview
.
tourId
,
dealPreview
.
estateId
)
...
@@ -63,6 +79,7 @@ class DealsScreenPresenter @Inject constructor(
...
@@ -63,6 +79,7 @@ class DealsScreenPresenter @Inject constructor(
arrayListOf
(
arrayListOf
(
restoreStateObservable
,
restoreStateObservable
,
fetchDeals
,
fetchDeals
,
getDeals
,
onStartTours
onStartTours
)
)
)
)
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/estate/ScreenPresenter.kt
View file @
80becc0d
...
@@ -37,6 +37,7 @@ class EstateScreenPresenter @Inject constructor(
...
@@ -37,6 +37,7 @@ class EstateScreenPresenter @Inject constructor(
private
fun
getPlan
(
plan
:
PlanPresetModel
):
Observable
<
EstateScreenViewState
>
=
private
fun
getPlan
(
plan
:
PlanPresetModel
):
Observable
<
EstateScreenViewState
>
=
interactor
.
getPlan
(
plan
)
interactor
.
getPlan
(
plan
)
.
map
<
EstateScreenViewState
>
{
EstateScreenViewState
.
LoadPlan
(
it
)
}
.
map
<
EstateScreenViewState
>
{
EstateScreenViewState
.
LoadPlan
(
it
)
}
.
onErrorReturn
(
::
parseError
)
private
var
restoreModel
=
RestoreModel
(
null
,
null
)
private
var
restoreModel
=
RestoreModel
(
null
,
null
)
...
@@ -50,11 +51,13 @@ class EstateScreenPresenter @Inject constructor(
...
@@ -50,11 +51,13 @@ class EstateScreenPresenter @Inject constructor(
val
prefetchCards
=
interactor
.
getEstate
(
estateId
)
val
prefetchCards
=
interactor
.
getEstate
(
estateId
)
.
doOnNext
{
restoreModel
.
estate
=
it
.
copy
()
}
.
doOnNext
{
restoreModel
.
estate
=
it
.
copy
()
}
.
map
{
EstateScreenViewState
.
LoadEstate
(
it
)
}
.
map
<
EstateScreenViewState
>
{
EstateScreenViewState
.
LoadEstate
(
it
)
}
.
onErrorReturn
(
::
parseError
)
val
fetchPlans
=
interactor
.
getPlanTypes
(
estateId
)
val
fetchPlans
=
interactor
.
getPlanTypes
(
estateId
)
.
doOnNext
{
restoreModel
.
planList
=
it
.
toList
()
}
.
doOnNext
{
restoreModel
.
planList
=
it
.
toList
()
}
.
map
{
EstateScreenViewState
.
LoadPlanTypes
(
it
)
}
.
map
<
EstateScreenViewState
>
{
EstateScreenViewState
.
LoadPlanTypes
(
it
)
}
.
onErrorReturn
(
::
parseError
)
val
fetchPlan
=
intent
(
EstateScreen
::
planTypesTabSelected
)
val
fetchPlan
=
intent
(
EstateScreen
::
planTypesTabSelected
)
.
map
{
restoreModel
.
planList
?.
get
(
it
)
}
.
map
{
restoreModel
.
planList
?.
get
(
it
)
}
...
@@ -77,6 +80,7 @@ class EstateScreenPresenter @Inject constructor(
...
@@ -77,6 +80,7 @@ class EstateScreenPresenter @Inject constructor(
)
)
)
)
)
)
.
onErrorReturn
(
::
parseError
)
}
}
val
switchSizes
=
intent
(
EstateScreen
::
switchSizes
)
val
switchSizes
=
intent
(
EstateScreen
::
switchSizes
)
...
...
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