diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterGrid.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterGrid.kt index 92a47d790..3752b2452 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterGrid.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterGrid.kt @@ -1,6 +1,7 @@ package io.legado.app.ui.main.bookshelf.books import android.content.Context +import android.os.Bundle import io.legado.app.R import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.constant.BookType @@ -15,8 +16,9 @@ class BooksAdapterGrid(context: Context, private val callBack: CallBack) : BaseBooksAdapter(context, R.layout.item_bookshelf_grid) { override fun convert(holder: ItemViewHolder, item: Book, payloads: MutableList) { + val bundle = payloads.getOrNull(0) as? Bundle with(holder.itemView) { - if (payloads.isEmpty()) { + if (bundle == null) { ATH.applyBackgroundTint(this) tv_name.text = item.name bv_author.text = item.author @@ -35,9 +37,12 @@ class BooksAdapterGrid(context: Context, private val callBack: CallBack) : bv_unread.setHighlight(item.lastCheckCount > 0) } } else { - when (payloads[0]) { - 5 -> { - if (item.origin != BookType.local && callBack.isUpdate(item.bookUrl)) { + bundle.keySet().map { + when (it) { + "name" -> tv_name.text = item.name + "author" -> bv_author.text = item.author + "cover" -> iv_cover.load(item.getDisplayCover(), item.name, item.author) + "refresh" -> if (item.origin != BookType.local && callBack.isUpdate(item.bookUrl)) { bv_unread.invisible() rl_loading.show() } else { diff --git a/app/src/main/java/io/legado/app/ui/widget/DetailSeekBar.kt b/app/src/main/java/io/legado/app/ui/widget/DetailSeekBar.kt new file mode 100644 index 000000000..00d790474 --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/widget/DetailSeekBar.kt @@ -0,0 +1,57 @@ +package io.legado.app.ui.widget + +import android.content.Context +import android.util.AttributeSet +import android.view.Gravity +import android.view.View +import android.widget.SeekBar +import androidx.appcompat.widget.LinearLayoutCompat +import io.legado.app.R +import io.legado.app.utils.progressAdd +import kotlinx.android.synthetic.main.view_detail_seek_bar.view.* +import org.jetbrains.anko.sdk27.listeners.onClick + +class DetailSeekBar(context: Context, attrs: AttributeSet?) : LinearLayoutCompat(context, attrs), + SeekBar.OnSeekBarChangeListener { + + private var valueFormat: String? = null + private var onChanged: ((progress: Int) -> Unit)? = null + val progress: Int + get() = seek_bar.progress + + init { + gravity = Gravity.CENTER_VERTICAL + View.inflate(context, R.layout.view_detail_seek_bar, this) + + val typedArray = context.obtainStyledAttributes(attrs, R.styleable.DetailSeekBar) + tv_seek_title.text = typedArray.getText(R.styleable.DetailSeekBar_title) + typedArray.recycle() + + iv_seek_add.onClick { + seek_bar.progressAdd(1) + onChanged?.invoke(seek_bar.progress) + } + iv_seek_remove.onClick { + seek_bar.progressAdd(-1) + onChanged?.invoke(seek_bar.progress) + } + seek_bar.setOnSeekBarChangeListener(this) + } + + private fun upValue() { + + } + + override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) { + + } + + override fun onStartTrackingTouch(seekBar: SeekBar?) { + + } + + override fun onStopTrackingTouch(seekBar: SeekBar?) { + onChanged?.invoke(seek_bar.progress) + } + +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/widget/ViewDetailSeekBar.kt b/app/src/main/java/io/legado/app/ui/widget/ViewDetailSeekBar.kt deleted file mode 100644 index 507b7a9da..000000000 --- a/app/src/main/java/io/legado/app/ui/widget/ViewDetailSeekBar.kt +++ /dev/null @@ -1,2 +0,0 @@ -package io.legado.app.ui.widget - diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index 297ba1065..e3ca97f5a 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -65,6 +65,10 @@ + + + +