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
ba6db1a2
Commit
ba6db1a2
authored
Apr 28, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix subscriptions
parent
e8b55308
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
27 deletions
+21
-27
EstateRepository.kt
...to/visual/roompark/data/data_provider/EstateRepository.kt
+1
-1
SubscriptionRepository.kt
...ual/roompark/data/data_provider/SubscriptionRepository.kt
+14
-4
response.kt
...al/roompark/data/repository/api/room_park/raw/response.kt
+1
-1
deal.kt
...ava/com/biganto/visual/roompark/domain/interactor/deal.kt
+1
-2
ScreenPresenter.kt
...sual/roompark/presentation/screen/deal/ScreenPresenter.kt
+2
-0
ScreenPresenter.kt
.../roompark/presentation/screen/settings/ScreenPresenter.kt
+2
-19
No files found.
app/src/main/java/com/biganto/visual/roompark/data/data_provider/EstateRepository.kt
View file @
ba6db1a2
...
...
@@ -44,7 +44,7 @@ class EstateRepository @Inject constructor(
.
doOnError
(
Timber
::
e
)
.
map
{
fromRawList
(
it
,
::
fromRaw
)
}
,
db
.
getUserFavorites
(
user
.
uuid
)
.
defaultIfEmpty
(
null
).
toList
().
toObservable
()
.
toList
().
toObservable
()
.
doOnError
(
Timber
::
e
)
){
apiList
,
dbList
->
if
(
dbList
.
isEmpty
())
...
...
app/src/main/java/com/biganto/visual/roompark/data/data_provider/SubscriptionRepository.kt
View file @
ba6db1a2
...
...
@@ -66,8 +66,12 @@ class SubscriptionRepository @Inject constructor(
val
newSubList
=
mutableListOf
<
SubscriptionEntity
>()
apiSubs
.
forEach
{
apiSub
->
Timber
.
d
(
"api sub state: ${apiSub.active}"
)
val
cachedSub
=
userSubs
?.
firstOrNull
{
s
->
s
.
topic
==
apiSub
.
topic
&&
s
.
number
==
apiSub
.
estate_id
}
userSubs
?.
firstOrNull
{
s
->
Timber
.
w
(
"hehe ${s.topic} == ${apiSub.topic} && ${s.number} == ${apiSub.estate_id}"
)
s
.
topic
==
apiSub
.
topic
&&
s
.
number
==
apiSub
.
estate_id
}
as
SubscriptionEntity
?
?:
SubscriptionEntity
()
.
apply
{
...
...
@@ -75,10 +79,16 @@ class SubscriptionRepository @Inject constructor(
setTopic
(
apiSub
.
topic
)
setNumber
(
apiSub
.
estate_id
)
}
cachedSub
.
setState
(
apiSub
.
stat
e
)
cachedSub
.
setState
(
apiSub
.
activ
e
)
newSubList
.
add
(
cachedSub
)
}
userSubs
?.
let
{
db
.
deleteSubscriptions
(
it
)
}
userSubs
?.
filter
{
!
newSubList
.
map
{
s
->
s
.
id
}.
contains
(
it
.
id
)
}
?.
toList
()
?.
let
{
Timber
.
w
(
"to delete; ${it.size}"
)
db
.
deleteSubscriptions
(
it
)
}
Timber
.
w
(
"to newSubList; ${newSubList}"
)
return
db
.
upsert
(
newSubList
)
.
map
{
list
->
list
.
map
{
fromEntity
(
...
...
@@ -101,7 +111,7 @@ class SubscriptionRepository @Inject constructor(
,
topicName
=
topic
,
topicId
=
topic_id
)
.
flatMap
{
saveSubscribtions
(
user
,
it
.
subscriptions
?:
arrayListOf
())
}
.
doOnNext
{
db
.
refreshUser
(
user
)
}
.
doOnNext
{
db
.
refreshUser
(
user
)
.
blockingFirst
()
}
override
fun
unSubscribeTopicResult
(
user
:
UserEntity
,
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/api/room_park/raw/response.kt
View file @
ba6db1a2
...
...
@@ -23,7 +23,7 @@ data class SubscriptionStatusRaw(
val
topic
:
String
,
val
estate_id
:
String
,
@Expose
val
stat
e
:
Boolean
=
true
val
activ
e
:
Boolean
=
true
)
data class
DealRaw
(
...
...
app/src/main/java/com/biganto/visual/roompark/domain/interactor/deal.kt
View file @
ba6db1a2
...
...
@@ -6,7 +6,6 @@ import com.biganto.visual.roompark.domain.model.SubscriptionModel
import
com.biganto.visual.roompark.domain.model.SubscriptionTopic
import
com.biganto.visual.roompark.domain.use_case.DealseUseCase
import
com.biganto.visual.roompark.domain.use_case.SubscriptionUseCase
import
io.reactivex.Completable
import
io.reactivex.Observable
import
timber.log.Timber
import
javax.inject.Inject
...
...
@@ -101,4 +100,4 @@ class DealInteractor @Inject constructor(
)
)
}
}
\ No newline at end of file
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/presentation/screen/deal/ScreenPresenter.kt
View file @
ba6db1a2
...
...
@@ -56,8 +56,10 @@ class DealScreenPresenter @Inject constructor(
.
flatMap
{
newState
->
interactor
.
switchSubscription
(
restoreModel
.
sub
!!
,
newState
)
.
map
{
subs
->
Timber
.
d
(
"Got subs: $subs"
)
val
s
=
subs
.
map
{
it
.
subModel
}.
firstOrNull
{
it
.
id
==
restoreModel
.
sub
?.
id
}
restoreModel
.
sub
=
s
Timber
.
d
(
"Got s: $s"
)
if
(
s
!=
null
)
return
@map
DealScreenViewState
.
SubscriptionStatus
(
s
.
state
)
else
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenPresenter.kt
View file @
ba6db1a2
...
...
@@ -4,7 +4,6 @@ import com.biganto.visual.roompark.base.BaseRoomParkActivity
import
com.biganto.visual.roompark.conductor.BigantoBasePresenter
import
com.biganto.visual.roompark.domain.interactor.SettingsInteractor
import
com.biganto.visual.roompark.domain.model.CachedDataModel
import
com.biganto.visual.roompark.domain.model.SubscriptionModel
import
com.biganto.visual.roompark.domain.model.TitledSubscriptionModel
import
com.biganto.visual.roompark.util.monades.ExceptionString
import
com.jakewharton.rxrelay2.PublishRelay
...
...
@@ -68,24 +67,8 @@ class SettingsScreenPresenter @Inject constructor(
.
flatMap
{
sub
->
interactor
.
switchSubscription
(
sub
,
!
sub
.
state
)
.
map
<
SettingsScreenViewState
>
{
restoreModel
.
subs
=
it
.
toMutableList
()
SettingsScreenViewState
.
SubscriptionStatus
(
sub
.
id
,
!
sub
.
state
)
}
.
doOnNext
{
val
ind
=
restoreModel
.
subs
.
indexOfFirst
{
it
.
subModel
.
id
==
sub
.
id
}
restoreModel
.
subs
[
ind
]
=
TitledSubscriptionModel
(
title
=
restoreModel
.
subs
[
ind
].
title
,
subModel
=
SubscriptionModel
(
topic
=
sub
.
topic
,
id
=
restoreModel
.
subs
[
ind
].
subModel
.
id
,
state
=
!
sub
.
state
)
)
restoreModel
.
subs
=
it
.
sortedBy
{
it
.
subModel
.
id
}.
toMutableList
()
SettingsScreenViewState
.
LoadSubscriptions
(
it
)
}
.
doOnError
{
Timber
.
e
(
it
)
}
.
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