pull/32/head
kunfei 5 years ago
parent bce9c17fad
commit a692416bbf
  1. 12
      app/src/main/java/io/legado/app/ui/main/explore/FindBookAdapter.kt
  2. 4
      app/src/main/res/layout/item_find_book.xml

@ -1,7 +1,6 @@
package io.legado.app.ui.main.explore
import android.content.Context
import android.graphics.drawable.GradientDrawable
import android.view.LayoutInflater
import android.widget.GridLayout
import io.legado.app.R
@ -9,7 +8,6 @@ import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.base.adapter.SimpleRecyclerAdapter
import io.legado.app.data.entities.BookSource
import io.legado.app.help.coroutine.Coroutine
import io.legado.app.lib.theme.ColorUtils
import io.legado.app.lib.theme.accentColor
import io.legado.app.utils.gone
import io.legado.app.utils.visible
@ -26,8 +24,7 @@ class FindBookAdapter(context: Context, private val scope: CoroutineScope, val c
override fun convert(holder: ItemViewHolder, item: BookSource, payloads: MutableList<Any>) {
with(holder.itemView) {
val bgShape: GradientDrawable? = tv_name.background as? GradientDrawable
bgShape?.setStroke(2, ColorUtils.getRandomColor())
if (payloads.isEmpty()) {
tv_name.text = item.bookSourceName
ll_title.onClick {
val oldEx = exIndex
@ -35,12 +32,14 @@ class FindBookAdapter(context: Context, private val scope: CoroutineScope, val c
exIndex = -1
} else {
exIndex = holder.layoutPosition
notifyItemChanged(holder.layoutPosition)
notifyItemChanged(holder.layoutPosition, false)
}
notifyItemChanged(oldEx)
notifyItemChanged(oldEx, false)
callBack.scrollTo(holder.layoutPosition)
}
}
if (exIndex == holder.layoutPosition) {
iv_status.setImageResource(R.drawable.ic_remove)
rotate_loading.loadingColor = context.accentColor
rotate_loading.show()
Coroutine.async(scope) {
@ -78,6 +77,7 @@ class FindBookAdapter(context: Context, private val scope: CoroutineScope, val c
rotate_loading.hide()
}
} else {
iv_status.setImageResource(R.drawable.ic_add)
rotate_loading.hide()
gl_child.gone()
}

@ -32,8 +32,8 @@
<ImageView
android:id="@+id/iv_status"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/ic_add"
app:tint="@color/tv_text_secondary"
tools:ignore="ContentDescription" />

Loading…
Cancel
Save