diff --git a/app/src/main/java/io/legado/app/data/entities/BookSource.kt b/app/src/main/java/io/legado/app/data/entities/BookSource.kt index ec306feca..78852a4ec 100644 --- a/app/src/main/java/io/legado/app/data/entities/BookSource.kt +++ b/app/src/main/java/io/legado/app/data/entities/BookSource.kt @@ -182,10 +182,6 @@ data class BookSource( return exploreKinds } - fun showExplore(): Boolean { - return enabledExplore && !exploreUrl.isNullOrEmpty() - } - /** * 执行JS */ diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt index f0d2bb3f0..d7c86fbad 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt @@ -1,7 +1,9 @@ package io.legado.app.ui.book.source.manage import android.content.Context +import android.graphics.Color import android.os.Bundle +import android.widget.ImageView import android.widget.PopupMenu import androidx.core.os.bundleOf import androidx.recyclerview.widget.RecyclerView @@ -11,6 +13,7 @@ import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.data.entities.BookSource import io.legado.app.help.ItemTouchCallback.OnItemTouchCallbackListener import io.legado.app.lib.theme.backgroundColor +import io.legado.app.utils.invisible import io.legado.app.utils.visible import kotlinx.android.synthetic.main.item_book_source.view.* import org.jetbrains.anko.sdk27.listeners.onClick @@ -98,14 +101,14 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : R.id.menu_enable_explore -> { item.enabledExplore = !item.enabledExplore callBack.update(item) - iv_explore.visible(item.showExplore()) + upShowExplore(iv_explore, item) } } true } popupMenu.show() } - iv_explore.visible(item.showExplore()) + upShowExplore(iv_explore, item) } else { payload.keySet().map { when (it) { @@ -117,13 +120,29 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : String.format("%s (%s)", item.bookSourceName, item.bookSourceGroup) } "enabled" -> swt_enabled.isChecked = payload.getBoolean(it) - "showExplore" -> iv_explore.visible(payload.getBoolean(it)) + "showExplore" -> upShowExplore(iv_explore, item) } } } } } + private fun upShowExplore(iv: ImageView, source: BookSource) { + when { + source.exploreUrl.isNullOrEmpty() -> { + iv.invisible() + } + source.enabledExplore -> { + iv.setColorFilter(Color.GREEN) + iv.visible() + } + else -> { + iv.setColorFilter(Color.RED) + iv.visible() + } + } + } + override fun onMove(srcPosition: Int, targetPosition: Int): Boolean { val srcItem = getItem(srcPosition) val targetItem = getItem(targetPosition) diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/DiffCallBack.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/DiffCallBack.kt index 9ed40b625..8810d2dd9 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/DiffCallBack.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/DiffCallBack.kt @@ -32,7 +32,9 @@ class DiffCallBack( return false if (oldItem.enabled != newItem.enabled) return false - if (oldItem.showExplore() != newItem.showExplore()) { + if (oldItem.enabledExplore != newItem.enabledExplore + || oldItem.exploreUrl != newItem.exploreUrl + ) { return false } return true @@ -51,8 +53,10 @@ class DiffCallBack( if (oldItem.enabled != newItem.enabled) { payload.putBoolean("enabled", newItem.enabled) } - if (oldItem.showExplore() != newItem.showExplore()) { - payload.putBoolean("showExplore", newItem.enabledExplore) + if (oldItem.enabledExplore != newItem.enabledExplore + || oldItem.exploreUrl != newItem.exploreUrl + ) { + payload.putBoolean("showExplore", true) } if (payload.isEmpty) { return null