章节换源点赞,UI微调
This commit is contained in:
@@ -6,6 +6,7 @@ import android.os.Bundle
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.appcompat.widget.PopupMenu
|
import androidx.appcompat.widget.PopupMenu
|
||||||
|
import androidx.core.graphics.drawable.DrawableCompat
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.recyclerview.widget.DiffUtil
|
import androidx.recyclerview.widget.DiffUtil
|
||||||
import io.legado.app.R
|
import io.legado.app.R
|
||||||
@@ -13,9 +14,8 @@ import io.legado.app.base.adapter.DiffRecyclerAdapter
|
|||||||
import io.legado.app.base.adapter.ItemViewHolder
|
import io.legado.app.base.adapter.ItemViewHolder
|
||||||
import io.legado.app.data.entities.SearchBook
|
import io.legado.app.data.entities.SearchBook
|
||||||
import io.legado.app.databinding.ItemChangeSourceBinding
|
import io.legado.app.databinding.ItemChangeSourceBinding
|
||||||
import io.legado.app.utils.gone
|
import io.legado.app.utils.*
|
||||||
import io.legado.app.utils.invisible
|
import splitties.init.appCtx
|
||||||
import io.legado.app.utils.visible
|
|
||||||
import splitties.views.onLongClick
|
import splitties.views.onLongClick
|
||||||
|
|
||||||
|
|
||||||
@@ -75,16 +75,18 @@ class ChangeBookSourceAdapter(
|
|||||||
if (score > 0) {
|
if (score > 0) {
|
||||||
binding.ivBad.gone()
|
binding.ivBad.gone()
|
||||||
binding.ivGood.visible()
|
binding.ivGood.visible()
|
||||||
binding.ivGood.drawable.setTint(Color.parseColor("#D50000"))
|
DrawableCompat.setTint(binding.ivGood.drawable, appCtx.getCompatColor(R.color.md_red_A200))
|
||||||
|
DrawableCompat.setTint(binding.ivBad.drawable, appCtx.getCompatColor(R.color.md_blue_100))
|
||||||
} else if (score < 0) {
|
} else if (score < 0) {
|
||||||
binding.ivGood.gone()
|
binding.ivGood.gone()
|
||||||
binding.ivBad.visible()
|
binding.ivBad.visible()
|
||||||
binding.ivBad.drawable.setTint(Color.parseColor("#2962FF"))
|
DrawableCompat.setTint(binding.ivGood.drawable, appCtx.getCompatColor(R.color.md_red_100))
|
||||||
|
DrawableCompat.setTint(binding.ivBad.drawable, appCtx.getCompatColor(R.color.md_blue_A200))
|
||||||
} else {
|
} else {
|
||||||
binding.ivGood.visible()
|
binding.ivGood.visible()
|
||||||
binding.ivBad.visible()
|
binding.ivBad.visible()
|
||||||
binding.ivGood.drawable.setTint(Color.parseColor("#FF8A80"))
|
DrawableCompat.setTint(binding.ivGood.drawable, appCtx.getCompatColor(R.color.md_red_100))
|
||||||
binding.ivBad.drawable.setTint(Color.parseColor("#82B1FF"))
|
DrawableCompat.setTint(binding.ivBad.drawable, appCtx.getCompatColor(R.color.md_blue_100))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,13 +94,13 @@ class ChangeBookSourceAdapter(
|
|||||||
override fun registerListener(holder: ItemViewHolder, binding: ItemChangeSourceBinding) {
|
override fun registerListener(holder: ItemViewHolder, binding: ItemChangeSourceBinding) {
|
||||||
binding.ivGood.setOnClickListener {
|
binding.ivGood.setOnClickListener {
|
||||||
if (binding.ivBad.isVisible) {
|
if (binding.ivBad.isVisible) {
|
||||||
binding.ivGood.drawable.setTint(Color.parseColor("#D50000"))
|
DrawableCompat.setTint(binding.ivGood.drawable, appCtx.getCompatColor(R.color.md_red_A200))
|
||||||
binding.ivBad.gone()
|
binding.ivBad.gone()
|
||||||
getItem(holder.layoutPosition)?.let {
|
getItem(holder.layoutPosition)?.let {
|
||||||
callBack.setBookScore(it, 1)
|
callBack.setBookScore(it, 1)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
binding.ivGood.drawable.setTint(Color.parseColor("#FF8A80"))
|
DrawableCompat.setTint(binding.ivGood.drawable, appCtx.getCompatColor(R.color.md_red_100))
|
||||||
binding.ivBad.visible()
|
binding.ivBad.visible()
|
||||||
getItem(holder.layoutPosition)?.let {
|
getItem(holder.layoutPosition)?.let {
|
||||||
callBack.setBookScore(it, 0)
|
callBack.setBookScore(it, 0)
|
||||||
@@ -107,13 +109,13 @@ class ChangeBookSourceAdapter(
|
|||||||
}
|
}
|
||||||
binding.ivBad.setOnClickListener {
|
binding.ivBad.setOnClickListener {
|
||||||
if (binding.ivGood.isVisible) {
|
if (binding.ivGood.isVisible) {
|
||||||
binding.ivBad.drawable.setTint(Color.parseColor("#2962FF"))
|
DrawableCompat.setTint(binding.ivBad.drawable, appCtx.getCompatColor(R.color.md_blue_A200))
|
||||||
binding.ivGood.gone()
|
binding.ivGood.gone()
|
||||||
getItem(holder.layoutPosition)?.let {
|
getItem(holder.layoutPosition)?.let {
|
||||||
callBack.setBookScore(it, -1)
|
callBack.setBookScore(it, -1)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
binding.ivBad.drawable.setTint(Color.parseColor("#82B1FF"))
|
DrawableCompat.setTint(binding.ivBad.drawable, appCtx.getCompatColor(R.color.md_blue_100))
|
||||||
binding.ivGood.visible()
|
binding.ivGood.visible()
|
||||||
getItem(holder.layoutPosition)?.let {
|
getItem(holder.layoutPosition)?.let {
|
||||||
callBack.setBookScore(it, 0)
|
callBack.setBookScore(it, 0)
|
||||||
|
|||||||
@@ -5,14 +5,19 @@ import android.os.Bundle
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.appcompat.widget.PopupMenu
|
import androidx.appcompat.widget.PopupMenu
|
||||||
|
import androidx.core.graphics.drawable.DrawableCompat
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.recyclerview.widget.DiffUtil
|
import androidx.recyclerview.widget.DiffUtil
|
||||||
import io.legado.app.R
|
import io.legado.app.R
|
||||||
import io.legado.app.base.adapter.DiffRecyclerAdapter
|
import io.legado.app.base.adapter.DiffRecyclerAdapter
|
||||||
import io.legado.app.base.adapter.ItemViewHolder
|
import io.legado.app.base.adapter.ItemViewHolder
|
||||||
import io.legado.app.data.entities.SearchBook
|
import io.legado.app.data.entities.SearchBook
|
||||||
import io.legado.app.databinding.ItemChangeSourceBinding
|
import io.legado.app.databinding.ItemChangeSourceBinding
|
||||||
|
import io.legado.app.utils.getCompatColor
|
||||||
|
import io.legado.app.utils.gone
|
||||||
import io.legado.app.utils.invisible
|
import io.legado.app.utils.invisible
|
||||||
import io.legado.app.utils.visible
|
import io.legado.app.utils.visible
|
||||||
|
import splitties.init.appCtx
|
||||||
import splitties.views.onLongClick
|
import splitties.views.onLongClick
|
||||||
|
|
||||||
|
|
||||||
@@ -68,10 +73,57 @@ class ChangeChapterSourceAdapter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
val score = callBack.getBookScore(item)
|
||||||
|
if (score > 0) {
|
||||||
|
binding.ivBad.gone()
|
||||||
|
binding.ivGood.visible()
|
||||||
|
DrawableCompat.setTint(binding.ivGood.drawable, appCtx.getCompatColor(R.color.md_red_A200))
|
||||||
|
DrawableCompat.setTint(binding.ivBad.drawable, appCtx.getCompatColor(R.color.md_blue_100))
|
||||||
|
} else if (score < 0) {
|
||||||
|
binding.ivGood.gone()
|
||||||
|
binding.ivBad.visible()
|
||||||
|
DrawableCompat.setTint(binding.ivGood.drawable, appCtx.getCompatColor(R.color.md_red_100))
|
||||||
|
DrawableCompat.setTint(binding.ivBad.drawable, appCtx.getCompatColor(R.color.md_blue_A200))
|
||||||
|
} else {
|
||||||
|
binding.ivGood.visible()
|
||||||
|
binding.ivBad.visible()
|
||||||
|
DrawableCompat.setTint(binding.ivGood.drawable, appCtx.getCompatColor(R.color.md_red_100))
|
||||||
|
DrawableCompat.setTint(binding.ivBad.drawable, appCtx.getCompatColor(R.color.md_blue_100))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun registerListener(holder: ItemViewHolder, binding: ItemChangeSourceBinding) {
|
override fun registerListener(holder: ItemViewHolder, binding: ItemChangeSourceBinding) {
|
||||||
|
binding.ivGood.setOnClickListener {
|
||||||
|
if (binding.ivBad.isVisible) {
|
||||||
|
DrawableCompat.setTint(binding.ivGood.drawable, appCtx.getCompatColor(R.color.md_red_A200))
|
||||||
|
binding.ivBad.gone()
|
||||||
|
getItem(holder.layoutPosition)?.let {
|
||||||
|
callBack.setBookScore(it, 1)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DrawableCompat.setTint(binding.ivGood.drawable, appCtx.getCompatColor(R.color.md_red_100))
|
||||||
|
binding.ivBad.visible()
|
||||||
|
getItem(holder.layoutPosition)?.let {
|
||||||
|
callBack.setBookScore(it, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
binding.ivBad.setOnClickListener {
|
||||||
|
if (binding.ivGood.isVisible) {
|
||||||
|
DrawableCompat.setTint(binding.ivBad.drawable, appCtx.getCompatColor(R.color.md_blue_A200))
|
||||||
|
binding.ivGood.gone()
|
||||||
|
getItem(holder.layoutPosition)?.let {
|
||||||
|
callBack.setBookScore(it, -1)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DrawableCompat.setTint(binding.ivBad.drawable, appCtx.getCompatColor(R.color.md_blue_100))
|
||||||
|
binding.ivGood.visible()
|
||||||
|
getItem(holder.layoutPosition)?.let {
|
||||||
|
callBack.setBookScore(it, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
holder.itemView.setOnClickListener {
|
holder.itemView.setOnClickListener {
|
||||||
getItem(holder.layoutPosition)?.let {
|
getItem(holder.layoutPosition)?.let {
|
||||||
callBack.openToc(it)
|
callBack.openToc(it)
|
||||||
@@ -118,5 +170,7 @@ class ChangeChapterSourceAdapter(
|
|||||||
fun editSource(searchBook: SearchBook)
|
fun editSource(searchBook: SearchBook)
|
||||||
fun disableSource(searchBook: SearchBook)
|
fun disableSource(searchBook: SearchBook)
|
||||||
fun deleteSource(searchBook: SearchBook)
|
fun deleteSource(searchBook: SearchBook)
|
||||||
|
fun setBookScore(searchBook: SearchBook, score: Int)
|
||||||
|
fun getBookScore(searchBook: SearchBook): Int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -314,6 +314,14 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun setBookScore(searchBook: SearchBook, score: Int) {
|
||||||
|
viewModel.setBookScore(searchBook, score)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getBookScore(searchBook: SearchBook): Int {
|
||||||
|
return viewModel.getBookScore(searchBook)
|
||||||
|
}
|
||||||
|
|
||||||
override fun clickChapter(bookChapter: BookChapter, nextChapterUrl: String?) {
|
override fun clickChapter(bookChapter: BookChapter, nextChapterUrl: String?) {
|
||||||
searchBook?.let {
|
searchBook?.let {
|
||||||
binding.loadingToc.show()
|
binding.loadingToc.show()
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatImageView
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
android:id="@+id/iv_good"
|
android:id="@+id/iv_good"
|
||||||
android:layout_width="40dp"
|
android:layout_width="30dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
@@ -17,11 +17,11 @@
|
|||||||
app:layout_constraintBottom_toTopOf="@+id/iv_bad"
|
app:layout_constraintBottom_toTopOf="@+id/iv_bad"
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:tint="@color/md_red_50" />
|
app:tint="@color/md_red_A200" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatImageView
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
android:id="@+id/iv_bad"
|
android:id="@+id/iv_bad"
|
||||||
android:layout_width="40dp"
|
android:layout_width="30dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginBottom="5dp"
|
android:layout_marginBottom="5dp"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
@@ -30,13 +30,13 @@
|
|||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/iv_good"
|
app:layout_constraintTop_toBottomOf="@+id/iv_good"
|
||||||
app:tint="@color/md_blue_50" />
|
app:tint="@color/md_blue_A200" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_origin"
|
android:id="@+id/tv_origin"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="40dp"
|
android:layout_marginLeft="30dp"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:textColor="@color/primaryText"
|
android:textColor="@color/primaryText"
|
||||||
@@ -59,7 +59,7 @@
|
|||||||
android:id="@+id/tv_last"
|
android:id="@+id/tv_last"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="40dp"
|
android:layout_marginLeft="30dp"
|
||||||
android:layout_marginBottom="10dp"
|
android:layout_marginBottom="10dp"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:textColor="@color/secondaryText"
|
android:textColor="@color/secondaryText"
|
||||||
|
|||||||
Reference in New Issue
Block a user