Commit 3ba27c4e authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

improve mvi behaviour

parent aabbca59
*.iml
.gradle
/local.properties
/.idea
/.idea/caches
/.idea/libraries
/.idea/modules.xml
......
......@@ -2,6 +2,7 @@
<dictionary name="bogdashkin">
<words>
<w>Biganto</w>
<w>snackbar</w>
</words>
</dictionary>
</component>
\ No newline at end of file
......@@ -9,18 +9,22 @@ import android.view.inputmethod.InputMethodManager
import android.widget.Toast
import androidx.annotation.LayoutRes
import androidx.annotation.StringRes
import androidx.appcompat.app.ActionBar
import androidx.appcompat.app.AppCompatActivity
import butterknife.ButterKnife
import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.base.ICollapsingToolBar
import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.conductor.mosby.mvi.BigantoMviController
import com.biganto.visual.roompark.di.dagger.PerScreen
import com.biganto.visual.roompark.view_utils.snackbar.ISnackBarProvider
import com.hannesdorfmann.mosby3.mvi.MviBasePresenter
import io.reactivex.disposables.CompositeDisposable
import javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 28.05.2018.
*/
@PerScreen
abstract class BigantoBaseController<VS : BigantoBaseViewState,V: BigantoBaseContract<VS>,P : MviBasePresenter<V,VS>>
: BigantoMviController<V, P> {
......@@ -38,22 +42,12 @@ abstract class BigantoBaseController<VS : BigantoBaseViewState,V: BigantoBaseCon
@StringRes
protected abstract fun getToolbarTitleId(): Int
protected abstract fun showBottomAppBar(): Boolean
// protected lateinit var toolBars:TopBottomActionBarsSupported
protected lateinit var snackbar: ISnackBarProvider
private fun setToolbarTitle() {
// if the Activity happens to be non-AppCompatActivity or it does not have ActionBar, simply do not set the title
(activity as? AppCompatActivity)?.supportActionBar?.apply {
title = resources?.getString(getToolbarTitleId())
setDisplayHomeAsUpEnabled(router.backstackSize > 1)
}
}
@Inject
private lateinit var roomParkActivity:RoomParkMainActivity
//TODO(injection)
private fun bottomToolbar() : ActionBar?=(activity as? AppCompatActivity)?.supportActionBar
protected val toolBar: ICollapsingToolBar = roomParkActivity
protected val snackbar: ISnackBarProvider = roomParkActivity.snackbarProvider
override fun onDetach(view: View) {
detachDisposable.clear()
......@@ -64,19 +58,13 @@ abstract class BigantoBaseController<VS : BigantoBaseViewState,V: BigantoBaseCon
val view = inflater.inflate(getLayoutId(), container, false)
// instantiate the view
ButterKnife.bind(this, view)
// toolBars=(activity as TopBottomActionBarsSupported)
snackbar = activity as ISnackBarProvider
//TODO(remove duplicated code:)
if (showBottomAppBar())
bottomToolbar()?.show()
if (!showBottomAppBar())
bottomToolbar()?.hide()
return view
}
protected fun View.hideKeyboard() {
val inputMethodManager = applicationContext?.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
val inputMethodManager = applicationContext
?.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
inputMethodManager.hideSoftInputFromWindow(this.windowToken, 0)
}
......
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