Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
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
3d63a790
Commit
3d63a790
authored
Apr 24, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
subscriptions token fix;
subscriptions new api model
parent
9b458a8a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
63 additions
and
33 deletions
+63
-33
StartToursDownloadingDialogController.kt
...ogs/tour_chooser/StartToursDownloadingDialogController.kt
+2
-11
EstateRepository.kt
...to/visual/roompark/data/data_provider/EstateRepository.kt
+2
-4
SubscriptionRepository.kt
...ual/roompark/data/data_provider/SubscriptionRepository.kt
+42
-16
RetrofitModule.kt
...oompark/data/repository/api/retrofit/di/RetrofitModule.kt
+1
-1
response.kt
...al/roompark/data/repository/api/room_park/raw/response.kt
+12
-1
IDb.kt
...ava/com/biganto/visual/roompark/data/repository/db/IDb.kt
+1
-0
RequeryRepository.kt
.../roompark/data/repository/db/requrey/RequeryRepository.kt
+3
-0
No files found.
app/src/main/java/com/biganto/visual/roompark/conductor/dialogs/tour_chooser/StartToursDownloadingDialogController.kt
View file @
3d63a790
...
...
@@ -100,19 +100,10 @@ class StartToursDownloadingDialogController : Controller {
view
.
findViewById
<
Button
>(
R
.
id
.
alert_ok_button
)
.
clicks
()
.
debounce
(
200
,
TimeUnit
.
MILLISECONDS
)
.
observeOn
(
Schedulers
.
io
())
.
flatMap
{
downloader
.
startToursDownloading
()
// .subscribeOn(Schedulers.computation())
.
doOnComplete
{
Timber
.
d
(
" C "
)
}
}
.
doOnComplete
{
Timber
.
d
(
" X "
)
}
// .subscribeOn(AndroidSchedulers.mainThread())
.
doOnComplete
{
Timber
.
d
(
" Xss "
)
}
.
observeOn
(
Schedulers
.
io
())
.
flatMap
{
downloader
.
startToursDownloading
()}
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
({
Timber
.
d
(
" SUBSCRIBER "
)
snackbar
.
showSnackBar
(
R
.
string
.
download_all_tours_start_snackbar_message
)
handleBack
()
},{
...
...
app/src/main/java/com/biganto/visual/roompark/data/data_provider/EstateRepository.kt
View file @
3d63a790
...
...
@@ -25,8 +25,6 @@ import javax.inject.Inject
*/
//
const
val
TEST_DEAL_TOKEN
=
"183|PQZi0LmaYswPmFHcLb0pHITkg_7aJNC4x2IIC90kbRKE1GBt2m48tdi-1jb9jo9MYoxCGyvJtDy3ret7_nAoAg=="
class
EstateRepository
@Inject
constructor
(
local
:
ILocalStore
,
...
...
@@ -53,7 +51,7 @@ class EstateRepository @Inject constructor(
.
doOnNext
{
db
.
refreshUser
(
user
)
}
override
fun
fetchDeals
(
user
:
UserEntity
):
Observable
<
List
<
EstateEntity
>>
=
api
.
getDeals
(
TEST_DEAL_TOKEN
)
//api.getDeals(user.authToken)
api
.
getDeals
(
user
.
authToken
)
//api.getDeals(user.authToken)
.
doOnError
(
Timber
::
e
)
.
map
{
List
(
it
.
size
){
index
->
fromRaw
(
it
[
index
],
user
)}
}
.
flatMap
(
db
::
upsertDeals
)
...
...
@@ -126,7 +124,7 @@ class EstateRepository @Inject constructor(
}
.
doOnError
(
Timber
::
e
)
.
flatMap
{
user
->
api
.
getDeals
(
TEST_DEAL_TOKEN
)
//api.getDeals(user.authToken)
api
.
getDeals
(
user
.
authToken
)
//api.getDeals(user.authToken)
.
doOnError
(
Timber
::
e
)
.
map
{
List
(
it
.
size
){
index
->
fromRaw
(
it
[
index
],
user
)}
}
.
doOnNext
(
db
::
blockingUpsert
)
...
...
app/src/main/java/com/biganto/visual/roompark/data/data_provider/SubscriptionRepository.kt
View file @
3d63a790
package
com.biganto.visual.roompark.data.data_provider
import
com.biganto.visual.roompark.data.repository.api.room_park.IRoomParkApi
import
com.biganto.visual.roompark.data.repository.api.room_park.raw.SubscriptionStatusRaw
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.UserEntity
...
...
@@ -37,23 +38,49 @@ class SubscriptionRepository @Inject constructor(
subInnerId
:
Int
?,
topic
:
String
,
topic_id
:
String
?,
n
u
ewState
:
Boolean
newState
:
Boolean
):
Observable
<
SubscriptionEntity
>
{
va
r
sub
=
subInnerId
?.
let
{
id
->
userEntity
.
subscriptions
?.
firstOrNull
{
sub
->
sub
.
id
==
id
}
}
Timber
.
d
(
"before nullch _subsc: $sub / ${sub?.id}"
)
if
(
sub
==
null
)
{
sub
=
SubscriptionEntity
()
sub
.
setOwner
(
userEntity
)
sub
.
setTopic
(
topic
)
sub
.
setNumber
(
topic_id
)
}
(
sub
as
SubscriptionEntity
).
setState
(
nuewState
)
Timber
.
d
(
"before save _subsc: $sub / ${sub?.id}"
)
va
l
userSubs
=
userEntity
.
subscriptions
val
sub
=
subInnerId
?.
let
{
id
->
userEntity
.
subscriptions
?.
firstOrNull
{
sub
->
sub
.
id
==
id
}
as
SubscriptionEntity
?
}
?:
SubscriptionEntity
()
.
apply
{
setOwner
(
userEntity
)
setTopic
(
topic
)
setNumber
(
topic_id
)
}
sub
.
setState
(
newState
)
return
db
.
saveSubscription
(
sub
)
}
fun
saveSubscribtions
(
userEntity
:
UserEntity
,
apiSubs
:
List
<
SubscriptionStatusRaw
>
):
Observable
<
SubscriptionEntity
>
{
val
userSubs
=
userEntity
.
subscriptions
val
newSubList
=
mutableListOf
<
SubscriptionEntity
>()
apiSubs
.
forEach
{
apiSub
->
val
cachedSub
=
userSubs
?.
firstOrNull
{
s
->
s
.
topic
==
apiSub
.
topic
&&
s
.
number
==
apiSub
.
estate_id
}
as
SubscriptionEntity
?
?:
SubscriptionEntity
()
.
apply
{
setOwner
(
userEntity
)
setTopic
(
apiSub
.
topic
)
setNumber
(
apiSub
.
estate_id
)
}
cachedSub
.
setState
(
apiSub
.
state
)
newSubList
.
add
(
cachedSub
)
}
userSubs
?.
let
{
db
.
deleteSubscriptions
(
it
)
}
return
db
.
upsert
(
newSubList
).
map
{
it
as
SubscriptionEntity
}.
toObservable
()
}
override
fun
subscribeTopic
(
user
:
UserEntity
,
subInnerId
:
Int
,
...
...
@@ -61,14 +88,13 @@ class SubscriptionRepository @Inject constructor(
topic
:
String
,
topic_id
:
String
?
):
Completable
=
api
.
subscribeTopic
(
userToken
=
if
(
topic_id
!=
null
)
TEST_DEAL_TOKEN
else
user
.
authToken
,
userToken
=
user
.
authToken
,
deviceToken
=
deviceToken
,
topicName
=
topic
,
topicId
=
topic_id
)
.
flatMapCompletable
{
if
(
it
.
status
==
SUBSCRIPTION_RESULT_STATUS
){
saveSubscribeState
(
user
,
subInnerId
,
topic
,
topic_id
,
true
)
.
doOnNext
{
Timber
.
d
(
"zzz $it"
)
}
.
ignoreElements
()
}
else
error
(
"Error subscription state!"
)
...
...
@@ -83,7 +109,7 @@ class SubscriptionRepository @Inject constructor(
topic_id
:
String
?
):
Completable
=
api
.
unSuubscribeTopic
(
userToken
=
if
(
topic_id
!=
null
)
TEST_DEAL_TOKEN
else
user
.
authToken
,
userToken
=
user
.
authToken
,
deviceToken
=
deviceToken
,
topicName
=
topic
,
topicId
=
topic_id
)
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/api/retrofit/di/RetrofitModule.kt
View file @
3d63a790
...
...
@@ -36,7 +36,7 @@ private const val TIMEOUT_SECONDS=120L
private
const
val
WRITE_SECONDS
=
120L
private
const
val
READ_SECONDS
=
120L
val
INTERCEPT_LOG_LEVEL
=
HttpLoggingInterceptor
.
Level
.
NONE
val
INTERCEPT_LOG_LEVEL
=
HttpLoggingInterceptor
.
Level
.
BODY
@Module
class
RetrofitModule
{
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/api/room_park/raw/response.kt
View file @
3d63a790
package
com.biganto.visual.roompark.data.repository.api.room_park.raw
import
com.google.gson.annotations.Expose
import
java.util.*
/**
...
...
@@ -13,7 +14,17 @@ data class AuthRaw(
val
name
:
String
)
data class
StatusResponse
(
val
status
:
String
)
data class
StatusResponse
(
val
status
:
String
,
val
subscriptions
:
List
<
SubscriptionStatusRaw
>?
)
data class
SubscriptionStatusRaw
(
val
topic
:
String
,
val
estate_id
:
String
,
@Expose
val
state
:
Boolean
=
true
)
data class
DealRaw
(
val
id
:
String
,
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/db/IDb.kt
View file @
3d63a790
...
...
@@ -77,4 +77,5 @@ interface IDb {
fun
refreshEstatesWithTours
():
Completable
fun
upsertEstates
(
entity
:
List
<
EstateEntity
>):
Observable
<
Iterable
<
EstateEntity
>>?
fun
upsertDeals
(
entity
:
List
<
DealEntity
>):
Observable
<
Iterable
<
DealEntity
>>
fun
deleteSubscriptions
(
entities
:
List
<
Subscription
>)
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/data/repository/db/requrey/RequeryRepository.kt
View file @
3d63a790
...
...
@@ -415,6 +415,9 @@ class RequeryRepository @Inject constructor(
override
fun
deleteTourPreview
(
entity
:
TourPreviewEntity
)
=
deleteBlocking
(
entity
)
override
fun
deleteSubscriptions
(
entities
:
List
<
Subscription
>)
=
deleteBlocking
(
entities
)
override
fun
deleteTourPreview
(
id
:
String
)
=
store
.
delete
(
TourPreview
::
class
)
...
...
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