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
99cecf5f
Commit
99cecf5f
authored
Apr 21, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
estate resotre model
parent
817a65ce
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
88 additions
and
60 deletions
+88
-60
TourChooserDialogController.kt
...uctor/dialogs/tour_chooser/TourChooserDialogController.kt
+1
-1
ScreenController.kt
...l/roompark/presentation/screen/estate/ScreenController.kt
+47
-32
ScreenPresenter.kt
...al/roompark/presentation/screen/estate/ScreenPresenter.kt
+30
-22
ScreenViewState.kt
...al/roompark/presentation/screen/estate/ScreenViewState.kt
+1
-0
download_tour_layout.xml
app/src/main/res/layout-v23/download_tour_layout.xml
+5
-1
tours_chooser_screen.xml
app/src/main/res/layout/tours_chooser_screen.xml
+4
-4
No files found.
app/src/main/java/com/biganto/visual/roompark/conductor/dialogs/tour_chooser/TourChooserDialogController.kt
View file @
99cecf5f
...
...
@@ -80,7 +80,7 @@ class ChooseTourDialogController : Controller {
.
subscribe
(
::
onTourClicked
)
)
view
.
findViewById
<
View
>(
R
.
id
.
close_current_button
).
setOnClickListener
{
handleBack
()
}
//
view.findViewById<View>(R.id.close_current_button).setOnClickListener { handleBack() }
view
.
setOnClickListener
{
handleBack
()
}
return
view
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/estate/ScreenController.kt
View file @
99cecf5f
package
com.biganto.visual.roompark.presentation.screen.estate
import
android.annotation.SuppressLint
import
android.net.Uri
import
android.os.Bundle
import
android.view.View
...
...
@@ -262,6 +263,7 @@ class EstateScreenController :
is
EstateScreenViewState
.
SomeError
->
render
(
viewState
)
is
EstateScreenViewState
.
ShowEstateInfo
->
render
(
viewState
)
is
EstateScreenViewState
.
ToursLoaded
->
render
(
viewState
)
is
EstateScreenViewState
.
RestoreView
->
render
(
viewState
)
}
}
...
...
@@ -277,40 +279,12 @@ class EstateScreenController :
private
var
estateModel
:
EstateModel
?
=
null
private
fun
render
(
viewState
:
EstateScreenViewState
.
LoadEstate
)
{
estateModel
=
viewState
.
estate
toolBar
.
setToolbar
(
null
,
StatusToolbarModel
(
StatusState
.
AVAILABLE
,
null
,
null
)
)
flatTitle
.
text
=
resources
?.
getString
(
viewState
.
estate
.
type
.
typeShortString
()
,
viewState
.
estate
.
number
)
siteLink
.
setGone
(
viewState
.
estate
.
url
==
null
)
viewState
.
estate
.
url
?.
let
{
url
->
siteLink
.
setOnClickListener
{
activity
?.
startUrl
(
url
)
}
setEstateInfo
(
viewState
.
estate
)
}
startTour
.
setGone
(
viewState
.
estate
.
multitourId
==
null
)
startTourDivider
.
setGone
(
viewState
.
estate
.
multitourId
==
null
)
viewState
.
estate
.
multitourPreview
?.
let
{
Glide
.
with
(
tourScreen
)
.
load
(
it
)
.
into
(
tourScreen
)
}
when
(
viewState
.
estate
.
type
){
FlatType
.
FLAT
->
{
flatTypeView
.
setGone
(
false
)
infoTabDivicder
.
setGone
(
false
)
explicationTab
.
setGone
(
false
)
}
else
->
{
flatTypeView
.
setGone
(
true
)
infoTabDivicder
.
setGone
(
true
)
explicationTab
.
setGone
(
true
)
}
}
private
fun
render
(
viewState
:
EstateScreenViewState
.
RestoreView
)
{
setEstateInfo
(
viewState
.
restore
.
estate
)
}
...
...
@@ -395,6 +369,7 @@ class EstateScreenController :
}
@SuppressLint
(
"SetJavaScriptEnabled"
)
private
fun
render
(
viewState
:
EstateScreenViewState
.
LoadPlan
)
{
planWebView
.
settings
.
javaScriptEnabled
=
true
planWebView
.
clearCache
(
true
)
...
...
@@ -402,11 +377,51 @@ class EstateScreenController :
planWebView
.
loadUrl
(
uri
)
}
private
fun
setEstateInfo
(
estateModel
:
EstateModel
?){
toolBar
.
setToolbar
(
null
,
StatusToolbarModel
(
StatusState
.
AVAILABLE
,
null
,
null
)
)
estateModel
?.
let
{
estate
->
flatTitle
.
text
=
resources
?.
getString
(
estate
.
type
.
typeShortString
()
,
estate
.
number
)
}
siteLink
.
setGone
(
estateModel
?.
url
==
null
)
estateModel
?.
url
?.
let
{
url
->
siteLink
.
setOnClickListener
{
activity
?.
startUrl
(
url
)
}
}
startTour
.
setGone
(
estateModel
?.
multitourId
==
null
)
startTourDivider
.
setGone
(
estateModel
?.
multitourId
==
null
)
estateModel
?.
multitourPreview
?.
let
{
Glide
.
with
(
tourScreen
)
.
load
(
it
)
.
into
(
tourScreen
)
}
when
(
estateModel
?.
type
){
FlatType
.
FLAT
->
{
flatTypeView
.
setGone
(
false
)
infoTabDivicder
.
setGone
(
false
)
explicationTab
.
setGone
(
false
)
}
else
->
{
flatTypeView
.
setGone
(
true
)
infoTabDivicder
.
setGone
(
true
)
explicationTab
.
setGone
(
true
)
}
}
}
private
fun
getComponent
()
=
DaggerEstateScreenComponent
.
factory
()
.
create
(
RoomParkApplication
.
component
,
activity
as
RoomParkMainActivity
,
args
.
getInt
(
SELECTED_ESTATE_ID_KEY
))
.
inject
(
this
)
override
fun
getLayoutId
():
Int
=
R
.
layout
.
flat_full_card_screen
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/estate/ScreenPresenter.kt
View file @
99cecf5f
...
...
@@ -30,11 +30,6 @@ class EstateScreenPresenter @Inject constructor(
)
:
BigantoBasePresenter
<
EstateScreen
,
EstateScreenViewState
>()
{
private
var
planList
:
List
<
PlanPresetModel
>?
=
null
private
var
estate
:
EstateModel
?
=
null
private
var
showType
:
InfoShowType
=
InfoShowType
.
COMMON_INFO
override
fun
defaultErrorViewStateHandler
()
=
{
e
:
ExceptionString
->
EstateScreenViewState
.
SomeError
(
e
)
}
...
...
@@ -43,18 +38,26 @@ class EstateScreenPresenter @Inject constructor(
interactor
.
getPlan
(
plan
)
.
map
<
EstateScreenViewState
>
{
EstateScreenViewState
.
LoadPlan
(
it
)
}
private
var
restoreModel
=
RestoreModel
(
null
,
null
)
override
fun
detachView
()
{
super
.
detachView
()
restoreStateObservable
.
accept
(
EstateScreenViewState
.
RestoreView
(
restoreModel
))
}
override
fun
bindIntents
()
{
val
prefetchCards
=
interactor
.
getEstate
(
estateId
)
.
doOnNext
{
estate
=
it
.
copy
()
}
.
doOnNext
{
restoreModel
.
estate
=
it
.
copy
()
}
.
map
{
EstateScreenViewState
.
LoadEstate
(
it
)
}
val
fetchPlans
=
interactor
.
getPlanTypes
(
estateId
)
.
doOnNext
{
planList
=
it
.
toList
()
}
.
doOnNext
{
restoreModel
.
planList
=
it
.
toList
()
}
.
map
{
EstateScreenViewState
.
LoadPlanTypes
(
it
)
}
val
fetchPlan
=
intent
(
EstateScreen
::
planTypesTabSelected
)
.
map
{
planList
?.
get
(
it
)
}
.
map
{
restoreModel
.
planList
?.
get
(
it
)
}
.
flatMap
{
planPreset
->
interactor
.
getPlan
(
planPreset
)
.
map
<
EstateScreenViewState
>
{
plan
->
EstateScreenViewState
.
LoadPlan
(
plan
)
}
...
...
@@ -67,9 +70,9 @@ class EstateScreenPresenter @Inject constructor(
Observable
.
just
<
EstateScreenViewState
>(
EstateScreenViewState
.
ShowEstateInfo
(
showType
,
if
(
showType
==
InfoShowType
.
COMMON_INFO
)
mapCommonInfo
(
estate
?.
commonInfo
)
restoreModel
.
showType
,
if
(
restoreModel
.
showType
==
InfoShowType
.
COMMON_INFO
)
mapCommonInfo
(
restoreModel
.
estate
?.
commonInfo
)
else
mapCommonInfo
(
planPreset
.
explication
)
)
)
...
...
@@ -78,48 +81,48 @@ class EstateScreenPresenter @Inject constructor(
val
switchSizes
=
intent
(
EstateScreen
::
switchSizes
)
.
map
{
pair
->
val
plan
=
planList
?.
first
{
it
.
planId
==
pair
.
first
}
val
plan
=
restoreModel
.
planList
?.
first
{
it
.
planId
==
pair
.
first
}
plan
?.
switchFeature
<
FeatureModel
.
Sizes
>(
pair
.
second
)
plan
}.
flatMap
(
::
getPlan
)
val
switchFurn
=
intent
(
EstateScreen
::
switchFurniture
)
.
map
{
pair
->
val
plan
=
planList
?.
first
{
it
.
planId
==
pair
.
first
}
val
plan
=
restoreModel
.
planList
?.
first
{
it
.
planId
==
pair
.
first
}
plan
?.
switchFeature
<
FeatureModel
.
Furniture
>(
pair
.
second
)
plan
}.
flatMap
(
::
getPlan
)
val
switchWalls
=
intent
(
EstateScreen
::
switchWalls
)
.
map
{
pair
->
val
plan
=
planList
?.
first
{
it
.
planId
==
pair
.
first
}
val
plan
=
restoreModel
.
planList
?.
first
{
it
.
planId
==
pair
.
first
}
plan
?.
switchFeature
<
FeatureModel
.
Walls
>(
pair
.
second
)
plan
}.
flatMap
(
::
getPlan
)
val
switchElectric
=
intent
(
EstateScreen
::
switchElectric
)
.
map
{
pair
->
val
plan
=
planList
?.
first
{
it
.
planId
==
pair
.
first
}
val
plan
=
restoreModel
.
planList
?.
first
{
it
.
planId
==
pair
.
first
}
plan
?.
switchFeature
<
FeatureModel
.
Electric
>(
pair
.
second
)
plan
}.
flatMap
(
::
getPlan
)
val
showInfo
=
intent
(
EstateScreen
::
showCommonInfo
)
.
doOnNext
{
showType
=
InfoShowType
.
COMMON_INFO
}
.
map
{
estate
?.
commonInfo
}
.
doOnNext
{
restoreModel
.
showType
=
InfoShowType
.
COMMON_INFO
}
.
map
{
restoreModel
.
estate
?.
commonInfo
}
.
map
(
::
mapCommonInfo
)
.
map
{
EstateScreenViewState
.
ShowEstateInfo
(
showType
,
it
)
}
.
map
{
EstateScreenViewState
.
ShowEstateInfo
(
restoreModel
.
showType
,
it
)
}
val
showExplication
=
intent
(
EstateScreen
::
showExplication
)
.
doOnNext
{
showType
=
InfoShowType
.
EXPLICATIONS
}
.
map
{
planList
?.
get
(
it
)
?.
explication
}
.
doOnNext
{
restoreModel
.
showType
=
InfoShowType
.
EXPLICATIONS
}
.
map
{
restoreModel
.
planList
?.
get
(
it
)
?.
explication
}
.
map
(
::
mapCommonInfo
)
.
map
{
EstateScreenViewState
.
ShowEstateInfo
(
showType
,
it
)
}
.
map
{
EstateScreenViewState
.
ShowEstateInfo
(
restoreModel
.
showType
,
it
)
}
val
onStartTours
=
intent
(
EstateScreen
::
tourCardClicked
)
.
map
{
estate
}
.
map
{
restoreModel
.
estate
}
.
flatMap
{
estate
->
toursInteractor
.
getEstateTourList
(
estate
)
.
map
{
EstateScreenViewState
.
ToursLoaded
(
it
)
}
}
...
...
@@ -202,3 +205,8 @@ enum class InfoShowType{
COMMON_INFO
,
EXPLICATIONS
}
data class
RestoreModel
(
var
planList
:
List
<
PlanPresetModel
>?
=
null
,
var
estate
:
EstateModel
?
=
null
,
var
showType
:
InfoShowType
=
InfoShowType
.
COMMON_INFO
)
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/presentation/screen/estate/ScreenViewState.kt
View file @
99cecf5f
...
...
@@ -21,4 +21,5 @@ sealed class EstateScreenViewState : BigantoBaseViewState() {
class
SomeError
(
val
exception
:
ExceptionString
)
:
EstateScreenViewState
()
class
ShowEstateInfo
(
val
showType
:
InfoShowType
,
val
info
:
List
<
DisplayInfoModel
>)
:
EstateScreenViewState
()
class
ToursLoaded
(
val
tours
:
List
<
TourModel
>)
:
EstateScreenViewState
()
class
RestoreView
(
val
restore
:
RestoreModel
)
:
EstateScreenViewState
()
}
\ No newline at end of file
app/src/main/res/layout-v23/download_tour_layout.xml
View file @
99cecf5f
...
...
@@ -59,10 +59,14 @@
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:id=
"@+id/cancelDownloadButton"
android:background=
"?attr/selectableItemBackgroundBorderless"
android:clickable=
"true"
android:focusable=
"true"
app:layout_constraintTop_toBottomOf=
"@+id/downloadProgress"
android:layout_marginTop=
"16dp"
app:layout_constraintStart_toStartOf=
"parent"
android:layout_marginStart=
"32dp"
app:layout_constraintEnd_toEndOf=
"parent"
android:layout_marginEnd=
"32dp"
android:layout_marginBottom=
"32dp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintVertical_bias=
"0.24000001"
style=
"@style/CancelTextDownloader"
android:padding=
"4dp"
app:layout_constraintVertical_bias=
"0.24000001"
style=
"@style/CancelTextDownloader"
android:padding=
"8dp"
android:paddingStart=
"8dp"
android:paddingEnd=
"8dp"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/tours_chooser_screen.xml
View file @
99cecf5f
...
...
@@ -5,8 +5,9 @@
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/playTourCardOpacityLight"
android:backgroundTintMode=
"src_atop"
android:clickable=
"true"
android:focusable
InTouchMode
=
"true"
>
android:focusable=
"true"
>
<com.google.android.material.card.MaterialCardView
android:layout_width=
"0dp"
...
...
@@ -42,10 +43,9 @@
android:layout_alignParentEnd=
"true"
android:layout_marginTop=
"16dp"
android:layout_marginEnd=
"8dp"
android:clickable=
"
tru
e"
android:clickable=
"
fals
e"
android:contentDescription=
"@string/content_description_close"
android:focusable=
"true"
android:focusableInTouchMode=
"true"
android:focusable=
"false"
android:scaleType=
"fitXY"
android:src=
"@drawable/ic_close_circled"
app:layout_constraintEnd_toEndOf=
"parent"
...
...
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