|
|
@ -4,6 +4,7 @@ import android.graphics.drawable.GradientDrawable |
|
|
|
import android.view.LayoutInflater |
|
|
|
import android.view.LayoutInflater |
|
|
|
import android.view.View |
|
|
|
import android.view.View |
|
|
|
import android.view.ViewGroup |
|
|
|
import android.view.ViewGroup |
|
|
|
|
|
|
|
import android.widget.TextView |
|
|
|
import androidx.paging.PagedListAdapter |
|
|
|
import androidx.paging.PagedListAdapter |
|
|
|
import androidx.recyclerview.widget.DiffUtil |
|
|
|
import androidx.recyclerview.widget.DiffUtil |
|
|
|
import androidx.recyclerview.widget.RecyclerView |
|
|
|
import androidx.recyclerview.widget.RecyclerView |
|
|
@ -13,6 +14,7 @@ import io.legado.app.lib.theme.ColorUtils |
|
|
|
import io.legado.app.utils.gone |
|
|
|
import io.legado.app.utils.gone |
|
|
|
import io.legado.app.utils.invisible |
|
|
|
import io.legado.app.utils.invisible |
|
|
|
import kotlinx.android.synthetic.main.item_find_book.view.* |
|
|
|
import kotlinx.android.synthetic.main.item_find_book.view.* |
|
|
|
|
|
|
|
import org.jetbrains.anko.sdk27.listeners.onClick |
|
|
|
|
|
|
|
|
|
|
|
class FindBookAdapter:PagedListAdapter<BookSource, FindBookAdapter.MyViewHolder>(DIFF_CALLBACK) { |
|
|
|
class FindBookAdapter:PagedListAdapter<BookSource, FindBookAdapter.MyViewHolder>(DIFF_CALLBACK) { |
|
|
|
|
|
|
|
|
|
|
@ -33,26 +35,33 @@ class FindBookAdapter:PagedListAdapter<BookSource, FindBookAdapter.MyViewHolder> |
|
|
|
return MyViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.item_find_book, parent, false)) |
|
|
|
return MyViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.item_find_book, parent, false)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onBindViewHolder(holder: MyViewHolder, position: Int) { |
|
|
|
override fun onBindViewHolder(holder: MyViewHolder, position: Int): Unit = |
|
|
|
currentList?.get(position)?.let { |
|
|
|
with(holder.itemView) { |
|
|
|
holder.bind(it, position == exIndex) |
|
|
|
currentList?.get(position)?.let { bookSource -> |
|
|
|
} |
|
|
|
val bgShape: GradientDrawable? = tv_name.background as? GradientDrawable |
|
|
|
} |
|
|
|
bgShape?.setStroke(2, ColorUtils.getRandomColor()) |
|
|
|
|
|
|
|
tv_name.text = bookSource.bookSourceName |
|
|
|
class MyViewHolder(view: View) : RecyclerView.ViewHolder(view) { |
|
|
|
ll_title.onClick { |
|
|
|
|
|
|
|
val oldEx = exIndex |
|
|
|
fun bind(bookSource: BookSource, ex: Boolean) = with(itemView) { |
|
|
|
exIndex = position |
|
|
|
val bgShape: GradientDrawable? = tv_name.background as? GradientDrawable |
|
|
|
notifyItemChanged(oldEx) |
|
|
|
bgShape?.setStroke(2, ColorUtils.getRandomColor()) |
|
|
|
notifyItemChanged(position) |
|
|
|
tv_name.text = bookSource.bookSourceName |
|
|
|
} |
|
|
|
if (ex) { |
|
|
|
if (exIndex == position) { |
|
|
|
gl_child.invisible() |
|
|
|
gl_child.invisible() |
|
|
|
bookSource.getExploreRule().exploreUrl?.let { |
|
|
|
bookSource.getExploreRule().getExploreKinds(bookSource.bookSourceUrl)?.let { |
|
|
|
|
|
|
|
it.map { kind -> |
|
|
|
|
|
|
|
val tv = TextView(context) |
|
|
|
|
|
|
|
tv.text = kind.title |
|
|
|
|
|
|
|
tv.onClick { } |
|
|
|
|
|
|
|
gl_child.addView(tv) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
gl_child.gone() |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
gl_child.gone() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MyViewHolder(view: View) : RecyclerView.ViewHolder(view) |
|
|
|
} |
|
|
|
} |