From 84d6447887bab8adc3f2b760f794a73845622f9f Mon Sep 17 00:00:00 2001 From: kubasz Date: Sat, 14 Sep 2019 14:31:12 +0200 Subject: [PATCH] Optimized toolbar code --- .../src/main/java/pl/szczodrzynski/navlib/NavToolbar.kt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/navlib/src/main/java/pl/szczodrzynski/navlib/NavToolbar.kt b/navlib/src/main/java/pl/szczodrzynski/navlib/NavToolbar.kt index e69a70a..1bc8881 100644 --- a/navlib/src/main/java/pl/szczodrzynski/navlib/NavToolbar.kt +++ b/navlib/src/main/java/pl/szczodrzynski/navlib/NavToolbar.kt @@ -7,8 +7,6 @@ import com.google.android.material.appbar.MaterialToolbar class NavToolbar : MaterialToolbar { - var toolbar: MaterialToolbar = this - constructor(context: Context) : super(context) { create(null, 0) } @@ -30,11 +28,11 @@ class NavToolbar : MaterialToolbar { } override fun setSubtitle(subtitle: CharSequence?) { - if(subtitle == null || subtitle.isEmpty()) { - toolbar.setPadding(0, 0, 0, 0) + if(subtitle.isNullOrEmpty()) { + setPadding(0, 0, 0, 0) toolbarImage?.translationY = 0f } else { - toolbar.setPadding(0, -1, 0, 5) + setPadding(0, -1, 0, 5) toolbarImage?.translationY = 6f } super.setSubtitle(subtitle)