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