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
692f8415
Commit
692f8415
authored
Apr 03, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tours merge info
parent
72ab65f7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
88 additions
and
2 deletions
+88
-2
IDb.kt
...ava/com/biganto/visual/roompark/data/repository/db/IDb.kt
+1
-0
RequeryRepository.kt
.../roompark/data/repository/db/requrey/RequeryRepository.kt
+9
-0
tours.kt
...va/com/biganto/visual/roompark/domain/interactor/tours.kt
+8
-1
toures.kt
...ava/com/biganto/visual/roompark/domain/use_case/toures.kt
+70
-1
No files found.
app/src/main/java/com/biganto/visual/roompark/data/repository/db/IDb.kt
View file @
692f8415
...
...
@@ -68,4 +68,5 @@ interface IDb {
fun
getFileEntitysOrDefault
(
uri
:
RevisionString
):
FileEntity
fun
getTourPreview
(
tourId
:
String
):
ReactiveResult
<
TourPreviewEntity
>
fun
getTourPreviewsObservableResult
(
estateId
:
Int
):
Observable
<
ReactiveResult
<
TourPreviewEntity
>>
fun
getEstateTourPreviews
(
estateId
:
Int
):
Observable
<
List
<
TourPreviewEntity
>>
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/data/repository/db/requrey/RequeryRepository.kt
View file @
692f8415
...
...
@@ -209,6 +209,15 @@ class RequeryRepository @Inject constructor(
.
where
(
TourPreviewEntity
.
ID
.
eq
(
tourId
))
.
get
()
override
fun
getEstateTourPreviews
(
estateId
:
Int
):
Observable
<
List
<
TourPreviewEntity
>>
=
store
.
select
(
TourPreviewEntity
::
class
)
.
where
(
TourPreviewEntity
.
ESTATE_ID
.
eq
(
estateId
))
.
get
()
.
observable
()
.
toList
()
.
toObservable
()
.
map
{
it
.
toList
()
}
override
fun
upsertTourPreview
(
list
:
List
<
TourPreviewEntity
>)
=
store
.
upsert
(
list
)
.
doOnSuccess
{
Timber
.
d
(
"Upsertd succses %s"
,
it
.
count
())
}
...
...
app/src/main/java/com/biganto/visual/roompark/domain/interactor/tours.kt
View file @
692f8415
package
com.biganto.visual.roompark.domain.interactor
import
com.biganto.visual.roompark.domain.model.EstateModel
import
com.biganto.visual.roompark.domain.use_case.DownloadUseCase
import
com.biganto.visual.roompark.domain.use_case.TourPreviewsUseCase
import
javax.inject.Inject
/**
...
...
@@ -8,9 +10,14 @@ import javax.inject.Inject
*/
class
ToursInteractor
@Inject
constructor
(
val
downloadUseCase
:
DownloadUseCase
val
downloadUseCase
:
DownloadUseCase
,
val
tourUseCase
:
TourPreviewsUseCase
){
fun
getEstateTourList
(
estate
:
EstateModel
){
tourUseCase
.
fetchTourOffer
(
estate
.
multitourId
?:
error
(
"Отсутсвуют виртуальные туры для данного объекта"
),
estate
.
id
)
}
...
...
app/src/main/java/com/biganto/visual/roompark/domain/use_case/toures.kt
View file @
692f8415
...
...
@@ -2,7 +2,9 @@ package com.biganto.visual.roompark.domain.use_case
import
android.content.res.Resources
import
com.biganto.visual.roompark.data.repository.api.biganto.IBigantoApi
import
com.biganto.visual.roompark.data.repository.api.biganto.raw.TourPreviewRaw
import
com.biganto.visual.roompark.data.repository.db.IDb
import
com.biganto.visual.roompark.domain.contract.AuthContract
import
com.biganto.visual.roompark.domain.custom_exception.CustomApiException
import
com.biganto.visual.roompark.domain.model.TourModel
import
com.biganto.visual.roompark.domain.model.fromEntity
...
...
@@ -23,6 +25,7 @@ const val EMPTY_PARENT = -778
class
TourPreviewsUseCase
@Inject
constructor
(
private
val
api
:
IBigantoApi
,
private
val
db
:
IDb
,
private
val
auth
:
AuthContract
)
{
fun
getTourById
(
tourId
:
String
):
Observable
<
DownloadTourByIdResult
>
{
...
...
@@ -90,9 +93,75 @@ class TourPreviewsUseCase @Inject constructor(
,
api
.
provideHttpUrl
().
toString
()
,
requestModel
.
targetResolution
)
}
private
fun
fetchDbTourList
(
estateId
:
Int
)
=
db
.
getEstateTourPreviews
(
estateId
)
private
fun
fetchApiTourList
(
multitourId
:
Int
,
estateId
:
Int
)
=
auth
.
currentUser
().
flatMap
{
user
->
api
.
getOfferTours
(
multitourId
)
.
map
{
mergeRaw
(
it
,
TourRemoteRequestModel
(
estateId
,
api
.
provideHttpUrl
().
toString
(),
user
.
targetResolution
)
)
}
.
map
{
it
}
.
doOnNext
{
db
.
blockingUpsert
(
it
)
}
}
fun
fetchTourOffer
(
multitourId
:
Int
,
parent
:
Int
)
=
Observable
.
mergeDelayError
(
arrayListOf
(
fetchDbTourList
(
parent
),
fetchApiTourList
(
multitourId
,
parent
))
)
.
map
{
it
}
.
map
(
::
fromEntity
)
private
fun
mergeRaw
(
raw
:
List
<
TourPreviewRaw
>,
requestRequestModel
:
TourRemoteRequestModel
)
=
raw
.
map
{
mergeRaw
(
it
,
requestRequestModel
)
}
private
fun
mergeRaw
(
raw
:
TourPreviewRaw
,
requestRequestModel
:
TourRemoteRequestModel
)
:
TourPreviewEntity
{
val
entity
=
db
.
getTourPreview
(
raw
.
id
.
toString
()).
firstOrNull
()
?:
return
fromRaw
(
raw
,
requestRequestModel
.
estateId
,
api
.
provideHttpUrl
().
toString
()
,
requestRequestModel
.
targetResolution
)
val
fromApi
=
fromRaw
(
raw
,
requestRequestModel
.
estateId
,
api
.
provideHttpUrl
().
toString
()
,
requestRequestModel
.
targetResolution
)
if
(
fromApi
.
updated
>
entity
.
updated
&&
entity
.
isDownloaded
==
DownloadState
.
Downloaded
)
{
entity
.
isDownloaded
=
DownloadState
.
NotSynced
//maxState(entity.isDownloaded, fromApi.isDownloaded)
return
entity
}
// In case< where we need to update tour parent, when it was downloaded by link
// if (fromApi.estate.id!=requestRequestModel.estateId)
// entity.estate=fromApi.estate
fromApi
.
setMetaFileEntityId
(
entity
.
metaFileEntityId
)
fromApi
.
targetResolution
=
entity
.
targetResolution
fromApi
.
isDownloaded
=
entity
.
isDownloaded
fromApi
.
overallSize
=
entity
.
overallSize
fromApi
.
downloadedSize
=
entity
.
downloadedSize
fromApi
.
tempSize
=
entity
.
tempSize
fromApi
.
overallFiles
=
entity
.
overallFiles
fromApi
.
downloadedFiles
=
entity
.
downloadedFiles
return
fromApi
}
}
data class
TourRemoteRequestModel
(
val
estateId
:
String
,
val
token
:
String
?
=
null
,
val
targetResolution
:
Int
)
data class
TourRemoteRequestModel
(
val
estateId
:
Int
,
val
token
:
String
?
=
null
,
val
targetResolution
:
Int
)
data class
ToursRemoteByIdRequestModel
(
val
ids
:
List
<
String
>,
val
estateId
:
Int
,
...
...
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