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
1b342e91
Commit
1b342e91
authored
Apr 20, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix flow flatamapiterable;
complete plan types download
parent
6d527311
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
36 deletions
+30
-36
DownloadPlansDialogController.kt
...ompark/conductor/dialogs/DownloadPlansDialogController.kt
+9
-15
planTypesUseCase.kt
...ganto/visual/roompark/domain/use_case/planTypesUseCase.kt
+21
-21
No files found.
app/src/main/java/com/biganto/visual/roompark/conductor/dialogs/DownloadPlansDialogController.kt
View file @
1b342e91
...
@@ -8,7 +8,6 @@ import android.view.ViewGroup
...
@@ -8,7 +8,6 @@ import android.view.ViewGroup
import
android.widget.ImageView
import
android.widget.ImageView
import
android.widget.ProgressBar
import
android.widget.ProgressBar
import
androidx.annotation.LayoutRes
import
androidx.annotation.LayoutRes
import
androidx.core.os.bundleOf
import
com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.base.BaseRoomParkActivity
import
com.biganto.visual.roompark.base.BaseRoomParkActivity
import
com.biganto.visual.roompark.base.RoomParkApplication
import
com.biganto.visual.roompark.base.RoomParkApplication
...
@@ -17,12 +16,8 @@ import com.biganto.visual.roompark.di.dagger.ActivityModule
...
@@ -17,12 +16,8 @@ import com.biganto.visual.roompark.di.dagger.ActivityModule
import
com.biganto.visual.roompark.di.dagger.AppComponent
import
com.biganto.visual.roompark.di.dagger.AppComponent
import
com.biganto.visual.roompark.di.dagger.PerScreen
import
com.biganto.visual.roompark.di.dagger.PerScreen
import
com.biganto.visual.roompark.domain.interactor.SettingsInteractor
import
com.biganto.visual.roompark.domain.interactor.SettingsInteractor
import
com.biganto.visual.roompark.domain.interactor.ToursInteractor
import
com.biganto.visual.roompark.domain.model.TourModel
import
com.biganto.visual.roompark.domain.model.fromEntity
import
com.biganto.visual.roompark.domain.use_case.DownloadUseCase
import
com.biganto.visual.roompark.domain.use_case.DownloadUseCase
import
com.biganto.visual.roompark.util.view_utils.snackbar.ISnackBarProvider
import
com.biganto.visual.roompark.util.view_utils.snackbar.ISnackBarProvider
import
com.biganto.visual.roomparkvr.data.repository.db.requery.model.TourPreviewEntity
import
com.bluelinelabs.conductor.Controller
import
com.bluelinelabs.conductor.Controller
import
com.bumptech.glide.Glide
import
com.bumptech.glide.Glide
import
com.google.android.material.textview.MaterialTextView
import
com.google.android.material.textview.MaterialTextView
...
@@ -60,7 +55,7 @@ class DownloadPlansDialogController : Controller {
...
@@ -60,7 +55,7 @@ class DownloadPlansDialogController : Controller {
override
fun
onContextAvailable
(
context
:
Context
)
{
override
fun
onContextAvailable
(
context
:
Context
)
{
super
.
onContextAvailable
(
context
)
super
.
onContextAvailable
(
context
)
PlansDownloaderScreenComponent
.
factory
()
Dagger
PlansDownloaderScreenComponent
.
factory
()
.
create
(
RoomParkApplication
.
component
,
activity
as
RoomParkMainActivity
)
.
create
(
RoomParkApplication
.
component
,
activity
as
RoomParkMainActivity
)
.
inject
(
this
)
.
inject
(
this
)
}
}
...
@@ -100,7 +95,8 @@ class DownloadPlansDialogController : Controller {
...
@@ -100,7 +95,8 @@ class DownloadPlansDialogController : Controller {
Glide
.
with
(
view
)
Glide
.
with
(
view
)
.
load
(
R
.
drawable
.
ic_plan
)
.
load
(
R
.
drawable
.
ic_plan
)
.
transform
(
BlurTransformation
(
13
,
8
)
.
fitCenter
()
.
transform
(
BlurTransformation
(
25
,
12
)
,
ColorFilterTransformation
(
0
x99000000
.
toInt
()))
,
ColorFilterTransformation
(
0
x99000000
.
toInt
()))
.
into
(
downloaderBg
)
.
into
(
downloaderBg
)
...
@@ -113,9 +109,11 @@ class DownloadPlansDialogController : Controller {
...
@@ -113,9 +109,11 @@ class DownloadPlansDialogController : Controller {
{
model
->
{
model
->
downloadTourTitleText
.
text
=
"${model.currentProgress}/${model.totalProgress}"
downloadTourTitleText
.
text
=
"${model.currentProgress}/${model.totalProgress}"
updateProgressBar
(
model
.
currentProgress
,
model
.
totalProgress
)
updateProgressBar
(
model
.
currentProgress
,
model
.
totalProgress
)
if
(
model
.
currentProgress
==
model
.
totalProgress
){
snackbar
.
showSnackBar
(
R
.
string
.
plan_types_download_completed
)
snackbar
.
showSnackBar
(
R
.
string
.
plan_types_download_completed
)
handleBack
()
handleBack
()
}
}
}
,{
error
->
,{
error
->
Timber
.
e
(
error
)
Timber
.
e
(
error
)
snackbar
.
showSnackBar
(
error
.
localizedMessage
)
snackbar
.
showSnackBar
(
error
.
localizedMessage
)
...
@@ -153,7 +151,7 @@ class DownloadPlansDialogController : Controller {
...
@@ -153,7 +151,7 @@ class DownloadPlansDialogController : Controller {
@PerScreen
@PerScreen
@Component
(
@Component
(
modules
=
[
DownloaderScreenModule
::
class
],
modules
=
[
Plans
DownloaderScreenModule
::
class
],
dependencies
=
[
AppComponent
::
class
])
dependencies
=
[
AppComponent
::
class
])
interface
PlansDownloaderScreenComponent
{
interface
PlansDownloaderScreenComponent
{
...
@@ -171,11 +169,7 @@ interface PlansDownloaderScreenComponent {
...
@@ -171,11 +169,7 @@ interface PlansDownloaderScreenComponent {
}
}
@Module
@Module
abstract
class
DownloaderScreenModule
{
abstract
class
PlansDownloaderScreenModule
{
@PerScreen
@Binds
abstract
fun
provideContext
(
activity
:
RoomParkMainActivity
):
Context
@PerScreen
@PerScreen
@Binds
@Binds
...
...
app/src/main/java/com/biganto/visual/roompark/domain/use_case/planTypesUseCase.kt
View file @
1b342e91
...
@@ -6,7 +6,6 @@ import com.biganto.visual.roompark.data.repository.db.requrey.model.EstateEntity
...
@@ -6,7 +6,6 @@ import com.biganto.visual.roompark.data.repository.db.requrey.model.EstateEntity
import
com.biganto.visual.roompark.domain.contract.AuthContract
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.rxkotlin.subscribeBy
import
io.reactivex.schedulers.Schedulers
import
io.reactivex.schedulers.Schedulers
import
javax.inject.Inject
import
javax.inject.Inject
...
@@ -28,49 +27,50 @@ class PlanTypesUseCase @Inject constructor(
...
@@ -28,49 +27,50 @@ class PlanTypesUseCase @Inject constructor(
list
.
addAll
(
user
.
estates
?.
map
{
it
as
EstateEntity
}
?:
arrayListOf
())
list
.
addAll
(
user
.
estates
?.
map
{
it
as
EstateEntity
}
?:
arrayListOf
())
list
list
}
}
fun
fetchNotDownloadedPlansSizes
():
Observable
<
Int
>
=
fetchAllPlanTypes
.
flatMapIterable
{
it
}
.
flatMapIterable
{
it
}
.
flatMap
{
.
flatMap
{
planContract
.
getPlanTypes
(
it
.
id
)
planContract
.
getPlanTypes
(
it
.
id
)
.
map
{
plantypes
->
plantypes
.
flatMap
{
plan
->
plan
.
featuresVariants
}
}
.
map
{
plantypes
->
plantypes
.
flatMap
{
plan
->
plan
.
featuresVariants
}
}
}
}
fun
fetchNotDownloadedPlansSizes
():
Observable
<
Int
>
=
fetchAllPlanTypes
.
map
{
list
->
list
.
sumBy
{
if
(
planContract
.
getPlanFile
(
it
).
exists
())
0
else
1
}
}
.
map
{
list
->
list
.
sumBy
{
if
(
planContract
.
getPlanFile
(
it
).
exists
())
0
else
1
}
}
.
scan
{
t1
:
Int
,
t2
:
Int
->
t1
+
t2
}
.
scan
{
t1
:
Int
,
t2
:
Int
->
t1
+
t2
}
fun
downloadAllPlanTypes
(
cancellationToken
:
DownloadUseCase
.
CancellationToken
)
=
fun
downloadAllPlanTypes
(
cancellationToken
:
DownloadUseCase
.
CancellationToken
)
=
fetchAllPlanTypes
fetchAllPlanTypes
.
flatMapSingle
{
Observable
.
fromIterable
(
it
)
.
flatMap
{
estateEntity
->
planContract
.
getPlanTypes
(
estateEntity
.
id
)
.
map
{
plantypes
->
plantypes
.
flatMap
{
plan
->
plan
.
featuresVariants
}
}
}
.
toList
()
}
.
map
{
it
.
flatten
()
}
.
filter
{
!
cancellationToken
.
isCancelled
}
.
filter
{
!
cancellationToken
.
isCancelled
}
.
flatMap
{
downloadPlan
(
it
,
cancellationToken
)
}
.
flatMap
{
downloadPlan
(
it
,
cancellationToken
)
}
fun
downloadPlan
(
private
fun
downloadPlan
(
list
:
List
<
PlanFeaturesVariant
>
list
:
List
<
PlanFeaturesVariant
>
,
cancellationToken
:
DownloadUseCase
.
CancellationToken
,
cancellationToken
:
DownloadUseCase
.
CancellationToken
)
)
:
Observable
<
DownloadProgress
>
{
:
Observable
<
DownloadProgress
>
{
var
runThreads
=
list
.
size
var
completedThreads
=
0
var
completedThreads
=
0
return
Observable
.
create
<
DownloadProgress
>
{
emitter
->
list
.
forEach
{
return
Observable
.
fromIterable
(
list
)
planContract
.
getPlan
(
it
)
.
filter
{
!
cancellationToken
.
isCancelled
}
.
filter
{
!
cancellationToken
.
isCancelled
}
.
flatMap
{
planContract
.
getPlan
(
it
)
.
subscribeOn
(
Schedulers
.
io
())
.
subscribeOn
(
Schedulers
.
io
())
.
map
{
1
}
.
map
{
.
scan
{
t1
:
Int
,
t2
:
Int
->
t1
.
plus
(
t2
)
}
.
subscribe
{
emitter
.
onNext
(
DownloadProgress
(
it
,
list
.
size
))
completedThreads
++
completedThreads
++
DownloadProgress
(
completedThreads
,
list
.
size
)
}
}
}
}
while
(
completedThreads
<
runThreads
&&
cancellationToken
.
isCancelled
.
not
())
Thread
.
sleep
(
100
)
if
(
cancellationToken
.
isCancelled
)
emitter
.
onError
(
Throwable
(
"Cacnelled by user"
))
emitter
.
onComplete
()
}.
subscribeOn
(
Schedulers
.
computation
())
}
}
}
}
...
...
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