pull/32/head
kunfei 5 years ago
parent d939276921
commit 0ecdef542e
  1. 8
      app/src/main/java/io/legado/app/ui/search/SearchAdapter.kt
  2. 18
      app/src/main/java/io/legado/app/ui/widget/BadgeView.kt
  3. 12
      app/src/main/res/layout/item_search.xml

@ -49,8 +49,14 @@ class SearchAdapter : PagedListAdapter<SearchShow, SearchAdapter.MyViewHolder>(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()) {

@ -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()
}
}

@ -19,6 +19,14 @@
app:layout_constraintTop_toTopOf="parent"
tools:ignore="UnusedAttribute" />
<io.legado.app.ui.widget.BadgeView
android:id="@+id/bv_originCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintRight_toRightOf="parent" />
<TextView
android:id="@+id/tv_name"
android:layout_width="0dp"
@ -27,7 +35,7 @@
android:singleLine="true"
android:text="@string/app_name"
android:textColor="@color/tv_text_default"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toStartOf="@id/bv_originCount"
app:layout_constraintStart_toEndOf="@+id/iv_cover"
app:layout_constraintTop_toTopOf="parent" />
@ -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" />

Loading…
Cancel
Save