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
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(
...
@@ -112,14 +112,25 @@ class EstateRepository @Inject constructor(
private
fun
getPlanApi
(
estateId
:
Int
private
fun
getPlanApi
(
estateId
:
Int
,
planId
:
Int
,
planId
:
Int
,
furniture
:
Boolean
=
false
,
furniture
:
Boolean
?
=
null
,
sizes
:
Boolean
=
false
,
sizes
:
Boolean
?
=
null
,
walls
:
Boolean
=
false
,
walls
:
Boolean
?
=
null
,
electric
:
Boolean
=
false
)
=
,
electric
:
Boolean
?
=
null
)
=
api
.
getDirectPlan
(
estateId
,
planId
,
furniture
,
sizes
,
walls
,
electric
)
api
.
getDirectPlan
(
estateId
,
planId
,
furniture
?:
false
,
sizes
?:
false
,
walls
?:
false
,
electric
?:
false
)
.
map
{
.
map
{
val
sFile
=
FileModule
.
getDirectory
(
file
.
context
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
)
file
.
saveFileToDisk
(
sFile
,
it
)
sFile
.
path
sFile
.
path
}
}
...
@@ -132,6 +143,25 @@ class EstateRepository @Inject constructor(
...
@@ -132,6 +143,25 @@ class EstateRepository @Inject constructor(
arrayListOf
(
getPlanApi
(
estateId
,
planId
))
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
// fun getPlanRequestString(estateId: Int
// , planId:Int
// , planId:Int
// , furniture:Boolean
// , 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) {
...
@@ -85,10 +85,11 @@ class FileModule @Inject constructor(val context: Application) {
,
walls
:
Boolean
?
=
null
,
walls
:
Boolean
?
=
null
,
electric
:
Boolean
?
=
null
,
electric
:
Boolean
?
=
null
)
:
super
(
catalog
.
plus
(
"/plan"
).
plus
(
"/$estateId"
).
plus
(
"/$planId"
)
)
:
super
(
catalog
.
plus
(
"/plan"
).
plus
(
"/$estateId"
).
plus
(
"/$planId"
)
.
plus
(
"plan_${planId}_${furniture?:"
f
$
{
furniture
.
asInt
}
"}"
+
.
plus
(
"/plan${planId}"
+
"_${sizes?:"
f
$
{
sizes
.
asInt
}
"}"
+
"${sizes?.asInt?.toString()?.map { "
_s
$
it
" }?:""}"
+
"_${walls?:"
f
$
{
walls
.
asInt
}
"}"
+
"${furniture?.asInt?.toString()?.map { "
_f
$
it
" }?:""}"
+
"_${electric?:"
f
$
{
electric
.
asInt
}
"}"
)
"${walls?.asInt?.toString()?.map { "
_w
$
it
" }?:""}"
+
"${electric?.asInt?.toString()?.map { "
_e
$
it
" }?:""}"
)
.
plus
(
".html"
))
.
plus
(
".html"
))
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/domain/contract/DealContract.kt
View file @
55e0a43e
...
@@ -15,4 +15,14 @@ interface DealContract{
...
@@ -15,4 +15,14 @@ interface DealContract{
fun
getEstate
(
estateId
:
Int
):
Observable
<
EstateModel
>
fun
getEstate
(
estateId
:
Int
):
Observable
<
EstateModel
>
fun
getPlanTypes
(
estateId
:
Int
):
Observable
<
List
<
PlanPresetModel
>>
fun
getPlanTypes
(
estateId
:
Int
):
Observable
<
List
<
PlanPresetModel
>>
fun
getEmptyPlan
(
estateId
:
Int
,
planId
:
Int
):
Observable
<
String
>
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
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
com.biganto.visual.roompark.domain.use_case.EstateUseCase
import
javax.inject.Inject
import
javax.inject.Inject
...
@@ -18,4 +19,14 @@ class EstateInteractor @Inject constructor(
...
@@ -18,4 +19,14 @@ class EstateInteractor @Inject constructor(
fun
getPlan
(
estateId
:
Int
,
planId
:
Int
)
=
useCase
.
getPlan
(
estateId
,
planId
)
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
...
@@ -8,6 +8,8 @@ import com.biganto.visual.roompark.data.repository.db.requrey.model.PlanPreset
* Created by Vladislav Bogdashkin on 23.09.2019.
* Created by Vladislav Bogdashkin on 23.09.2019.
*/
*/
const
val
DEFAULT_WALLS_FEATURE_NAME
=
"walls"
data class
DealListModel
(
val
deals
:
List
<
DealListModel
>)
data class
DealListModel
(
val
deals
:
List
<
DealListModel
>)
...
@@ -111,8 +113,11 @@ fun fromEntity(entity : PlanPreset) = PlanPresetModel(
...
@@ -111,8 +113,11 @@ fun fromEntity(entity : PlanPreset) = PlanPresetModel(
planId
=
entity
.
planId
,
planId
=
entity
.
planId
,
estateId
=
entity
.
estateId
.
id
,
estateId
=
entity
.
estateId
.
id
,
title
=
entity
.
title
,
title
=
entity
.
title
,
features
=
entity
.
features
.
toList
(),
features
=
entity
.
features
.
asSequence
()
explication
=
List
(
entity
.
explication
.
size
){
ExplicationModel
((
entity
.
explication
[
it
]
as
ExplicationEntity
))}
.
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
(
data class
PlanPresetModel
(
...
@@ -120,7 +125,7 @@ data class PlanPresetModel(
...
@@ -120,7 +125,7 @@ data class PlanPresetModel(
val
explication
:
List
<
ExplicationModel
>,
val
explication
:
List
<
ExplicationModel
>,
var
estateId
:
Int
,
var
estateId
:
Int
,
val
title
:
String
,
val
title
:
String
,
val
features
:
List
<
String
>
val
features
:
List
<
FeatureStatus
>
)
)
data class
ExplicationModel
(
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(
...
@@ -16,3 +16,5 @@ data class FeatureStatus(
val
featureName
:
String
,
val
featureName
:
String
,
val
switchedOn
:
Boolean
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
...
@@ -9,16 +9,33 @@ import javax.inject.Inject
class
EstateUseCase
@Inject
constructor
(
class
EstateUseCase
@Inject
constructor
(
private
val
contract
:
DealContract
private
val
contract
:
DealContract
){
)
{
fun
fetchFavorites
()
=
contract
.
getFavorites
()
fun
fetchFavorites
()
=
contract
.
getFavorites
()
fun
getEstate
(
estateId
:
Int
)
=
contract
.
getEstate
(
estateId
)
fun
getEstate
(
estateId
:
Int
)
=
contract
.
getEstate
(
estateId
)
fun
getEstatePlanPresets
(
estateId
:
Int
)
=
fun
getEstatePlanPresets
(
estateId
:
Int
)
=
contract
.
getPlanTypes
(
estateId
)
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
...
@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.estate
import
com.biganto.visual.roompark.conductor.BigantoBasePresenter
import
com.biganto.visual.roompark.conductor.BigantoBasePresenter
import
com.biganto.visual.roompark.domain.interactor.EstateInteractor
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
com.biganto.visual.roompark.util.monades.ExceptionString
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.schedulers.Schedulers
import
io.reactivex.schedulers.Schedulers
...
@@ -20,6 +21,8 @@ class EstateScreenPresenter @Inject constructor(
...
@@ -20,6 +21,8 @@ class EstateScreenPresenter @Inject constructor(
)
)
:
BigantoBasePresenter
<
EstateScreen
,
EstateScreenViewState
>()
{
:
BigantoBasePresenter
<
EstateScreen
,
EstateScreenViewState
>()
{
private
var
planList
:
List
<
PlanPresetModel
>?
=
null
override
fun
defaultErrorViewStateHandler
()
=
override
fun
defaultErrorViewStateHandler
()
=
{
e
:
ExceptionString
->
EstateScreenViewState
.
SomeError
(
e
)
}
{
e
:
ExceptionString
->
EstateScreenViewState
.
SomeError
(
e
)
}
...
@@ -30,10 +33,13 @@ class EstateScreenPresenter @Inject constructor(
...
@@ -30,10 +33,13 @@ class EstateScreenPresenter @Inject constructor(
//.map { EstateScreenViewState.FavoriteEstatesLoaded(it) }
//.map { EstateScreenViewState.FavoriteEstatesLoaded(it) }
val
fetchPlans
=
interactor
.
getPlanTypes
(
estateId
)
val
fetchPlans
=
interactor
.
getPlanTypes
(
estateId
)
.
doOnNext
{
planList
=
it
.
toList
()
}
.
map
{
EstateScreenViewState
.
LoadPlanTypes
(
it
)
}
.
map
{
EstateScreenViewState
.
LoadPlanTypes
(
it
)
}
val
fetchPlan
=
intent
(
EstateScreen
::
planTypesTabSelected
)
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
)
}
.
map
{
EstateScreenViewState
.
LoadPlan
(
it
)
}
val
state
=
restoreStateObservable
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