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
55e0a43e
Commit
55e0a43e
authored
Jan 10, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
promote getplan method
parent
4a6a88b7
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
100 additions
and
18 deletions
+100
-18
EstateRepository.kt
...to/visual/roompark/data/data_provider/EstateRepository.kt
+36
-6
FileModule.kt
...iganto/visual/roompark/data/repository/file/FileModule.kt
+5
-4
DealContract.kt
...m/biganto/visual/roompark/domain/contract/DealContract.kt
+10
-0
estate.kt
...a/com/biganto/visual/roompark/domain/interactor/estate.kt
+11
-0
deals.kt
...in/java/com/biganto/visual/roompark/domain/model/deals.kt
+8
-3
planType.kt
...java/com/biganto/visual/roompark/domain/model/planType.kt
+3
-1
estateUseCase.kt
.../biganto/visual/roompark/domain/use_case/estateUseCase.kt
+20
-3
ScreenPresenter.kt
...al/roompark/presentation/screen/estate/ScreenPresenter.kt
+7
-1
No files found.
app/src/main/java/com/biganto/visual/roompark/data/data_provider/EstateRepository.kt
View file @
55e0a43e
...
...
@@ -112,14 +112,25 @@ class EstateRepository @Inject constructor(
private
fun
getPlanApi
(
estateId
:
Int
,
planId
:
Int
,
furniture
:
Boolean
=
false
,
sizes
:
Boolean
=
false
,
walls
:
Boolean
=
false
,
electric
:
Boolean
=
false
)
=
api
.
getDirectPlan
(
estateId
,
planId
,
furniture
,
sizes
,
walls
,
electric
)
,
furniture
:
Boolean
?
=
null
,
sizes
:
Boolean
?
=
null
,
walls
:
Boolean
?
=
null
,
electric
:
Boolean
?
=
null
)
=
api
.
getDirectPlan
(
estateId
,
planId
,
furniture
?:
false
,
sizes
?:
false
,
walls
?:
false
,
electric
?:
false
)
.
map
{
val
sFile
=
FileModule
.
getDirectory
(
file
.
context
,
FileModule
.
FileDirectory
.
PlanTypeDir
(
childName
=
"planType-$estateId-$planId.html"
))
,
FileModule
.
FileDirectory
.
PlanTypeDir
(
estateId
=
estateId
,
planId
=
planId
,
furniture
=
furniture
,
walls
=
walls
,
sizes
=
sizes
,
electric
=
electric
))
file
.
saveFileToDisk
(
sFile
,
it
)
sFile
.
path
}
...
...
@@ -132,6 +143,25 @@ class EstateRepository @Inject constructor(
arrayListOf
(
getPlanApi
(
estateId
,
planId
))
)
override
fun
getPlan
(
estateId
:
Int
,
planId
:
Int
,
furniture
:
Boolean
?
,
sizes
:
Boolean
?
,
walls
:
Boolean
?
,
electric
:
Boolean
?):
Observable
<
String
>
=
Observable
.
mergeDelayError
(
arrayListOf
(
getPlanApi
(
estateId
,
planId
,
furniture
,
sizes
,
walls
,
electric
)
)
)
// fun getPlanRequestString(estateId: Int
// , planId:Int
// , furniture:Boolean
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/file/FileModule.kt
View file @
55e0a43e
...
...
@@ -85,10 +85,11 @@ class FileModule @Inject constructor(val context: Application) {
,
walls
:
Boolean
?
=
null
,
electric
:
Boolean
?
=
null
)
:
super
(
catalog
.
plus
(
"/plan"
).
plus
(
"/$estateId"
).
plus
(
"/$planId"
)
.
plus
(
"plan_${planId}_${furniture?:"
f
$
{
furniture
.
asInt
}
"}"
+
"_${sizes?:"
f
$
{
sizes
.
asInt
}
"}"
+
"_${walls?:"
f
$
{
walls
.
asInt
}
"}"
+
"_${electric?:"
f
$
{
electric
.
asInt
}
"}"
)
.
plus
(
"/plan${planId}"
+
"${sizes?.asInt?.toString()?.map { "
_s
$
it
" }?:""}"
+
"${furniture?.asInt?.toString()?.map { "
_f
$
it
" }?:""}"
+
"${walls?.asInt?.toString()?.map { "
_w
$
it
" }?:""}"
+
"${electric?.asInt?.toString()?.map { "
_e
$
it
" }?:""}"
)
.
plus
(
".html"
))
}
...
...
app/src/main/java/com/biganto/visual/roompark/domain/contract/DealContract.kt
View file @
55e0a43e
...
...
@@ -15,4 +15,14 @@ interface DealContract{
fun
getEstate
(
estateId
:
Int
):
Observable
<
EstateModel
>
fun
getPlanTypes
(
estateId
:
Int
):
Observable
<
List
<
PlanPresetModel
>>
fun
getEmptyPlan
(
estateId
:
Int
,
planId
:
Int
):
Observable
<
String
>
fun
getPlan
(
estateId
:
Int
,
planId
:
Int
,
furniture
:
Boolean
?
,
sizes
:
Boolean
?
,
walls
:
Boolean
?
,
electric
:
Boolean
?):
Observable
<
String
>
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/domain/interactor/estate.kt
View file @
55e0a43e
package
com.biganto.visual.roompark.domain.interactor
import
com.biganto.visual.roompark.domain.model.PlanPresetModel
import
com.biganto.visual.roompark.domain.use_case.EstateUseCase
import
javax.inject.Inject
...
...
@@ -18,4 +19,14 @@ class EstateInteractor @Inject constructor(
fun
getPlan
(
estateId
:
Int
,
planId
:
Int
)
=
useCase
.
getPlan
(
estateId
,
planId
)
fun
getPlan
(
plan
:
PlanPresetModel
)
=
useCase
.
getPlan
(
plan
.
estateId
,
plan
.
planId
,
furniture
=
plan
.
features
.
firstOrNull
{
it
.
featureName
==
"furniture"
}
?.
switchedOn
,
sizes
=
plan
.
features
.
firstOrNull
{
it
.
featureName
==
"sizes"
}
?.
switchedOn
,
walls
=
plan
.
features
.
firstOrNull
{
it
.
featureName
==
"walls"
}
?.
switchedOn
,
electric
=
plan
.
features
.
firstOrNull
{
it
.
featureName
==
"electric"
}
?.
switchedOn
)
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/domain/model/deals.kt
View file @
55e0a43e
...
...
@@ -8,6 +8,8 @@ import com.biganto.visual.roompark.data.repository.db.requrey.model.PlanPreset
* Created by Vladislav Bogdashkin on 23.09.2019.
*/
const
val
DEFAULT_WALLS_FEATURE_NAME
=
"walls"
data class
DealListModel
(
val
deals
:
List
<
DealListModel
>)
...
...
@@ -111,8 +113,11 @@ fun fromEntity(entity : PlanPreset) = PlanPresetModel(
planId
=
entity
.
planId
,
estateId
=
entity
.
estateId
.
id
,
title
=
entity
.
title
,
features
=
entity
.
features
.
toList
(),
explication
=
List
(
entity
.
explication
.
size
){
ExplicationModel
((
entity
.
explication
[
it
]
as
ExplicationEntity
))}
features
=
entity
.
features
.
asSequence
()
.
map
{
FeatureStatus
(
it
,
it
==
DEFAULT_WALLS_FEATURE_NAME
)
}.
toList
(),
//default true value for walls (otherwise plan may be empty)
explication
=
List
(
entity
.
explication
.
size
)
{
ExplicationModel
((
entity
.
explication
[
it
]
as
ExplicationEntity
))}
)
data class
PlanPresetModel
(
...
...
@@ -120,7 +125,7 @@ data class PlanPresetModel(
val
explication
:
List
<
ExplicationModel
>,
var
estateId
:
Int
,
val
title
:
String
,
val
features
:
List
<
String
>
val
features
:
List
<
FeatureStatus
>
)
data class
ExplicationModel
(
...
...
app/src/main/java/com/biganto/visual/roompark/domain/model/planType.kt
View file @
55e0a43e
...
...
@@ -16,3 +16,5 @@ data class FeatureStatus(
val
featureName
:
String
,
val
switchedOn
:
Boolean
)
app/src/main/java/com/biganto/visual/roompark/domain/use_case/estateUseCase.kt
View file @
55e0a43e
...
...
@@ -9,16 +9,33 @@ import javax.inject.Inject
class
EstateUseCase
@Inject
constructor
(
private
val
contract
:
DealContract
){
)
{
fun
fetchFavorites
()
=
contract
.
getFavorites
()
fun
getEstate
(
estateId
:
Int
)
=
contract
.
getEstate
(
estateId
)
fun
getEstate
(
estateId
:
Int
)
=
contract
.
getEstate
(
estateId
)
fun
getEstatePlanPresets
(
estateId
:
Int
)
=
contract
.
getPlanTypes
(
estateId
)
fun
getPlan
(
estateId
:
Int
,
planId
:
Int
)
=
contract
.
getEmptyPlan
(
estateId
,
planId
)
fun
getPlan
(
estateId
:
Int
,
planId
:
Int
)
=
contract
.
getEmptyPlan
(
estateId
,
planId
)
fun
getPlan
(
estateId
:
Int
,
planId
:
Int
,
furniture
:
Boolean
?
,
sizes
:
Boolean
?
,
walls
:
Boolean
?
,
electric
:
Boolean
?
)
=
contract
.
getPlan
(
estateId
,
planId
,
furniture
,
sizes
,
walls
,
electric
)
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/presentation/screen/estate/ScreenPresenter.kt
View file @
55e0a43e
...
...
@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.estate
import
com.biganto.visual.roompark.conductor.BigantoBasePresenter
import
com.biganto.visual.roompark.domain.interactor.EstateInteractor
import
com.biganto.visual.roompark.domain.model.PlanPresetModel
import
com.biganto.visual.roompark.util.monades.ExceptionString
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.schedulers.Schedulers
...
...
@@ -20,6 +21,8 @@ class EstateScreenPresenter @Inject constructor(
)
:
BigantoBasePresenter
<
EstateScreen
,
EstateScreenViewState
>()
{
private
var
planList
:
List
<
PlanPresetModel
>?
=
null
override
fun
defaultErrorViewStateHandler
()
=
{
e
:
ExceptionString
->
EstateScreenViewState
.
SomeError
(
e
)
}
...
...
@@ -30,10 +33,13 @@ class EstateScreenPresenter @Inject constructor(
//.map { EstateScreenViewState.FavoriteEstatesLoaded(it) }
val
fetchPlans
=
interactor
.
getPlanTypes
(
estateId
)
.
doOnNext
{
planList
=
it
.
toList
()
}
.
map
{
EstateScreenViewState
.
LoadPlanTypes
(
it
)
}
val
fetchPlan
=
intent
(
EstateScreen
::
planTypesTabSelected
)
.
flatMap
{
planId
->
interactor
.
getPlan
(
estateId
,
planId
)
}
.
map
{
plan
->
planList
?.
first
{
it
.
planId
==
plan
}
}
.
flatMap
{
interactor
.
getPlan
(
it
)
}
.
map
{
EstateScreenViewState
.
LoadPlan
(
it
)
}
val
state
=
restoreStateObservable
...
...
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