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

screen pattern

parent 6c81fb51
package com.biganto.visual.roompark.domain.interactor
import javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 09.10.2019.
*/
class EstateInteractor @Inject constructor(
){
fun getEstate(estateId:Int) = null
}
\ No newline at end of file
package com.biganto.visual.roompark.presentation.screen.estate
import com.biganto.visual.roompark.conductor.BigantoBaseContract
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
interface EstateScreen : BigantoBaseContract<EstateScreenViewState> {
}
package com.biganto.visual.roompark.presentation.screen.estate
import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
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.presentation.screen.favorites.DaggerEstateScreenComponent
import com.biganto.visual.roompark.presentation.screen.favorites.util.EstateListAdapter
import com.biganto.visual.roompark.util.view_utils.grid.CeilsDecoration
import timber.log.Timber
import javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
class EstateScreenController :
BigantoBaseController<EstateScreenViewState
, EstateScreen
, EstateScreenPresenter>()
, EstateScreen {
override fun injectDependencies() {
getComponent()
}
@Inject
override lateinit var injectedPresenter: EstateScreenPresenter
@BindView(R.id.favorites_cards_recycler_view)
lateinit var favoritesRecyclerView: RecyclerView
private fun setToolbar(){
toolBar.showAll()
toolBar.appBar.setExpanded(false,false)
toolBar.collapsingToolbarLayout.title = "ИЗБРАННОЕ"
toolBar.appBar.liftOnScrollTargetViewId = R.id.favorites_cards_recycler_view
toolBar.appBar.setLiftable(true)
toolBar.appBarScrollable(false)
favoritesRecyclerView.isNestedScrollingEnabled = false
}
private fun bindRecycler() {
}
override fun onViewBound(v: View) {
setToolbar()
bindRecycler()
}
override fun render(viewState: EstateScreenViewState) {
super.render(viewState)
Timber.d("Render state $viewState")
when(viewState){
is EstateScreenViewState.Idle -> render(viewState)
is EstateScreenViewState.FavoriteEstatesLoaded -> render(viewState)
is EstateScreenViewState.SomeError -> render(viewState)
}
}
private fun render(viewState: EstateScreenViewState.Idle){
}
private fun render(viewState: EstateScreenViewState.SomeError) =
showError(viewState.exception)
private fun render(viewState: EstateScreenViewState.FavoriteEstatesLoaded) {
}
private fun getComponent() = DaggerEstateScreenComponent.factory()
.create(RoomParkApplication.component,activity as RoomParkMainActivity)
.inject(this)
override fun getLayoutId(): Int = R.layout.favorites_screen
}
\ No newline at end of file
package com.biganto.visual.roompark.presentation.screen.estate
import android.content.Context
import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.di.dagger.AppComponent
import com.biganto.visual.roompark.di.dagger.PerScreen
import dagger.Binds
import dagger.BindsInstance
import dagger.Component
import dagger.Module
@PerScreen
@Component(
modules = [EstateScreenModule::class],
dependencies = [AppComponent::class])
interface EstateScreenComponent {
@Component.Factory
interface Factory{
fun create(
appComponent: AppComponent
,@BindsInstance activity: RoomParkMainActivity
): EstateScreenComponent
}
val presenter: EstateScreenPresenter
fun inject(controller: EstateScreenController)
}
@Module
abstract class EstateScreenModule{
@PerScreen
@Binds
abstract fun provideContext(activity: RoomParkMainActivity): Context
}
package com.biganto.visual.roompark.presentation.screen.estate
import com.biganto.visual.roompark.conductor.BigantoBasePresenter
import com.biganto.visual.roompark.domain.interactor.EstateInteractor
import com.biganto.visual.roompark.util.monades.ExceptionString
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import timber.log.Timber
import javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
class EstateScreenPresenter @Inject constructor(
private val interactor: EstateInteractor
)
: BigantoBasePresenter<EstateScreen, EstateScreenViewState>() {
override fun defaultErrorViewStateHandler() =
{e: ExceptionString -> EstateScreenViewState.SomeError(e) }
override fun bindIntents() {
val prefetchCards = interactor.getEstate(1)
//.map { EstateScreenViewState.FavoriteEstatesLoaded(it) }
val state = restoreStateObservable
.mergeWith(prefetchCards)
.doOnError{ Timber.e(it)}
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
subscribeViewState(state.cast(EstateScreenViewState::class.java), EstateScreen::render)
}
}
\ No newline at end of file
package com.biganto.visual.roompark.presentation.screen.estate
import com.biganto.visual.roompark.conductor.BigantoBaseViewState
import com.biganto.visual.roompark.domain.model.EstateModel
import com.biganto.visual.roompark.util.monades.ExceptionString
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
sealed class EstateScreenViewState : BigantoBaseViewState() {
class Idle : EstateScreenViewState()
class FavoriteEstatesLoaded(val items: List<EstateModel>) : EstateScreenViewState()
class SomeError(val exception: ExceptionString) : EstateScreenViewState()
}
\ No newline at end of file
package com.biganto.visual.roompark.presentation.screen.estate.util
import android.view.View
import com.biganto.visual.roompark.domain.model.PlanModel
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyclerAdapter
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
/**
* Created by Vladislav Bogdashkin on 16.10.2019.
*/
class PlanPresetAdapterAdapter : CommonRecyclerAdapter<PlenPresetViewHolder, PlanModel>() {
override val vhKlazz = PlenPresetViewHolder::class
override fun getVhLayout(): Int {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}
class PlenPresetViewHolder(itemView: View) : CommonViewHolder<PlanModel>(itemView) {
override fun onViewBound(model: PlanModel) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}
\ No newline at end of file
package com.biganto.visual.roompark.presentation.screen.favorites
import com.biganto.visual.roompark.conductor.BigantoBaseContract
import com.biganto.visual.roompark.presentation.screen.estate.FavoritesScreenViewState
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
......
......@@ -8,6 +8,9 @@ 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.presentation.screen.estate.FavoritesScreen
import com.biganto.visual.roompark.presentation.screen.estate.FavoritesScreenPresenter
import com.biganto.visual.roompark.presentation.screen.estate.FavoritesScreenViewState
import com.biganto.visual.roompark.presentation.screen.favorites.util.FavoritesListAdapter
import com.biganto.visual.roompark.util.view_utils.grid.CeilsDecoration
import timber.log.Timber
......
......@@ -4,6 +4,10 @@ import android.content.Context
import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.di.dagger.AppComponent
import com.biganto.visual.roompark.di.dagger.PerScreen
import com.biganto.visual.roompark.presentation.screen.estate.FavoritesScreenComponent
import com.biganto.visual.roompark.presentation.screen.estate.FavoritesScreenController
import com.biganto.visual.roompark.presentation.screen.estate.FavoritesScreenModule
import com.biganto.visual.roompark.presentation.screen.estate.FavoritesScreenPresenter
import dagger.Binds
import dagger.BindsInstance
import dagger.Component
......
......@@ -2,6 +2,8 @@ package com.biganto.visual.roompark.presentation.screen.favorites
import com.biganto.visual.roompark.conductor.BigantoBasePresenter
import com.biganto.visual.roompark.domain.interactor.FavoritesInteractor
import com.biganto.visual.roompark.presentation.screen.estate.FavoritesScreen
import com.biganto.visual.roompark.presentation.screen.estate.FavoritesScreenViewState
import com.biganto.visual.roompark.util.monades.ExceptionString
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
......
......@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.favorites
import com.biganto.visual.roompark.conductor.BigantoBaseViewState
import com.biganto.visual.roompark.domain.model.EstateModel
import com.biganto.visual.roompark.presentation.screen.estate.FavoritesScreenViewState
import com.biganto.visual.roompark.util.monades.ExceptionString
/**
......
......@@ -12,7 +12,7 @@ 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.presentation.screen.deals.DealsScreenController
import com.biganto.visual.roompark.presentation.screen.favorites.FavoritesScreenController
import com.biganto.visual.roompark.presentation.screen.estate.FavoritesScreenController
import com.biganto.visual.roompark.presentation.screen.feeds.FeedsScreenController
import com.biganto.visual.roompark.presentation.screen.settings.SettingsScreenController
import com.biganto.visual.roompark.presentation.screen.to_flat.FindFlatScreenController
......
......@@ -10,7 +10,7 @@ import com.biganto.visual.roompark.base.ICollapsingToolBar
import com.biganto.visual.roompark.base.RoomParkApplication
import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.presentation.screen.deals.DealsScreenController
import com.biganto.visual.roompark.presentation.screen.favorites.FavoritesScreenController
import com.biganto.visual.roompark.presentation.screen.estate.FavoritesScreenController
import com.biganto.visual.roompark.presentation.screen.feeds.FeedsScreenController
import com.biganto.visual.roompark.presentation.screen.home.DaggerHomeScreenComponent
import com.biganto.visual.roompark.presentation.screen.home.HomeScreenPresenter
......
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