From 57fcac7970808e46139cc681e3b5d8716817e2b2 Mon Sep 17 00:00:00 2001 From: Constantine Date: Sun, 10 Feb 2019 23:22:36 +0300 Subject: [PATCH] New logic of backLayout drawing --- .../backdrop/BackdropBehavior.kt | 5 +---- .../backdropview/ui/MainActivity.kt | 3 +-- sample/src/main/res/layout/activity_main.xml | 20 +++++++++---------- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/backdrop/src/main/kotlin/ru/semper_viventem/backdrop/BackdropBehavior.kt b/backdrop/src/main/kotlin/ru/semper_viventem/backdrop/BackdropBehavior.kt index 899a68d..8e9164c 100644 --- a/backdrop/src/main/kotlin/ru/semper_viventem/backdrop/BackdropBehavior.kt +++ b/backdrop/src/main/kotlin/ru/semper_viventem/backdrop/BackdropBehavior.kt @@ -66,7 +66,7 @@ class BackdropBehavior : CoordinatorLayout.Behavior { } override fun layoutDependsOn(parent: CoordinatorLayout, child: View, dependency: View): Boolean { - if (toolbarId == null || backLayoutId == null) return false + if (toolbarId == null && backLayoutId == null) return false return when (dependency.id) { toolbarId -> true @@ -171,9 +171,6 @@ class BackdropBehavior : CoordinatorLayout.Behavior { // TODO (next release): remove this block if (toolbarId != null) { backLayout.y = toolbar.y + toolbar.height - frontLayout.layoutParams.height = parent.height - toolbar.height - } else { - frontLayout.layoutParams.height = parent.height - (backLayout.y.toInt() + toolbar.y.toInt() + toolbar.height) } drawDropState(frontLayout, toolbar, backLayout, false) diff --git a/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/MainActivity.kt b/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/MainActivity.kt index 6337096..604498c 100644 --- a/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/MainActivity.kt +++ b/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/MainActivity.kt @@ -34,8 +34,7 @@ class MainActivity : AppCompatActivity() { backdropBehavior = foregroundContainer.findBehavior() with(backdropBehavior) { - attachBackContainer(R.id.backContainer) - attachToolbar(R.id.toolbar) + attachBackLayout(R.id.backContainer) } with(toolbar) { setTitle(R.string.app_name) diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml index 31b8a93..d5b96de 100644 --- a/sample/src/main/res/layout/activity_main.xml +++ b/sample/src/main/res/layout/activity_main.xml @@ -9,29 +9,29 @@ android:background="@color/colorPrimary" tools:context=".ui.MainActivity"> - - - + + - +