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

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

Loading…
Cancel
Save