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
02226f64
Commit
02226f64
authored
Apr 20, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finish fetching sizes plan types
parent
cc82fe5f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
38 deletions
+23
-38
PlanRepository.kt
...anto/visual/roompark/data/data_provider/PlanRepository.kt
+15
-11
planTypesUseCase.kt
...ganto/visual/roompark/domain/use_case/planTypesUseCase.kt
+5
-24
ScreenController.kt
...roompark/presentation/screen/settings/ScreenController.kt
+2
-2
ScreenPresenter.kt
.../roompark/presentation/screen/settings/ScreenPresenter.kt
+1
-1
No files found.
app/src/main/java/com/biganto/visual/roompark/data/data_provider/PlanRepository.kt
View file @
02226f64
...
...
@@ -151,34 +151,38 @@ private fun BitSet.getOrNull(index:Int) =
if
(
index
<
0
||
index
>=
this
.
size
())
null
else
get
(
index
)
private
fun
Int
.
getBit
(
index
:
Int
):
Boolean
?
{
if
(
index
<
0
)
return
null
return
Integer
.
toBinaryString
(
shr
(
index
)).
last
()==
'1'
}
val
PlanPresetModel
.
featuresVariants
:
List
<
PlanFeaturesVariant
>
get
()
{
if
(
this
.
features
.
isNullOrEmpty
())
return
arrayListOf
()
val
maxInd
=
this
.
features
.
size
val
variants
=
BitSet
(
maxInd
).
apply
{
for
(
i
in
0
until
size
())
set
(
i
,
false
)
}
val
f
=
features
.
indexOfFirst
{
it
is
FeatureModel
.
Furniture
}
val
s
=
features
.
indexOfFirst
{
it
is
FeatureModel
.
Sizes
}
val
e
=
features
.
indexOfFirst
{
it
is
FeatureModel
.
Electric
}
val
w
=
features
.
indexOfFirst
{
it
is
FeatureModel
.
Walls
}
val
trueBit
=
BitSet
(
1
).
apply
{
set
(
0
,
true
)
}
var
firstRun
=
true
val
resList
=
mutableListOf
<
PlanFeaturesVariant
>()
var
increment
=
0
var
allTrue
:
Boolean
do
{
if
(
firstRun
)
firstRun
=
false
else
variants
.
and
(
trueBit
)
val
v
=
PlanFeaturesVariant
(
estateId
,
planId
,
furniture
=
variants
.
getOrNull
(
f
),
sizes
=
variants
.
getOrNull
(
s
),
electric
=
variants
.
getOrNull
(
e
),
walls
=
variants
.
getOrNull
(
w
)
furniture
=
increment
.
getBit
(
f
),
sizes
=
increment
.
getBit
(
s
),
electric
=
increment
.
getBit
(
e
),
walls
=
increment
.
getBit
(
w
)
)
allTrue
=
v
.
furniture
?:
true
&&
v
.
electric
?:
true
&&
v
.
sizes
?:
true
&&
v
.
walls
?:
true
resList
.
add
(
v
)
}
while
(
variants
.
cardinality
()
!=
variants
.
size
())
increment
++
}
while
(!
allTrue
)
return
resList
}
...
...
app/src/main/java/com/biganto/visual/roompark/domain/use_case/planTypesUseCase.kt
View file @
02226f64
...
...
@@ -4,9 +4,6 @@ import com.biganto.visual.roompark.data.data_provider.featuresVariants
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.FlatPlanContract
import
io.reactivex.BackpressureStrategy
import
io.reactivex.schedulers.Schedulers
import
timber.log.Timber
import
javax.inject.Inject
/**
...
...
@@ -28,26 +25,10 @@ class PlanTypesUseCase @Inject constructor(
list
}
.
flatMapIterable
{
it
}
.
toFlowable
(
BackpressureStrategy
.
BUFFER
)
.
parallel
(
4
)
.
runOn
(
Schedulers
.
io
())
.
flatMap
{
.
flatMap
{
planContract
.
getPlanTypes
(
it
.
id
)
.
map
{
plantypes
->
plantypes
.
flatMap
{
plan
->
plan
.
featuresVariants
}
}
.
toFlowable
(
BackpressureStrategy
.
BUFFER
)
.
map
{
plantypes
->
plantypes
.
flatMap
{
plan
->
plan
.
featuresVariants
}}
}
.
sequential
()
.
toList
()
.
toObservable
()
.
map
{
it
.
flatten
()
}
.
doOnNext
{
Timber
.
d
(
" plaanzz: $it"
)
}
.
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
}
}
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenController.kt
View file @
02226f64
...
...
@@ -136,11 +136,11 @@ class SettingsScreenController :
toursDownloaderTitle
.
text
=
resources
?.
getString
(
R
.
string
.
download_all_tours_settings_with_size
,
""
)
?.
getString
(
R
.
string
.
download_all_tours_settings_with_size
,
"
-
"
)
flatDownloaderTitle
.
text
=
resources
?.
getString
(
R
.
string
.
download_all_plan_types_settings_with_sizes
,
""
)
?.
getString
(
R
.
string
.
download_all_plan_types_settings_with_sizes
,
"
-
"
)
setToolbar
()
bindRecycler
()
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenPresenter.kt
View file @
02226f64
...
...
@@ -42,7 +42,7 @@ class SettingsScreenPresenter @Inject constructor(
.
map
{
SettingsScreenViewState
.
OnSizePrefetch
(
it
)
}
val
fetchPlansSize
=
interactor
.
fetchPlanTypesSizes
()
.
map
{
it
*
1024L
}
.
map
{
it
*
1024L
*
1024L
}
.
map
{
SettingsScreenViewState
.
OnPlanTypesPrefetch
(
it
)
}
val
onDownloadTours
=
intent
(
SettingsScreen
::
downloadAllTours
)
...
...
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