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
a1c067d4
Commit
a1c067d4
authored
Jan 16, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update to flat functionally as design
parent
3fd8fbd3
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
75 additions
and
9 deletions
+75
-9
ScreenContract.kt
...al/roompark/presentation/screen/to_flat/ScreenContract.kt
+1
-0
ScreenController.kt
.../roompark/presentation/screen/to_flat/ScreenController.kt
+29
-3
ScreenPresenter.kt
...l/roompark/presentation/screen/to_flat/ScreenPresenter.kt
+22
-1
ScreenViewState.kt
...l/roompark/presentation/screen/to_flat/ScreenViewState.kt
+3
-2
flat_watch_button_selector.xml
app/src/main/res/color/flat_watch_button_selector.xml
+6
-0
find_flat_screen.xml
app/src/main/res/layout/find_flat_screen.xml
+2
-3
strings.xml
app/src/main/res/values/strings.xml
+2
-0
styles.xml
app/src/main/res/values/styles.xml
+10
-0
No files found.
app/src/main/java/com/biganto/visual/roompark/presentation/screen/to_flat/ScreenContract.kt
View file @
a1c067d4
...
...
@@ -9,6 +9,7 @@ import io.reactivex.Observable
interface
FindFlatScreen
:
BigantoBaseContract
<
FindFlatScreenViewState
>
{
fun
getFlat
()
:
Observable
<
FlatRequestModel
>
fun
openFlat
()
:
Observable
<
Int
>
}
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 @
a1c067d4
...
...
@@ -18,9 +18,11 @@ import com.google.android.material.tabs.TabLayout
import
com.google.android.material.textfield.TextInputLayout
import
com.jakewharton.rxbinding3.view.clicks
import
com.jakewharton.rxbinding3.view.keys
import
com.jakewharton.rxbinding3.widget.afterTextChangeEvents
import
io.reactivex.Observable
import
io.reactivex.android.schedulers.AndroidSchedulers
import
timber.log.Timber
import
java.util.concurrent.TimeUnit
import
javax.inject.Inject
/**
...
...
@@ -34,16 +36,23 @@ class FindFlatScreenController :
,
FindFlatScreen
{
override
fun
openFlat
():
Observable
<
Int
>
=
findFlatButton
.
clicks
()
.
map
{
1
}
.
mergeWith
(
flatNumberEditor
.
keys
{
it
.
keyCode
==
KeyEvent
.
KEYCODE_ENTER
}.
map
{
1
})
.
doOnNext
{
flatNumberEditor
.
hideKeyboard
()
}
.
observeOn
(
AndroidSchedulers
.
mainThread
())
override
fun
getFlat
():
Observable
<
FlatRequestModel
>
=
Observable
.
merge
(
flatNumberEditor
.
keys
{
it
.
keyCode
==
KeyEvent
.
KEYCODE_ENTER
},
findFlatButton
.
clicks
())
.
doOnNext
{
flatNumberEditor
.
hideKeyboard
()
}
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
()
)
}
.
debounce
(
300
,
TimeUnit
.
MILLISECONDS
)
.
observeOn
(
AndroidSchedulers
.
mainThread
())
override
fun
injectDependencies
()
{
...
...
@@ -107,6 +116,8 @@ class FindFlatScreenController :
is
FindFlatScreenViewState
.
Idle
->
render
(
viewState
)
is
FindFlatScreenViewState
.
SomeError
->
render
(
viewState
)
is
FindFlatScreenViewState
.
FlatFounded
->
render
(
viewState
)
is
FindFlatScreenViewState
.
FlatNotFound
->
render
(
viewState
)
is
FindFlatScreenViewState
.
StartFlat
->
render
(
viewState
)
}
}
...
...
@@ -117,6 +128,21 @@ class FindFlatScreenController :
}
private
fun
render
(
viewState
:
FindFlatScreenViewState
.
FlatFounded
){
findFlatButton
.
isEnabled
=
true
findFlatButton
.
text
=
resources
?.
getString
(
R
.
string
.
flat_ready_to_watch
)
}
private
fun
render
(
viewState
:
FindFlatScreenViewState
.
FlatNotFound
){
findFlatButton
.
isEnabled
=
false
viewState
.
exceptionString
.
selectHandler
(
{
findFlatButton
.
text
=
resources
?.
getString
(
it
)},
{
findFlatButton
.
text
=
it
}
)
}
private
fun
render
(
viewState
:
FindFlatScreenViewState
.
StartFlat
){
router
.
pushController
(
RouterTransaction
.
with
(
EstateScreenController
(
viewState
.
esateId
))
.
pushChangeHandler
(
FadeChangeHandler
())
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/to_flat/ScreenPresenter.kt
View file @
a1c067d4
package
com.biganto.visual.roompark.presentation.screen.to_flat
import
com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.conductor.BigantoBasePresenter
import
com.biganto.visual.roompark.domain.interactor.FindFlatInteractor
import
com.biganto.visual.roompark.util.monades.ExceptionString
...
...
@@ -23,20 +24,40 @@ class FindFlatScreenPresenter @Inject constructor(
{
e
:
ExceptionString
->
FindFlatScreenViewState
.
SomeError
(
e
)}
//estateId
private
var
recentFlat
:
Int
?
=
null
override
fun
vsByCode
(
code
:
Int
):
(
ExceptionString
)
->
FindFlatScreenViewState
=
when
(
code
)
{
304
->
{
message
:
ExceptionString
->
FindFlatScreenViewState
.
FlatNotFound
(
message
)}
else
->
super
.
vsByCode
(
code
)
}
override
fun
bindIntents
()
{
val
getFlatIntent
=
intent
(
FindFlatScreen
::
getFlat
)
.
doOnNext
{
recentFlat
=
null
}
.
doOnNext
{
Timber
.
d
(
" flat is $it"
)}
.
flatMap
{
request
->
interactor
.
getFlat
(
request
.
building
,
request
.
number
)
.
map
<
FindFlatScreenViewState
>
{
FindFlatScreenViewState
.
FlatFounded
(
it
)}
.
doOnNext
{
recentFlat
=
it
}
.
map
<
FindFlatScreenViewState
>
{
FindFlatScreenViewState
.
FlatFounded
()}
.
onErrorReturn
(
::
parseError
)
}
.
startWith
(
Observable
.
just
(
FindFlatScreenViewState
.
RequstFlatProgress
()))
val
startFlatIntent
=
intent
(
FindFlatScreen
::
openFlat
)
.
map
{
if
(
recentFlat
!=
null
)
{
FindFlatScreenViewState
.
StartFlat
(
recentFlat
as
Int
)}
else
FindFlatScreenViewState
.
FlatNotFound
(
ExceptionString
(
R
.
string
.
flat_not_found
,
null
)
)
}
val
state
=
restoreStateObservable
.
mergeWith
(
getFlatIntent
)
.
mergeWith
(
startFlatIntent
)
.
doOnError
{
Timber
.
e
(
it
)
}
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/to_flat/ScreenViewState.kt
View file @
a1c067d4
...
...
@@ -11,7 +11,8 @@ import com.biganto.visual.roompark.util.monades.ExceptionString
sealed
class
FindFlatScreenViewState
:
BigantoBaseViewState
()
{
class
Idle
:
FindFlatScreenViewState
()
class
RequstFlatProgress
:
FindFlatScreenViewState
()
class
FlatFounded
(
val
esateId
:
Int
)
:
FindFlatScreenViewState
()
class
FlatNotFound
:
FindFlatScreenViewState
()
class
FlatFounded
:
FindFlatScreenViewState
()
class
FlatNotFound
(
val
exceptionString
:
ExceptionString
)
:
FindFlatScreenViewState
()
class
StartFlat
(
val
esateId
:
Int
)
:
FindFlatScreenViewState
()
class
SomeError
(
val
exception
:
ExceptionString
)
:
FindFlatScreenViewState
()
}
\ No newline at end of file
app/src/main/res/color/flat_watch_button_selector.xml
0 → 100644
View file @
a1c067d4
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item
android:state_enabled=
"false"
android:color=
"@color/colorError"
/>
<item
android:color=
"@color/colorAccent"
/>
</selector>
\ No newline at end of file
app/src/main/res/layout/find_flat_screen.xml
View file @
a1c067d4
...
...
@@ -45,11 +45,10 @@
<com.google.android.material.button.MaterialButton
android:id=
"@+id/findFlatButton"
style=
"@style/
AuthButton.Enable
"
style=
"@style/
FlatButton.Watch
"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"16dp"
android:layout_marginTop=
"16dp"
android:layout_marginEnd=
"16dp"
android:text=
"СМОТРЕТЬ"
/>
android:layout_marginEnd=
"16dp"
/>
</LinearLayout>
\ No newline at end of file
app/src/main/res/values/strings.xml
View file @
a1c067d4
...
...
@@ -69,6 +69,8 @@
<string
name=
"max_discount"
>
Максимальная скидка с учетом всех акций
</string>
<string
name=
"discount_value"
>
%,.1f \%
</string>
<string
name=
"discounted_price"
>
Стоимость со скидкой
</string>
<string
name=
"flat_not_found"
>
В ЭТОМ ДОМЕ НЕТ КВАРТИРЫ С ТАКИМ НОМЕРОМ
</string>
<string
name=
"flat_ready_to_watch"
>
СМОТРЕТЬ
</string>
<!--endregion-->
</resources>
app/src/main/res/values/styles.xml
View file @
a1c067d4
...
...
@@ -149,6 +149,16 @@
<item
name=
"hintTextColor"
>
@color/colorNoticeText
</item>
</style>
<style
name=
"FlatButton.Watch"
parent=
"Widget.MaterialComponents.Button.OutlinedButton"
>
<item
name=
"android:text"
>
"СМОТРЕТЬ"
</item>
<item
name=
"android:textColor"
>
@color/flat_watch_button_selector
</item>
<item
name=
"strokeColor"
>
@color/flat_watch_button_selector
</item>
<item
name=
"strokeWidth"
>
4dp
</item>
<item
name=
"android:height"
>
64dp
</item>
<item
name=
"cornerRadius"
>
0dp
</item>
<item
name=
"rippleColor"
>
@color/colorAccentSecondary
</item>
<item
name=
"android:textSize"
>
@dimen/accent_header
</item>
</style>
<style
name=
"AuthButton.Enable"
>
<item
name=
"android:text"
>
"ВОЙТИ"
</item>
...
...
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