From 899a362ea0d8a963960958a5187e1f0e1b677498 Mon Sep 17 00:00:00 2001 From: Administrator Date: Fri, 10 Jan 2020 09:26:57 +0800 Subject: [PATCH] =?UTF-8?q?BadgeView=E6=94=AF=E6=8C=81=E7=BB=98=E5=88=B6?= =?UTF-8?q?=E6=88=90=E4=B8=8A=E5=B9=B3=E8=A7=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/ui/widget/BadgeView.kt | 4 ++++ app/src/main/res/layout/item_bookshelf_grid.xml | 1 + app/src/main/res/values/attrs.xml | 1 + 3 files changed, 6 insertions(+) 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 b644ad5fb..3f1572164 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 @@ -36,6 +36,7 @@ class BadgeView @JvmOverloads constructor( text = text } private var radius: Float = 0.toFloat() + private var flatangle: Boolean val badgeCount: Int? get() { @@ -77,6 +78,8 @@ class BadgeView @JvmOverloads constructor( val typedArray = context.obtainStyledAttributes(attrs, R.styleable.BadgeView) val radios = typedArray.getDimensionPixelOffset(R.styleable.BadgeView_bv_radius, 8) + flatangle = + typedArray.getBoolean(R.styleable.BadgeView_up_flat_angle, false) typedArray.recycle() if (layoutParams !is LayoutParams) { @@ -111,6 +114,7 @@ class BadgeView @JvmOverloads constructor( val radius = dip2Px(dipRadius).toFloat() val radiusArray = floatArrayOf(radius, radius, radius, radius, radius, radius, radius, radius) + if (flatangle) { radiusArray.fill(0f, 0, 3) } val roundRect = RoundRectShape(radiusArray, null, null) val bgDrawable = ShapeDrawable(roundRect) diff --git a/app/src/main/res/layout/item_bookshelf_grid.xml b/app/src/main/res/layout/item_bookshelf_grid.xml index ca639edd4..20d5ab3e2 100644 --- a/app/src/main/res/layout/item_bookshelf_grid.xml +++ b/app/src/main/res/layout/item_bookshelf_grid.xml @@ -56,6 +56,7 @@ android:includeFontPadding="false" android:singleLine="true" app:bv_radius="1dp" + app:up_flat_angle="true" app:layout_constraintLeft_toLeftOf="@id/iv_cover" app:layout_constraintBottom_toBottomOf="@id/iv_cover" tools:ignore="RtlHardcoded" /> diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index de2fe5dc5..297ba1065 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -143,5 +143,6 @@ + \ No newline at end of file