From 0ecdef542edf664f45069fbe3e19b53ad404e9d8 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 7 Aug 2019 09:11:53 +0800 Subject: [PATCH] up --- .../io/legado/app/ui/search/SearchAdapter.kt | 8 +++++++- .../java/io/legado/app/ui/widget/BadgeView.kt | 18 +++++++++--------- app/src/main/res/layout/item_search.xml | 12 ++++++++++-- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/search/SearchAdapter.kt b/app/src/main/java/io/legado/app/ui/search/SearchAdapter.kt index 2c46fd479..66b55595d 100644 --- a/app/src/main/java/io/legado/app/ui/search/SearchAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/search/SearchAdapter.kt @@ -49,8 +49,14 @@ class SearchAdapter : PagedListAdapter(D fun bind(searchBook: SearchShow, callBack: CallBack?) = with(itemView) { tv_name.text = searchBook.name + bv_originCount.setBadgeCount(searchBook.originCount) tv_author.text = searchBook.author - tv_lasted.text = context.getString(R.string.book_search_last, searchBook.latestChapterTitle) + if (searchBook.latestChapterTitle.isNullOrEmpty()) { + tv_lasted.gone() + } else { + tv_lasted.text = context.getString(R.string.book_search_last, searchBook.latestChapterTitle) + tv_lasted.visible() + } tv_introduce.text = searchBook.intro val kinds = searchBook.getKindList() if (kinds.isEmpty()) { 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 5f09a8744..aad98f5dd 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 @@ -15,6 +15,9 @@ import android.widget.FrameLayout.LayoutParams import android.widget.TabWidget import androidx.appcompat.widget.AppCompatTextView import io.legado.app.R +import io.legado.app.lib.theme.accentColor +import io.legado.app.utils.gone +import io.legado.app.utils.visible /** @@ -71,11 +74,6 @@ class BadgeView @JvmOverloads constructor( } init { - - init() - } - - private fun init() { if (layoutParams !is LayoutParams) { val layoutParams = LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, @@ -93,7 +91,7 @@ class BadgeView @JvmOverloads constructor( radius = 8f // set default background - setBackground(radius, Color.parseColor("#d3321b")) + setBackground(radius, context.accentColor) gravity = Gravity.CENTER @@ -132,9 +130,9 @@ class BadgeView @JvmOverloads constructor( */ override fun setText(text: CharSequence, type: BufferType) { if (isHideOnNull && TextUtils.isEmpty(text)) { - visibility = View.GONE + gone() } else { - visibility = View.VISIBLE + visible() } super.setText(text, type) } @@ -142,7 +140,9 @@ class BadgeView @JvmOverloads constructor( fun setBadgeCount(count: Int) { text = count.toString() if (count == 0) { - visibility = View.GONE + gone() + } else { + visible() } } diff --git a/app/src/main/res/layout/item_search.xml b/app/src/main/res/layout/item_search.xml index ec2466f7f..4a71b3049 100644 --- a/app/src/main/res/layout/item_search.xml +++ b/app/src/main/res/layout/item_search.xml @@ -19,6 +19,14 @@ app:layout_constraintTop_toTopOf="parent" tools:ignore="UnusedAttribute" /> + + @@ -46,7 +54,7 @@ android:layout_height="wrap_content" android:ellipsize="end" android:lines="1" - android:drawableLeft="@drawable/ic_author" + android:drawableStart="@drawable/ic_author" android:text="@string/author" android:textColor="@color/tv_text_default" android:textSize="12sp" />