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
633d6223
Commit
633d6223
authored
Apr 17, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring, remove logs
parent
5ee2709b
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
108 additions
and
117 deletions
+108
-117
RetrofitModule.kt
...oompark/data/repository/api/retrofit/di/RetrofitModule.kt
+1
-1
FileModule.kt
...iganto/visual/roompark/data/repository/file/FileModule.kt
+0
-1
TourDownloadService.kt
...ual/roompark/data/service/download/TourDownloadService.kt
+13
-8
DownloadUseCase.kt
...iganto/visual/roompark/domain/use_case/DownloadUseCase.kt
+2
-2
toures.kt
...ava/com/biganto/visual/roompark/domain/use_case/toures.kt
+92
-100
ScreenController.kt
...roompark/presentation/screen/settings/ScreenController.kt
+0
-5
No files found.
app/src/main/java/com/biganto/visual/roompark/data/repository/api/retrofit/di/RetrofitModule.kt
View file @
633d6223
...
...
@@ -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
.
HEADERS
val
INTERCEPT_LOG_LEVEL
=
HttpLoggingInterceptor
.
Level
.
NONE
@Module
class
RetrofitModule
{
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/file/FileModule.kt
View file @
633d6223
...
...
@@ -60,7 +60,6 @@ class FileModule @Inject constructor(val context: Application) {
fun
saveFileToDisk
(
file
:
File
,
content
:
String
){
Timber
.
d
(
"write to : $file"
)
Timber
.
d
(
"write to : ${file.name}"
)
// file.createNewFile()
file
.
parentFile
.
mkdirs
()
file
.
writeText
(
content
)
//to json array because core unity method parse data like TourData[] Estate[] etc..
...
...
app/src/main/java/com/biganto/visual/roompark/data/service/download/TourDownloadService.kt
View file @
633d6223
...
...
@@ -175,7 +175,7 @@ class DownloadManagerService @Inject constructor(
val
sink
=
Okio
.
buffer
(
Okio
.
appendingSink
(
fileStorage
))
val
buffer
=
sink
.
buffer
()
var
read
=
0L
val
step
=
4096
val
step
=
8192
val
source
=
response
.
source
()
var
timer
=
System
.
currentTimeMillis
()
var
stop
:
Boolean
=
false
...
...
@@ -194,7 +194,6 @@ class DownloadManagerService @Inject constructor(
}
}
model
.
isDownloaded
=
(
source
.
exhausted
()
&&
(
model
.
fileDownloadedSize
==
model
.
tempOverallFileSize
||
model
.
tempOverallFileSize
==
0L
))
...
...
@@ -268,9 +267,10 @@ class DownloadManagerService @Inject constructor(
mergeFiles
(
fileEntities
)
val
jlist
=
db
.
getTourFilesJunction
(
tour
.
id
).
toList
()
Timber
.
d
(
"jlist:: ${jlist?.size} start ${jlist?.firstOrNull()?.id}"
)
val
junctionList
=
fileEntities
.
map
{
file
->
val
entity
=
jlist
.
firstOrNull
{
it
.
tour
==
tour
.
id
&&
it
.
file
==
file
.
uri
}
val
entity
=
jlist
.
firstOrNull
{
it
.
tour
==
tour
.
id
&&
it
.
file
.
uri
()
==
file
.
uri
.
uri
()
}
?:
TourFileJunctionEntity
().
apply
{
setTour
(
tour
.
id
)
setFile
(
file
.
uri
)
...
...
@@ -279,8 +279,8 @@ class DownloadManagerService @Inject constructor(
totalSize
+=
file
.
totalSize
entity
}
Timber
.
w
(
"fffff $downloadedSize $totalSize"
)
Timber
.
d
(
"junctionList:: ${junctionList.size} start ${junctionList.first().id}"
)
setDownloadInfo
(
raw
.
id
.
toString
()
,
tempLoadedFiles
=
0
...
...
@@ -337,7 +337,6 @@ class DownloadManagerService @Inject constructor(
.
observeOn
(
Schedulers
.
computation
())
// .doOnNext{Timber.d("7 ${it}")}
.
flatMap
{
model
->
Timber
.
d
(
" model __ ${model}"
)
setDownloadInfo
(
model
.
tourId
,
totalSizedDiffSize
=
model
.
tempTourTotalDiff
...
...
@@ -377,10 +376,13 @@ class DownloadManagerService @Inject constructor(
private
fun
downloadTourFromQueue
():
Observable
<
String
>
=
Observable
.
fromCallable
{
activeDownloading
.
set
(
true
);
downloadQueue
.
poll
()
}
.
doOnNext
{
Timber
.
d
(
"to load tour: ${it}"
)
}
.
flatMap
{
db
.
getTourPreview
(
it
).
observable
()
}
.
filter
{
Timber
.
d
(
"to load tour: ${it.isDownloaded} ${it.id}"
)
val
forward
=
it
.
isDownloaded
!=
DownloadState
.
Downloaded
activeDownloading
.
set
(
forward
)
Timber
.
d
(
"to load tour: $forward"
)
if
(!
forward
)
notifyDownloadProgress
()
forward
...
...
@@ -519,6 +521,7 @@ class DownloadManagerService @Inject constructor(
disposable
.
add
(
toursToDownloadObserver
.
flatMap
{
db
.
getTourPreview
(
it
).
observable
()
}
.
filter
{
it
.
isDownloaded
!=
DownloadState
.
Downloaded
}
.
doOnNext
{
it
.
isDownloaded
=
DownloadState
.
Downloading
it
.
downloadedFiles
=
0
...
...
@@ -531,18 +534,20 @@ class DownloadManagerService @Inject constructor(
.
subscribeOn
(
Schedulers
.
io
())
.
doOnError
(
Timber
::
e
)
.
subscribe
{
downloadQueue
.
add
(
it
)
}
)
}
private
fun
getMeta
(
tour
:
TourPreviewEntity
):
Observable
<
String
>
=
api
.
getTourMetaAsString
(
tour
.
id
)
.
doOnNext
{
meta
->
tour
.
let
{
.
map
{
meta
->
tour
.
apply
{
val
metaUri
=
RevisionString
(
"$META_PREDICTION${tour.id}$META_FILE_TYPE"
)
it
.
setMetaFileEntityId
(
metaUri
)
setMetaFileEntityId
(
metaUri
)
fileModule
.
saveFileToDisk
(
fileModule
.
getFile
(
metaUri
.
uri
()),
meta
)
}
}
.
flatMap
{
db
.
upsertTourPreview
(
it
)
}
.
map
{
tour
.
id
}
.
onErrorReturn
{
setTourStatus
(
tour
.
id
,
DownloadState
.
Crushed
)
...
...
app/src/main/java/com/biganto/visual/roompark/domain/use_case/DownloadUseCase.kt
View file @
633d6223
...
...
@@ -63,7 +63,7 @@ class DownloadUseCase @Inject constructor(
else
Okio
.
buffer
(
Okio
.
sink
(
fileStorage
))
val
buffer
=
sink
.
buffer
()
var
read
=
0L
val
step
=
4096
val
step
=
8192
val
source
=
response
.
source
()
var
stop
:
Boolean
=
token
.
isCancelled
sink
.
use
{
...
...
@@ -161,7 +161,7 @@ class DownloadUseCase @Inject constructor(
val
jlist
=
db
.
getTourFilesJunction
(
tour
.
id
).
toList
()
val
junctionList
=
fileEntities
.
map
{
file
->
val
entity
=
jlist
.
firstOrNull
{
it
.
tour
==
tour
.
id
&&
it
.
file
==
file
.
uri
}
val
entity
=
jlist
.
firstOrNull
{
it
.
tour
==
tour
.
id
&&
it
.
file
.
uri
()
==
file
.
uri
.
uri
()
}
?:
TourFileJunctionEntity
()
entity
.
setTour
(
tour
.
id
)
entity
.
setFile
(
file
.
uri
)
...
...
app/src/main/java/com/biganto/visual/roompark/domain/use_case/toures.kt
View file @
633d6223
This diff is collapsed.
Click to expand it.
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenController.kt
View file @
633d6223
...
...
@@ -208,11 +208,6 @@ class SettingsScreenController :
@SuppressLint
(
"SetTextI18n"
)
private
fun
render
(
viewState
:
SettingsScreenViewState
.
LoadSettingsList
){
toursDownloaderTitle
.
text
=
viewState
.
settings
.
offlineStoreData
[
0
].
title
+
"(${viewState.settings.offlineStoreData[0].amountBytes.bytesToSize()})"
flatDownloaderTitle
.
text
=
viewState
.
settings
.
offlineStoreData
[
1
].
title
+
"(${viewState.settings.offlineStoreData[1].amountBytes.bytesToSize()})"
}
private
fun
getComponent
()
=
DaggerSettingsScreenComponent
.
factory
()
...
...
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