Commit 4c2572e7 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

implement top app bar default activity behaviour

parent c9b24789
package com.biganto.visual.roompark.base
import android.os.Bundle
import android.widget.TextView
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import androidx.coordinatorlayout.widget.CoordinatorLayout
import butterknife.BindView
import com.biganto.visual.roompark.BuildConfig
import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.di.koin.StartUpData
import com.biganto.visual.roompark.view_utils.app_bar.DragControlAppBarLayoutBehaviour
import com.biganto.visual.roompark.view_utils.snackbar.ISnackBarProvider
import com.bluelinelabs.conductor.Conductor
import com.bluelinelabs.conductor.Router
import com.crashlytics.android.Crashlytics
import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.appbar.CollapsingToolbarLayout
import com.google.android.material.bottomnavigation.BottomNavigationView
import io.fabric.sdk.android.Fabric
import org.koin.android.scope.currentScope
class RoomParkMainActivity : AppCompatActivity() {
class RoomParkMainActivity(
) : AppCompatActivity()
,ICollapsingToolBar
,IConductorActivity
,IBottomNavigation{
lateinit var entryText:TextView
private val entryDate : StartUpData by currentScope.inject()
private val snackbarProvider: ISnackBarProvider by currentScope.inject()
private lateinit var router: Router
@BindView(R.id.top_toolbar) override lateinit var topAppBar: Toolbar
@BindView(R.id.app_bar) override lateinit var appBar: AppBarLayout
@BindView(R.id.topToolbarHolder) override lateinit var coordinatorLayout: CoordinatorLayout
@BindView(R.id.collapsingToolbarLayout) override lateinit var collapsingToolbarLayout: CollapsingToolbarLayout
@BindView(R.id.conductor_container) override lateinit var conductorContainer: ViewGroup
@BindView(R.id.bottom_navigation_view) override lateinit var bottomNavigation: BottomNavigationView
override fun onCreate(savedInstanceState: Bundle?) {
setTheme(R.style.AppTheme)
super.onCreate(savedInstanceState)
if (!BuildConfig.DEBUG) Fabric.with(this, Crashlytics())
setContentView(R.layout.activity_main)
setSupportActionBar(topAppBar)
router = Conductor.attachRouter(this, conductorContainer, savedInstanceState)
snackbarProvider.bindRootView(rootView = coordinatorLayout)
}
override fun displayBackButton(show: Boolean) {
supportActionBar?.setDisplayHomeAsUpEnabled(show)
}
override fun hideAll() {
appBar.visibility=Toolbar.INVISIBLE
bottomNavigation.visibility = Toolbar.GONE
val params = coordinatorLayout.layoutParams as CoordinatorLayout.LayoutParams
params.behavior = null
coordinatorLayout.requestLayout()
}
override fun showAll() {
appBar.setExpanded(false,false)
collapsingToolbarLayout.visibility= View.VISIBLE
bottomNavigation.visibility = Toolbar.VISIBLE
appBar.visibility= View.VISIBLE
topAppBar.visibility = View.VISIBLE
val params = coordinatorLayout.layoutParams as CoordinatorLayout.LayoutParams
params.behavior = AppBarLayout.ScrollingViewBehavior()
coordinatorLayout.requestLayout()
}
override fun appBarScrollable(allow: Boolean) {
val params = appBar.layoutParams as CoordinatorLayout.LayoutParams
val behavior = params.behavior as DragControlAppBarLayoutBehaviour
behavior.allowDrag=allow
}
}
package com.biganto.visual.roompark.base
import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import androidx.coordinatorlayout.widget.CoordinatorLayout
import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.appbar.CollapsingToolbarLayout
import com.google.android.material.bottomnavigation.BottomNavigationView
/**
* Created by Vladislav Bogdashkin on 26.09.2019.
*/
interface ISupportActionBar{
val topAppBar : Toolbar
fun displayBackButton(show:Boolean)
fun hideAll()
fun showAll()
}
interface ICollapsingToolBar : ISupportActionBar{
val appBar : AppBarLayout
val coordinatorLayout: CoordinatorLayout
val collapsingToolbarLayout : CollapsingToolbarLayout
fun appBarScrollable(allow:Boolean)
}
interface IConductorActivity{
val conductorContainer: ViewGroup
}
interface IBottomNavigation{
val bottomNavigation : BottomNavigationView
}
......@@ -24,7 +24,6 @@ import io.reactivex.disposables.CompositeDisposable
abstract class BigantoBaseController<VS : BigantoBaseViewState,V: BigantoBaseContract<VS>,P : MviBasePresenter<V,VS>>
: BigantoMviController<V, P> {
constructor():super()
constructor(args: Bundle):super(args)
......@@ -81,7 +80,6 @@ abstract class BigantoBaseController<VS : BigantoBaseViewState,V: BigantoBaseCon
inputMethodManager.hideSoftInputFromWindow(this.windowToken, 0)
}
protected fun View.showKeyboard() {
val inputMethodManager = applicationContext?.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
inputMethodManager.showSoftInput(this, 0)
......@@ -98,8 +96,6 @@ abstract class BigantoBaseController<VS : BigantoBaseViewState,V: BigantoBaseCon
protected val isTablet
get() = resources?.getBoolean(R.bool.isTablet)?:false
protected val catalogSpansCount
get() = resources?.getInteger(R.integer.catalogSpans)?:1
......
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