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
53a5764f
Commit
53a5764f
authored
Apr 20, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bits variants calc
parent
9e455842
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
3 deletions
+33
-3
PlanRepository.kt
...anto/visual/roompark/data/data_provider/PlanRepository.kt
+33
-3
No files found.
app/src/main/java/com/biganto/visual/roompark/data/data_provider/PlanRepository.kt
View file @
53a5764f
...
...
@@ -9,11 +9,13 @@ import com.biganto.visual.roompark.data.repository.file.FileModule
import
com.biganto.visual.roompark.data.repository.mapper.fromRaw
import
com.biganto.visual.roompark.data.repository.mapper.fromRawList
import
com.biganto.visual.roompark.domain.contract.FlatPlanContract
import
com.biganto.visual.roompark.domain.model.FeatureModel
import
com.biganto.visual.roompark.domain.model.PlanPresetModel
import
com.biganto.visual.roompark.domain.model.fromEntity
import
io.reactivex.Observable
import
io.reactivex.schedulers.Schedulers
import
timber.log.Timber
import
java.util.*
import
javax.inject.Inject
/**
...
...
@@ -144,13 +146,41 @@ class PlanRepository @Inject constructor(
}
private
fun
BitSet
.
getOrNull
(
index
:
Int
)
=
if
(
index
<
0
||
index
>=
this
.
size
())
null
else
get
(
index
)
val
PlanPresetModel
.
featuresVariants
:
List
<
PlanFeaturesVariant
>
get
()
{
if
(
this
.
features
.
isNullOrEmpty
())
return
arrayListOf
()
val
variants
=
this
.
features
.
size
return
arrayListOf
()
}
//List9 PlanFeaturesVariant()
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
>()
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
)
)
resList
.
add
(
v
)
}
while
(
variants
.
cardinality
()
!=
variants
.
size
())
return
resList
}
data class
PlanFeaturesVariant
(
val
estateId
:
Int
,
...
...
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