Commit c4e3681f authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

view events attached

parent 6d79e26b
package com.biganto.visual.roompark.domain.interactor
import com.biganto.visual.roompark.domain.model.TourModel
import com.biganto.visual.roompark.domain.model.TourRequestModel
import com.biganto.visual.roompark.domain.model.TourResponse
import io.reactivex.Observable
import javax.inject.Inject
/**
......@@ -8,4 +12,17 @@ import javax.inject.Inject
class FindFlatInteractor @Inject constructor(
){
fun getFlat(requaest: TourRequestModel): Observable<TourResponse> =
Observable.just(tourResponseMock)
companion object{
val tourResponseMock = TourResponse(arrayListOf(
TourModel("125","Tour s otdelkoj",null),
TourModel("126","Tour bez otdelki",null)
)
)
}
}
\ No newline at end of file
package com.biganto.visual.roompark.domain.model
/**
* Created by Vladislav Bogdashkin on 22.10.2019.
*/
data class TourRequestModel(val building:Int, val flat:String)
data class TourResponse(val response:List<TourModel>)
data class TourModel(val tourId:String, val title:String, val preview:String?)
package com.biganto.visual.roompark.presentation.screen.to_flat
import com.biganto.visual.roompark.conductor.BigantoBaseContract
import com.biganto.visual.roompark.domain.model.TourRequestModel
import io.reactivex.Observable
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
interface FindFlatScreen : BigantoBaseContract<FindFlatScreenViewState> {
fun getFlat() : Observable<TourRequestModel>
fun startTour() : Observable<String>
}
package com.biganto.visual.roompark.presentation.screen.to_flat
import android.view.KeyEvent
import android.view.View
import android.widget.EditText
import android.widget.TextView
import butterknife.BindView
import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.base.RoomParkApplication
import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.conductor.BigantoBaseController
import com.biganto.visual.roompark.domain.model.TourRequestModel
import com.biganto.visual.roompark.presentation.screen.feeds.EstateTabModel
import com.google.android.material.button.MaterialButton
import com.google.android.material.tabs.TabLayout
import com.google.android.material.textfield.TextInputLayout
import com.jakewharton.rxbinding3.view.keys
import io.reactivex.Observable
import timber.log.Timber
import javax.inject.Inject
......@@ -22,12 +29,36 @@ class FindFlatScreenController :
, FindFlatScreenPresenter>()
, FindFlatScreen {
override fun getFlat(): Observable<TourRequestModel> =
flatNumberEditor.keys { it.keyCode == KeyEvent.KEYCODE_ENTER }
.doOnNext { flatNumberEditor.hideKeyboard() }
.doOnNext{Timber.d(" key code is : ${it.keyCode}")}
.doOnNext{Timber.d(" KeyEvent.FLAG_EDITOR_ACTION : ${KeyEvent.FLAG_EDITOR_ACTION}")}
.map {
TourRequestModel(
estateTabs[flatTabs.selectedTabPosition].building
, flatNumberInput.editText?.text.toString()
)
}
override fun startTour(): Observable<String> = Observable.just("1")
override fun injectDependencies() {
getComponent()
}
@BindView(R.id.flat_estate_tabs)
lateinit var feedsTabs: TabLayout
lateinit var flatTabs: TabLayout
@BindView(R.id.flatNumberInputer)
lateinit var flatNumberInput: TextInputLayout
@BindView(R.id.flatNumberEditText)
lateinit var flatNumberEditor: EditText
@BindView(R.id.findFlatButton)
lateinit var fubdFlatButton: MaterialButton
@Inject
override lateinit var injectedPresenter: FindFlatScreenPresenter
......@@ -40,7 +71,7 @@ class FindFlatScreenController :
override fun onViewBound(v: View) {
estateTabs.forEach {estate ->
val tab = feedsTabs.newTab()
val tab = flatTabs.newTab()
.setCustomView(R.layout.to_flat_tab_view)
tab.customView
?.let {
......@@ -50,7 +81,8 @@ class FindFlatScreenController :
if (estateTabs.indexOf(estate) == estateTabs.size - 1) View.GONE
else View.VISIBLE
}
feedsTabs.addTab(tab)
flatTabs.addTab(tab)
}
}
......
......@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.to_flat
import com.biganto.visual.roompark.conductor.BigantoBasePresenter
import com.biganto.visual.roompark.domain.interactor.FindFlatInteractor
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import timber.log.Timber
......@@ -20,12 +21,29 @@ class FindFlatScreenPresenter @Inject constructor(
override fun bindIntents() {
val startTourIntent = intent(FindFlatScreen::startTour)
.map { FindFlatScreenViewState.StartTour(it) }
val getFlatIntent = intent(FindFlatScreen::getFlat)
.doOnNext{Timber.d(" flat is $it")}
.flatMap { request ->
interactor.getFlat(request)
.map {
if (it.response.isNullOrEmpty()) FindFlatScreenViewState.FlatNotFound()
else FindFlatScreenViewState.TourFounded(it.response)
}
.onErrorReturn { Timber.e(it);FindFlatScreenViewState.RequstFlatProgress() }
}
.startWith(Observable.just(FindFlatScreenViewState.RequstFlatProgress()))
val state = restoreStateObservable
.doOnError{ Timber.e(it)}
.mergeWith(getFlatIntent)
.mergeWith(startTourIntent)
.doOnError { Timber.e(it) }
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
subscribeViewState(state.cast(FindFlatScreenViewState::class.java), FindFlatScreen::render)
}
}
\ No newline at end of file
package com.biganto.visual.roompark.presentation.screen.to_flat
import com.biganto.visual.roompark.conductor.BigantoBaseViewState
import com.biganto.visual.roompark.domain.model.TourModel
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
......@@ -9,4 +10,8 @@ import com.biganto.visual.roompark.conductor.BigantoBaseViewState
sealed class FindFlatScreenViewState : BigantoBaseViewState() {
class Idle : FindFlatScreenViewState()
class RequstFlatProgress : FindFlatScreenViewState()
class TourFounded(val items:List<TourModel>) : FindFlatScreenViewState()
class StartTour(val tourId:String) : FindFlatScreenViewState()
class FlatNotFound() : FindFlatScreenViewState()
}
\ No newline at end of file
......@@ -19,17 +19,18 @@
<com.google.android.material.textfield.TextInputLayout
style="@style/SelectFlatInputLayout"
android:id="@+id/flatNumberInputer"
android:colorControlActivated="@color/colorAccent"
style="@style/SelectFlatInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp">
android:layout_marginEnd="16dp"
android:colorControlActivated="@color/colorAccent">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/flatNumberEditText"
style="@style/ToFlat.EditText"
android:layout_width="match_parent"
......@@ -41,6 +42,7 @@
<com.google.android.material.button.MaterialButton
android:id="@+id/findFlatButton"
style="@style/AuthButton.Enable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment