From 0fb66e8ce2407dcbc7787827a61b622bb2c71381 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 14 Feb 2020 16:17:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/data/entities/BookSource.kt | 4 +++ .../book/source/manage/BookSourceAdapter.kt | 12 +++++++ .../app/ui/book/source/manage/DiffCallBack.kt | 3 ++ app/src/main/res/layout/item_book_source.xml | 35 ++++++++++++++----- 4 files changed, 46 insertions(+), 8 deletions(-) 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 78852a4ec..ec306feca 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,6 +182,10 @@ 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 a213f8f97..ed823839a 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 @@ -11,6 +11,8 @@ 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 import java.util.* @@ -89,6 +91,11 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : } popupMenu.show() } + if (item.showExplore()) { + iv_explore.visible() + } else { + iv_explore.invisible() + } } else { payload.keySet().map { when (it) { @@ -100,6 +107,11 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : String.format("%s (%s)", item.bookSourceName, item.bookSourceGroup) } "enabled" -> swt_enabled.isChecked = payload.getBoolean(it) + "showExplore" -> if (payload.getBoolean(it)) { + iv_explore.visible() + } else { + iv_explore.invisible() + } } } } 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 da0d1292e..cdb56bc48 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 @@ -48,6 +48,9 @@ class DiffCallBack( if (oldItem.enabled != newItem.enabled) { payload.putBoolean("enabled", newItem.enabled) } + if (oldItem.showExplore() != newItem.showExplore()) { + payload.putBoolean("showExplore", newItem.enabledExplore) + } if (payload.isEmpty) { return null } diff --git a/app/src/main/res/layout/item_book_source.xml b/app/src/main/res/layout/item_book_source.xml index 7d9513d98..ee1174355 100644 --- a/app/src/main/res/layout/item_book_source.xml +++ b/app/src/main/res/layout/item_book_source.xml @@ -1,11 +1,10 @@ - + android:textColor="@color/tv_text_default" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintRight_toLeftOf="@id/swt_enabled" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" /> + tools:ignore="RtlSymmetry" + app:layout_constraintRight_toLeftOf="@id/iv_edit" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" /> + android:tint="@color/tv_text_default" + app:layout_constraintRight_toLeftOf="@id/iv_menu_more" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" /> - \ No newline at end of file + + + \ No newline at end of file