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
d094f0e3
Commit
d094f0e3
authored
Apr 21, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix files save flow
parent
99cecf5f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
7 deletions
+36
-7
PlanRepository.kt
...anto/visual/roompark/data/data_provider/PlanRepository.kt
+3
-3
FileModule.kt
...iganto/visual/roompark/data/repository/file/FileModule.kt
+26
-0
planTypesUseCase.kt
...ganto/visual/roompark/domain/use_case/planTypesUseCase.kt
+7
-4
No files found.
app/src/main/java/com/biganto/visual/roompark/data/data_provider/PlanRepository.kt
View file @
d094f0e3
...
@@ -64,7 +64,7 @@ class PlanRepository @Inject constructor(
...
@@ -64,7 +64,7 @@ class PlanRepository @Inject constructor(
,
sizes
?:
false
,
sizes
?:
false
,
walls
?:
false
,
walls
?:
false
,
electric
?:
false
)
,
electric
?:
false
)
.
m
ap
{
.
flatM
ap
{
val
sFile
=
getPlanFile
(
val
sFile
=
getPlanFile
(
estateId
=
estateId
,
estateId
=
estateId
,
planId
=
planId
,
planId
=
planId
,
...
@@ -72,8 +72,8 @@ class PlanRepository @Inject constructor(
...
@@ -72,8 +72,8 @@ class PlanRepository @Inject constructor(
walls
=
walls
,
walls
=
walls
,
sizes
=
sizes
,
sizes
=
sizes
,
electric
=
electric
)
electric
=
electric
)
file
.
saveFileToDisk
(
sFile
,
it
)
file
.
saveFileToDisk
Observable
(
sFile
,
it
)
sFile
.
path
.
map
{
sFile
.
path
}
}
}
.
subscribeOn
(
Schedulers
.
io
())
.
subscribeOn
(
Schedulers
.
io
())
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/file/FileModule.kt
View file @
d094f0e3
...
@@ -8,6 +8,7 @@ import com.google.gson.JsonElement
...
@@ -8,6 +8,7 @@ import com.google.gson.JsonElement
import
dagger.Module
import
dagger.Module
import
io.reactivex.Observable
import
io.reactivex.Observable
import
kotlinx.io.IOException
import
kotlinx.io.IOException
import
okio.Okio
import
timber.log.Timber
import
timber.log.Timber
import
java.io.File
import
java.io.File
import
javax.inject.Inject
import
javax.inject.Inject
...
@@ -58,6 +59,31 @@ class FileModule @Inject constructor(val context: Application) {
...
@@ -58,6 +59,31 @@ class FileModule @Inject constructor(val context: Application) {
file
.
writeText
(
"[$jsonElement]"
)
//to json array because core unity method parse data like TourData[] Estate[] etc..
file
.
writeText
(
"[$jsonElement]"
)
//to json array because core unity method parse data like TourData[] Estate[] etc..
}
}
fun
saveFileToDiskObservable
(
file
:
File
,
content
:
String
):
Observable
<
Long
>
{
file
.
parentFile
.
mkdirs
()
return
Observable
.
create
{
emitter
->
val
fileStorage
=
file
val
sink
=
Okio
.
buffer
(
Okio
.
sink
(
fileStorage
))
val
buffer
=
sink
.
buffer
()
var
read
=
0L
val
step
=
8192
val
source
=
content
.
byteInputStream
()
var
bytesRead
=
0L
sink
.
use
{
while
(
source
.
read
()>
0
)
{
bytesRead
+=
read
}
}
emitter
.
onNext
(
bytesRead
)
emitter
.
onComplete
()
}
}
fun
saveFileToDisk
(
file
:
File
,
content
:
String
){
fun
saveFileToDisk
(
file
:
File
,
content
:
String
){
Timber
.
d
(
"write to : $file"
)
Timber
.
d
(
"write to : $file"
)
// file.createNewFile()
// file.createNewFile()
...
...
app/src/main/java/com/biganto/visual/roompark/domain/use_case/planTypesUseCase.kt
View file @
d094f0e3
...
@@ -7,6 +7,7 @@ import com.biganto.visual.roompark.domain.contract.AuthContract
...
@@ -7,6 +7,7 @@ import com.biganto.visual.roompark.domain.contract.AuthContract
import
com.biganto.visual.roompark.domain.contract.FlatPlanContract
import
com.biganto.visual.roompark.domain.contract.FlatPlanContract
import
io.reactivex.Observable
import
io.reactivex.Observable
import
io.reactivex.schedulers.Schedulers
import
io.reactivex.schedulers.Schedulers
import
timber.log.Timber
import
javax.inject.Inject
import
javax.inject.Inject
/**
/**
...
@@ -59,16 +60,18 @@ class PlanTypesUseCase @Inject constructor(
...
@@ -59,16 +60,18 @@ class PlanTypesUseCase @Inject constructor(
,
cancellationToken
:
DownloadUseCase
.
CancellationToken
,
cancellationToken
:
DownloadUseCase
.
CancellationToken
)
)
:
Observable
<
DownloadProgress
>
{
:
Observable
<
DownloadProgress
>
{
var
completedThreads
=
0
return
Observable
.
fromIterable
(
list
)
return
Observable
.
fromIterable
(
list
)
.
filter
{
!
cancellationToken
.
isCancelled
}
.
filter
{
!
cancellationToken
.
isCancelled
}
.
flatMap
{
.
flatMap
{
planContract
.
getPlan
(
it
)
planContract
.
getPlan
(
it
)
.
map
{
1
}
.
subscribeOn
(
Schedulers
.
io
())
.
subscribeOn
(
Schedulers
.
io
())
.
map
{
.
observeOn
(
Schedulers
.
computation
())
completedThreads
++
.
scan
{
t1
:
Int
,
t2
:
Int
->
t1
+
t2
}
DownloadProgress
(
completedThreads
,
list
.
size
)
.
map
{
completed
->
Timber
.
d
(
"downaloadods ${completed}/${list.size}"
)
DownloadProgress
(
completed
,
list
.
size
)
}
}
}
}
}
}
...
...
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