|
|
@ -145,11 +145,8 @@ class TitleBar(context: Context, attrs: AttributeSet?) : AppBarLayout(context, a |
|
|
|
|
|
|
|
|
|
|
|
override fun onAttachedToWindow() { |
|
|
|
override fun onAttachedToWindow() { |
|
|
|
super.onAttachedToWindow() |
|
|
|
super.onAttachedToWindow() |
|
|
|
if (attachToActivity) { |
|
|
|
|
|
|
|
attachToActivity() |
|
|
|
attachToActivity() |
|
|
|
} |
|
|
|
} |
|
|
|
wrapTheme() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun setNavigationOnClickListener(clickListener: ((View) -> Unit)) { |
|
|
|
fun setNavigationOnClickListener(clickListener: ((View) -> Unit)) { |
|
|
|
toolbar.setNavigationOnClickListener(clickListener) |
|
|
|
toolbar.setNavigationOnClickListener(clickListener) |
|
|
@ -179,7 +176,14 @@ class TitleBar(context: Context, attrs: AttributeSet?) : AppBarLayout(context, a |
|
|
|
toolbar.setSubtitleTextAppearance(context, resId) |
|
|
|
toolbar.setSubtitleTextAppearance(context, resId) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun wrapTheme() { |
|
|
|
private fun attachToActivity() { |
|
|
|
|
|
|
|
if(attachToActivity) { |
|
|
|
|
|
|
|
activity?.let { |
|
|
|
|
|
|
|
it.setSupportActionBar(toolbar) |
|
|
|
|
|
|
|
it.supportActionBar?.setDisplayHomeAsUpEnabled(displayHomeAsUp) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
val primaryTextColor = if (isInEditMode) Color.BLACK else context.primaryTextColor |
|
|
|
val primaryTextColor = if (isInEditMode) Color.BLACK else context.primaryTextColor |
|
|
|
DrawableUtils.setTint(toolbar.overflowIcon, primaryTextColor) |
|
|
|
DrawableUtils.setTint(toolbar.overflowIcon, primaryTextColor) |
|
|
|
toolbar.setTitleTextColor(primaryTextColor) |
|
|
|
toolbar.setTitleTextColor(primaryTextColor) |
|
|
@ -191,13 +195,6 @@ class TitleBar(context: Context, attrs: AttributeSet?) : AppBarLayout(context, a |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun attachToActivity() { |
|
|
|
|
|
|
|
activity?.let { |
|
|
|
|
|
|
|
it.setSupportActionBar(toolbar) |
|
|
|
|
|
|
|
it.supportActionBar?.setDisplayHomeAsUpEnabled(displayHomeAsUp) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun wrapDrawableTint(drawable: Drawable?, tintList: ColorStateList?, tintMode: Int) { |
|
|
|
private fun wrapDrawableTint(drawable: Drawable?, tintList: ColorStateList?, tintMode: Int) { |
|
|
|
if (drawable == null || tintList == null) return |
|
|
|
if (drawable == null || tintList == null) return |
|
|
|
val wrappedDrawable = DrawableCompat.wrap(drawable.mutate()) |
|
|
|
val wrappedDrawable = DrawableCompat.wrap(drawable.mutate()) |
|
|
|