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
4b2dcd45
Commit
4b2dcd45
authored
Apr 09, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
to flat restore model
parent
9c1dc92c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
8 deletions
+37
-8
ScreenContract.kt
...al/roompark/presentation/screen/to_flat/ScreenContract.kt
+1
-1
ScreenController.kt
.../roompark/presentation/screen/to_flat/ScreenController.kt
+21
-6
ScreenPresenter.kt
...l/roompark/presentation/screen/to_flat/ScreenPresenter.kt
+14
-1
ScreenViewState.kt
...l/roompark/presentation/screen/to_flat/ScreenViewState.kt
+1
-0
No files found.
app/src/main/java/com/biganto/visual/roompark/presentation/screen/to_flat/ScreenContract.kt
View file @
4b2dcd45
...
...
@@ -9,7 +9,7 @@ import io.reactivex.Observable
interface
FindFlatScreen
:
BigantoBaseContract
<
FindFlatScreenViewState
>
{
fun
getFlat
()
:
Observable
<
FlatRequestModel
>
fun
openFlat
()
:
Observable
<
Int
>
fun
openFlat
()
:
Observable
<
FlatRequestModel
>
}
data class
FlatRequestModel
(
val
building
:
Int
,
val
number
:
Int
)
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/presentation/screen/to_flat/ScreenController.kt
View file @
4b2dcd45
...
...
@@ -36,11 +36,20 @@ class FindFlatScreenController :
,
FindFlatScreenPresenter
>()
,
FindFlatScreen
{
private
val
flatModel
:
FlatRequestModel
get
(){
return
FlatRequestModel
(
estateTabs
[
flatTabs
.
selectedTabPosition
].
building
,
flatNumberInput
.
editText
?.
text
.
toString
().
toInt
()
)
}
override
fun
openFlat
():
Observable
<
Int
>
=
override
fun
openFlat
():
Observable
<
FlatRequestModel
>
=
findFlatButton
.
clicks
()
.
map
{
1
}
.
mergeWith
(
flatNumberEditor
.
keys
{
it
.
keyCode
==
KeyEvent
.
KEYCODE_ENTER
}.
map
{
1
})
.
map
{
flatModel
}
.
doOnNext
{
flatNumberEditor
.
hideKeyboard
()
}
.
observeOn
(
AndroidSchedulers
.
mainThread
())
...
...
@@ -48,12 +57,9 @@ class FindFlatScreenController :
flatNumberEditor
.
afterTextChangeEvents
()
// keys{ it.keyCode == KeyEvent.KEYCODE_ENTER }
.
filter
{
flatNumberInput
.
editText
?.
text
?.
isNotEmpty
()
?:
false
}
.
map
{
FlatRequestModel
(
estateTabs
[
flatTabs
.
selectedTabPosition
].
building
,
flatNumberInput
.
editText
?.
text
.
toString
().
toInt
()
)
flatModel
}
.
debounce
(
30
0
,
TimeUnit
.
MILLISECONDS
)
.
debounce
(
12
0
,
TimeUnit
.
MILLISECONDS
)
.
observeOn
(
AndroidSchedulers
.
mainThread
())
override
fun
injectDependencies
()
{
...
...
@@ -118,6 +124,7 @@ class FindFlatScreenController :
is
FindFlatScreenViewState
.
FlatFounded
->
render
(
viewState
)
is
FindFlatScreenViewState
.
FlatNotFound
->
render
(
viewState
)
is
FindFlatScreenViewState
.
StartFlat
->
render
(
viewState
)
is
FindFlatScreenViewState
.
RestoreView
->
render
(
viewState
)
}
}
...
...
@@ -127,6 +134,14 @@ class FindFlatScreenController :
private
fun
render
(
viewState
:
FindFlatScreenViewState
.
Idle
){
}
private
fun
render
(
viewState
:
FindFlatScreenViewState
.
RestoreView
){
val
tabIndex
=
viewState
.
restore
.
building
-
1
Timber
.
d
(
":: ${viewState.restore.building} : $tabIndex"
)
flatTabs
.
getTabAt
(
tabIndex
)
?.
select
()
//zero-based
flatNumberInput
.
editText
?.
setText
(
viewState
.
restore
.
number
.
toString
())
}
private
fun
render
(
viewState
:
FindFlatScreenViewState
.
FlatFounded
){
findFlatButton
.
isEnabled
=
true
findFlatButton
.
text
=
resources
?.
getString
(
R
.
string
.
flat_ready_to_watch
)
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/to_flat/ScreenPresenter.kt
View file @
4b2dcd45
...
...
@@ -27,6 +27,13 @@ class FindFlatScreenPresenter @Inject constructor(
//estateId
private
var
recentFlat
:
Int
?
=
null
private
var
restoreModel
=
RestoreModel
(-
1
,-
1
)
override
fun
detachView
()
{
super
.
detachView
()
restoreStateObservable
.
accept
(
FindFlatScreenViewState
.
RestoreView
(
restoreModel
))
}
override
fun
vsByCode
(
code
:
Int
):
(
ExceptionString
)
->
FindFlatScreenViewState
=
when
(
code
)
{
304
->
{
message
:
ExceptionString
->
FindFlatScreenViewState
.
FlatNotFound
(
message
)}
...
...
@@ -36,6 +43,7 @@ class FindFlatScreenPresenter @Inject constructor(
override
fun
bindIntents
()
{
val
getFlatIntent
=
intent
(
FindFlatScreen
::
getFlat
)
.
doOnNext
{
restoreModel
.
building
=
it
.
building
;
restoreModel
.
number
=
it
.
number
}
.
doOnNext
{
recentFlat
=
null
}
.
doOnNext
{
Timber
.
d
(
" flat is $it"
)}
.
flatMap
{
request
->
...
...
@@ -47,6 +55,7 @@ class FindFlatScreenPresenter @Inject constructor(
.
startWith
(
Observable
.
just
(
FindFlatScreenViewState
.
RequstFlatProgress
()))
val
startFlatIntent
=
intent
(
FindFlatScreen
::
openFlat
)
.
doOnNext
{
restoreModel
.
building
=
it
.
building
;
restoreModel
.
number
=
it
.
number
}
.
map
{
if
(
recentFlat
!=
null
)
{
FindFlatScreenViewState
.
StartFlat
(
recentFlat
as
Int
)}
else
FindFlatScreenViewState
.
FlatNotFound
(
...
...
@@ -55,6 +64,7 @@ class FindFlatScreenPresenter @Inject constructor(
}
val
state
=
restoreStateObservable
.
mergeWith
(
getFlatIntent
)
.
mergeWith
(
startFlatIntent
)
...
...
@@ -64,4 +74,7 @@ class FindFlatScreenPresenter @Inject constructor(
subscribeViewState
(
state
.
cast
(
FindFlatScreenViewState
::
class
.
java
),
FindFlatScreen
::
render
)
}
}
\ No newline at end of file
}
data class
RestoreModel
(
var
building
:
Int
,
var
number
:
Int
)
app/src/main/java/com/biganto/visual/roompark/presentation/screen/to_flat/ScreenViewState.kt
View file @
4b2dcd45
...
...
@@ -15,4 +15,5 @@ sealed class FindFlatScreenViewState : BigantoBaseViewState() {
class
FlatNotFound
(
val
exceptionString
:
ExceptionString
)
:
FindFlatScreenViewState
()
class
StartFlat
(
val
esateId
:
Int
)
:
FindFlatScreenViewState
()
class
SomeError
(
val
exception
:
ExceptionString
)
:
FindFlatScreenViewState
()
class
RestoreView
(
val
restore
:
RestoreModel
)
:
FindFlatScreenViewState
()
}
\ No newline at end of file
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