From eb16c0ceaa41fe4853063b6775152f01a0b0c763 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 3 Sep 2019 19:29:36 +0800 Subject: [PATCH] up --- .../java/io/legado/app/ui/widget/BadgeView.kt | 20 +++++++++++------- .../legado/app/ui/widget/KeyboardToolPop.kt | 3 ++- .../java/io/legado/app/ui/widget/TitleBar.kt | 21 ++++++++++++++----- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/widget/BadgeView.kt b/app/src/main/java/io/legado/app/ui/widget/BadgeView.kt index aad98f5dd..86e7e0629 100644 --- a/app/src/main/java/io/legado/app/ui/widget/BadgeView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/BadgeView.kt @@ -29,12 +29,6 @@ class BadgeView @JvmOverloads constructor( defStyle: Int = android.R.attr.textViewStyle ) : AppCompatTextView(context, attrs, defStyle) { - /** - * @return Returns true if view is hidden on badge value 0 or null; - */ - /** - * @param hideOnNull the hideOnNull to set - */ var isHideOnNull = true set(hideOnNull) { field = hideOnNull @@ -70,7 +64,12 @@ class BadgeView @JvmOverloads constructor( val badgeMargin: IntArray get() { val params = layoutParams as LayoutParams - return intArrayOf(params.leftMargin, params.topMargin, params.rightMargin, params.bottomMargin) + return intArrayOf( + params.leftMargin, + params.topMargin, + params.rightMargin, + params.bottomMargin + ) } init { @@ -154,7 +153,12 @@ class BadgeView @JvmOverloads constructor( setBadgeMargin(dipMargin, dipMargin, dipMargin, dipMargin) } - fun setBadgeMargin(leftDipMargin: Int, topDipMargin: Int, rightDipMargin: Int, bottomDipMargin: Int) { + fun setBadgeMargin( + leftDipMargin: Int, + topDipMargin: Int, + rightDipMargin: Int, + bottomDipMargin: Int + ) { val params = layoutParams as LayoutParams params.leftMargin = dip2Px(leftDipMargin.toFloat()) params.topMargin = dip2Px(topDipMargin.toFloat()) diff --git a/app/src/main/java/io/legado/app/ui/widget/KeyboardToolPop.kt b/app/src/main/java/io/legado/app/ui/widget/KeyboardToolPop.kt index b97e32e97..076fac6b9 100644 --- a/app/src/main/java/io/legado/app/ui/widget/KeyboardToolPop.kt +++ b/app/src/main/java/io/legado/app/ui/widget/KeyboardToolPop.kt @@ -10,7 +10,8 @@ import android.widget.TextView import io.legado.app.R -class KeyboardToolPop(context: Context, onClickListener: OnClickListener?) : PopupWindow(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) { +class KeyboardToolPop(context: Context, onClickListener: OnClickListener?) : + PopupWindow(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) { init { @SuppressLint("InflateParams") diff --git a/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt b/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt index 796e6fcb3..d516601d9 100644 --- a/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt +++ b/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt @@ -60,7 +60,8 @@ class TitleBar(context: Context, attrs: AttributeSet?) : AppBarLayout(context, a displayHomeAsUp = a.getBoolean(R.styleable.TitleBar_displayHomeAsUp, true) val navigationIcon = a.getDrawable(R.styleable.TitleBar_navigationIcon) - val navigationContentDescription = a.getText(R.styleable.TitleBar_navigationContentDescription) + val navigationContentDescription = + a.getText(R.styleable.TitleBar_navigationContentDescription) val titleText = a.getString(R.styleable.TitleBar_title) val subtitleText = a.getString(R.styleable.TitleBar_subtitle) @@ -71,7 +72,10 @@ class TitleBar(context: Context, attrs: AttributeSet?) : AppBarLayout(context, a } if (a.hasValue(R.styleable.TitleBar_titleTextAppearance)) { - this.setTitleTextAppearance(context, a.getResourceId(R.styleable.TitleBar_titleTextAppearance, 0)) + this.setTitleTextAppearance( + context, + a.getResourceId(R.styleable.TitleBar_titleTextAppearance, 0) + ) } if (a.hasValue(R.styleable.TitleBar_titleTextColor)) { @@ -79,7 +83,10 @@ class TitleBar(context: Context, attrs: AttributeSet?) : AppBarLayout(context, a } if (a.hasValue(R.styleable.TitleBar_subtitleTextAppearance)) { - this.setSubtitleTextAppearance(context, a.getResourceId(R.styleable.TitleBar_subtitleTextAppearance, 0)) + this.setSubtitleTextAppearance( + context, + a.getResourceId(R.styleable.TitleBar_subtitleTextAppearance, 0) + ) } if (a.hasValue(R.styleable.TitleBar_subtitleTextColor)) { @@ -177,7 +184,7 @@ class TitleBar(context: Context, attrs: AttributeSet?) : AppBarLayout(context, a } private fun attachToActivity() { - if(attachToActivity) { + if (attachToActivity) { activity?.let { it.setSupportActionBar(toolbar) it.supportActionBar?.setDisplayHomeAsUpEnabled(displayHomeAsUp) @@ -191,7 +198,11 @@ class TitleBar(context: Context, attrs: AttributeSet?) : AppBarLayout(context, a if (navigationIconTint != null) { wrapDrawableTint(toolbar.navigationIcon, navigationIconTint, navigationIconTintMode) } else { - wrapDrawableTint(toolbar.navigationIcon, ColorStateList.valueOf(primaryTextColor), navigationIconTintMode) + wrapDrawableTint( + toolbar.navigationIcon, + ColorStateList.valueOf(primaryTextColor), + navigationIconTintMode + ) } }