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
dbed728c
Commit
dbed728c
authored
Jul 29, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update to unity master
parent
8bd9691c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
79 additions
and
20 deletions
+79
-20
RequeryRepository.kt
.../roompark/data/repository/db/requrey/RequeryRepository.kt
+2
-2
File.kt
.../visual/roompark/data/repository/db/requrey/model/File.kt
+10
-2
TourPreview.kt
.../roompark/data/repository/db/requrey/model/TourPreview.kt
+10
-2
FileModule.kt
...iganto/visual/roompark/data/repository/file/FileModule.kt
+1
-1
TourDownloadService.kt
...ual/roompark/data/service/download/TourDownloadService.kt
+1
-0
TourModel.kt
...ava/com/biganto/visual/roompark/domain/model/TourModel.kt
+7
-3
DownloadUseCase.kt
...iganto/visual/roompark/domain/use_case/DownloadUseCase.kt
+48
-10
No files found.
app/src/main/java/com/biganto/visual/roompark/data/repository/db/requrey/RequeryRepository.kt
View file @
dbed728c
...
...
@@ -30,7 +30,7 @@ import javax.inject.Inject
*/
private
const
val
DATABASE_VERSION
=
1
5
private
const
val
DATABASE_VERSION
=
1
6
@Module
class
DbModule
{
...
...
@@ -59,7 +59,7 @@ class RequeryRepository @Inject constructor(
override
fun
refreshEstatesWithTours
():
Completable
=
store
.
select
(
EstateEntity
::
class
)
.
where
(
EstateEntity
::
multitourId
.
notNull
())
.
where
(
EstateEntity
.
MULTITOUR_ID
.
notNull
())
.
get
()
.
observable
()
.
toList
()
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/db/requrey/model/File.kt
View file @
dbed728c
...
...
@@ -8,13 +8,21 @@ import com.biganto.visual.roompark.data.repository.db.requrey.utils.RevisionStri
import
com.biganto.visual.roompark.data.repository.file.FileModule
import
io.requery.*
import
java.io.File
import
java.math.BigInteger
import
java.security.MessageDigest
/**
* Created by Vladislav Bogdashkin on 15.06.2018.
*/
val
domainPredicthMatcher
=
"^(http|https)://"
.
toRegex
()
fun
toInitialName
(
fullPath
:
String
)
=
fullPath
.
hashCode
().
toString
()
fun
toInitialName
(
fullPath
:
String
)
=
String
.
format
(
"%032x"
,
BigInteger
(
1
,
MessageDigest
.
getInstance
(
"MD5"
).
digest
(
fullPath
.
toByteArray
(
Charsets
.
UTF_8
))
)
)
@Entity
interface
File
:
Persistable
{
...
...
@@ -59,7 +67,7 @@ fun fromRaw(raw: TourFileRaw, meta: LiteTourMetaRaw):FileEntity {
entity
.
setDestination
(
if
(
domainPredicthMatcher
.
containsMatchIn
(
raw
.
url
))
raw
.
url
else
BASE_URL
+
raw
.
url
else
BASE_URL
.
plus
(
raw
.
url
)
)
return
entity
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/db/requrey/model/TourPreview.kt
View file @
dbed728c
...
...
@@ -4,6 +4,7 @@ import com.biganto.visual.roompark.data.repository.api.biganto.raw.TourPreviewRa
import
com.biganto.visual.roompark.data.repository.db.requrey.RevisionString
import
com.biganto.visual.roompark.data.repository.db.requrey.model.Estate
import
com.biganto.visual.roompark.data.repository.db.requrey.model.EstateEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.domainPredicthMatcher
import
com.biganto.visual.roompark.data.repository.db.requrey.utils.IntListConverter
import
com.biganto.visual.roompark.data.repository.db.requrey.utils.IsoDateConverter
import
com.biganto.visual.roompark.data.repository.db.requrey.utils.RevisionStringConverter
...
...
@@ -72,8 +73,15 @@ fun fromRaw(raw: TourPreviewRaw, parentId:Int, baseUrl:String, userResolution:In
tour
.
setUpdated
(
raw
.
updated
)
tour
.
setType
(
raw
.
type
)
tour
.
setTitle
(
raw
.
title
)
tour
.
setPreview
(
"$baseUrl${raw.preview}"
)
tour
.
setScreen
(
"$baseUrl${raw.screen}"
)
tour
.
setPreview
(
if
(
domainPredicthMatcher
.
containsMatchIn
(
raw
.
preview
))
raw
.
preview
else
"$baseUrl${raw.preview}"
)
tour
.
setScreen
(
if
(
domainPredicthMatcher
.
containsMatchIn
(
raw
.
screen
))
raw
.
screen
else
"$baseUrl${raw.screen}"
)
tour
.
setHidden
(
raw
.
hidden
)
tour
.
resolutions
=
if
(
raw
.
resolutions
!=
null
&&
!
raw
.
resolutions
.
isNullOrEmpty
())
ArrayList
(
raw
.
resolutions
)
else
ArrayList
(
1024
)
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/file/FileModule.kt
View file @
dbed728c
...
...
@@ -41,7 +41,7 @@ class FileModule @Inject constructor(val context: Application) {
if
(
fileUri
.
contains
(
"/"
))
fileUri
.
substring
(
0
,
fileUri
.
lastIndexOf
(
"/"
))
else
""
val
directory
=
File
(
assetsFile
(
context
)
,
fileDir
)
val
directory
=
File
(
rootFolder
,
fileDir
)
directory
.
mkdirs
()
val
file
=
File
(
directory
,
fileName
)
...
...
app/src/main/java/com/biganto/visual/roompark/data/service/download/TourDownloadService.kt
View file @
dbed728c
...
...
@@ -592,6 +592,7 @@ class DownloadManagerService @Inject constructor(
Timber
.
e
(
e
)
}
}
tour
}
.
flatMap
{
db
.
upsertTourPreview
(
it
)
}
.
map
{
tour
.
id
}
...
...
app/src/main/java/com/biganto/visual/roompark/domain/model/TourModel.kt
View file @
dbed728c
...
...
@@ -27,7 +27,8 @@ data class TourModel (
var
downloadState
:
DownloadState
=
DownloadState
.
MetaPreparation
,
val
downloadedSize
:
Long
=-
1L
,
val
totalTourSize
:
Long
=-
1L
,
val
targetResolution
:
Int
val
targetResolution
:
Int
,
val
footageUri
:
String
?
)
:
Parcelable
{
constructor
(
parcel
:
Parcel
)
:
this
(
...
...
@@ -44,7 +45,8 @@ data class TourModel (
DownloadState
.
valueOf
(
parcel
.
readString
()),
parcel
.
readLong
(),
parcel
.
readLong
(),
parcel
.
readInt
())
parcel
.
readInt
(),
parcel
.
readString
())
val
metaPredict
:
String
get
()
=
metaUri
?.
removeSuffix
(
"$tour_id.json"
)
?:
""
...
...
@@ -64,6 +66,7 @@ data class TourModel (
parcel
.
writeLong
(
downloadedSize
)
parcel
.
writeLong
(
totalTourSize
)
parcel
.
writeInt
(
targetResolution
)
parcel
.
writeString
(
footageUri
)
}
override
fun
describeContents
():
Int
{
...
...
@@ -140,7 +143,8 @@ fun fromEntity(entity: TourPreviewEntity) = TourModel(
downloadState
=
entity
.
isDownloaded
,
//calcDownloadState(entity.tour as TourEntity?)
downloadedSize
=
entity
.
downloadedSize
?:
-
1L
,
totalTourSize
=
max
(
entity
.
overallSize
?:
0L
,
entity
.
tempSize
?:
0L
),
targetResolution
=
entity
.
targetResolution
targetResolution
=
entity
.
targetResolution
,
footageUri
=
entity
.
footageBaseUrl
)
fun
fromEntity
(
raw
:
List
<
TourPreviewEntity
>):
List
<
TourModel
>
=
List
(
raw
.
size
)
{
index
->
fromEntity
(
raw
[
index
])}
...
...
app/src/main/java/com/biganto/visual/roompark/domain/use_case/DownloadUseCase.kt
View file @
dbed728c
...
...
@@ -4,16 +4,20 @@ package com.biganto.visual.roompark.domain.use_case
import
android.app.Application
import
android.media.MediaScannerConnection
import
com.biganto.visual.roompark.data.repository.api.biganto.IBigantoApi
import
com.biganto.visual.roompark.data.repository.api.biganto.raw.LiteTourMetaRaw
import
com.biganto.visual.roompark.data.repository.db.IDb
import
com.biganto.visual.roompark.data.repository.db.requrey.RevisionString
import
com.biganto.visual.roompark.data.repository.db.requrey.model.FileEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.TourFileJunctionEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.fromRaw
import
com.biganto.visual.roompark.data.repository.db.requrey.model.toInitialName
import
com.biganto.visual.roompark.data.repository.file.FileModule
import
com.biganto.visual.roompark.data.service.download.TourFileData
import
com.biganto.visual.roompark.domain.contract.AuthContract
import
com.biganto.visual.roomparkvr.data.repository.db.requery.model.DownloadState
import
com.biganto.visual.roomparkvr.data.repository.db.requery.model.TourPreviewEntity
import
com.google.gson.Gson
import
com.google.gson.JsonParser
import
io.reactivex.BackpressureStrategy
import
io.reactivex.Flowable
import
io.reactivex.Observable
...
...
@@ -155,7 +159,9 @@ class DownloadUseCase @Inject constructor(
.
map
{
raw
->
var
downloadedSize
=
0L
var
totalSize
=
0L
val
fileEntities
=
raw
.
files
.
map
(
::
fromRaw
)
val
meta
=
getLocalMeta
(
tour
)
val
fileEntities
=
fromRaw
(
raw
.
files
,
meta
)
mergeFiles
(
fileEntities
)
val
jlist
=
db
.
getTourFilesJunction
(
tour
.
id
).
toList
()
...
...
@@ -205,7 +211,7 @@ class DownloadUseCase @Inject constructor(
hashMapOf
(
Pair
(
"Range"
,
"bytes=${model.fileDownloadedSize}-"
))
else
null
api
.
downloadFile
(
model
.
fileUrl
.
revisionUri
()
,
header
)
api
.
downloadFile
(
model
.
destination
,
header
)
.
flatMap
<
TourFileData
>
{
writeFile
(
it
,
model
,
token
)
.
toFlowable
(
BackpressureStrategy
.
BUFFER
)
...
...
@@ -255,26 +261,58 @@ class DownloadUseCase @Inject constructor(
.
doOnError
(
Timber
::
e
)
.
flatMap
{
observableTourDownloading
(
it
,
cancellataionToken
)
}
private
fun
getMeta
(
tour
:
TourPreviewEntity
)
=
api
.
getTourMetaAsString
(
tour
.
id
)
.
map
{
meta
->
tour
.
apply
{
val
metaUri
=
RevisionString
(
"$META_PREDICTION${tour.id}$META_FILE_TYPE"
)
setMetaFileEntityId
(
metaUri
)
fileModule
.
saveFileToDisk
(
File
(
FileModule
.
assetsDirectory
(
context
).
plus
(
metaUri
.
uri
()))
,
meta
)
try
{
val
jMeta
=
JsonParser
().
parse
(
meta
).
asJsonArray
.
first
()
val
metaLite
=
Gson
().
fromJson
(
jMeta
,
LiteTourMetaRaw
::
class
.
java
)
val
metaUri
=
RevisionString
(
"${META_PREDICTION}${tour.id}${META_FILE_TYPE}"
)
setMetaFileEntityId
(
metaUri
)
setFootageBaseUrl
(
toInitialName
(
metaLite
.
baseurl
))
setTourBaseUrl
(
toInitialName
(
metaLite
.
tour_baseurl
))
fileModule
.
saveFileToDisk
(
fileModule
.
getAssetFile
(
File
.
separator
.
plus
(
tour
.
footageBaseUrl
)
.
plus
(
metaUri
.
uri
())
)
,
meta
)
}
catch
(
e
:
Exception
)
{
Timber
.
e
(
e
)
}
}
tour
}
.
flatMap
{
db
.
upsertTourPreview
(
it
)
}
.
onErrorReturn
{
tour
.
isDownloaded
=
DownloadState
.
Crushed
db
.
upsertTourPreview
(
tour
).
blockingSubscribe
()
tour
}
private
fun
getLocalMeta
(
tour
:
TourPreviewEntity
):
LiteTourMetaRaw
{
return
Gson
().
fromJson
(
JsonParser
().
parse
(
fileModule
.
getAssetFile
(
File
.
separator
.
plus
(
tour
.
footageBaseUrl
)
.
plus
(
File
.
separator
)
.
plus
(
tour
.
metaFileEntityId
?.
uri
())
).
readText
()
).
asJsonArray
.
first
()
,
LiteTourMetaRaw
::
class
.
java
)
}
//#endregion oldMethod
private
fun
refreshGallery
(
file
:
File
)
{
...
...
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