diff --git a/app/src/main/java/io/legado/app/base/adapter/SimpleRecyclerAdapter.kt b/app/src/main/java/io/legado/app/base/adapter/DiffRecyclerAdapter.kt similarity index 93% rename from app/src/main/java/io/legado/app/base/adapter/SimpleRecyclerAdapter.kt rename to app/src/main/java/io/legado/app/base/adapter/DiffRecyclerAdapter.kt index f8c5e7e85..ea96c3b61 100644 --- a/app/src/main/java/io/legado/app/base/adapter/SimpleRecyclerAdapter.kt +++ b/app/src/main/java/io/legado/app/base/adapter/DiffRecyclerAdapter.kt @@ -15,7 +15,7 @@ import kotlin.collections.ArrayList * Created by Invincible on 2017/12/15. */ @Suppress("unused") -abstract class SimpleRecyclerAdapter(protected val context: Context) : +abstract class DiffRecyclerAdapter(protected val context: Context) : RecyclerView.Adapter() { val inflater: LayoutInflater = LayoutInflater.from(context) @@ -31,18 +31,7 @@ abstract class SimpleRecyclerAdapter(protected val conte var itemAnimation: ItemAnimation? = null - open val diffItemCallback: DiffUtil.ItemCallback = - object : DiffUtil.ItemCallback() { - - override fun areItemsTheSame(oldItem: ITEM, newItem: ITEM): Boolean { - return false - } - - override fun areContentsTheSame(oldItem: ITEM, newItem: ITEM): Boolean { - return true - } - - } + abstract val diffItemCallback: DiffUtil.ItemCallback fun setOnItemClickListener(listener: (holder: ItemViewHolder, item: ITEM) -> Unit) { itemClickListener = listener diff --git a/app/src/main/java/io/legado/app/ui/about/ReadRecordActivity.kt b/app/src/main/java/io/legado/app/ui/about/ReadRecordActivity.kt index 58d2cd1a3..45659854b 100644 --- a/app/src/main/java/io/legado/app/ui/about/ReadRecordActivity.kt +++ b/app/src/main/java/io/legado/app/ui/about/ReadRecordActivity.kt @@ -8,8 +8,8 @@ import android.view.ViewGroup import io.legado.app.App import io.legado.app.R import io.legado.app.base.BaseActivity +import io.legado.app.base.adapter.CommonRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.data.entities.ReadRecordShow import io.legado.app.databinding.ActivityReadRecordBinding import io.legado.app.databinding.ItemReadRecordBinding @@ -92,7 +92,7 @@ class ReadRecordActivity : BaseActivity() { } inner class RecordAdapter(context: Context) : - SimpleRecyclerAdapter(context) { + CommonRecyclerAdapter(context) { override fun getViewBinding(parent: ViewGroup): ItemReadRecordBinding { return ItemReadRecordBinding.inflate(inflater, parent, false) diff --git a/app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt b/app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt index ef89a5097..d37c1cc3a 100644 --- a/app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt @@ -12,8 +12,8 @@ import androidx.appcompat.widget.Toolbar import androidx.recyclerview.widget.LinearLayoutManager import io.legado.app.R import io.legado.app.base.BaseDialogFragment +import io.legado.app.base.adapter.CommonRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.constant.PreferKey import io.legado.app.data.entities.BookSource import io.legado.app.databinding.DialogEditTextBinding @@ -126,7 +126,7 @@ class ImportBookSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickList } inner class SourcesAdapter(context: Context) : - SimpleRecyclerAdapter(context) { + CommonRecyclerAdapter(context) { override fun getViewBinding(parent: ViewGroup): ItemSourceImportBinding { return ItemSourceImportBinding.inflate(inflater, parent, false) diff --git a/app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt b/app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt index 9753ac7f0..7c3fa1591 100644 --- a/app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt @@ -12,8 +12,8 @@ import androidx.appcompat.widget.Toolbar import androidx.recyclerview.widget.LinearLayoutManager import io.legado.app.R import io.legado.app.base.BaseDialogFragment +import io.legado.app.base.adapter.CommonRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.constant.PreferKey import io.legado.app.data.entities.RssSource import io.legado.app.databinding.DialogEditTextBinding @@ -126,7 +126,7 @@ class ImportRssSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListe } inner class SourcesAdapter(context: Context) : - SimpleRecyclerAdapter(context) { + CommonRecyclerAdapter(context) { override fun getViewBinding(parent: ViewGroup): ItemSourceImportBinding { return ItemSourceImportBinding.inflate(inflater, parent, false) diff --git a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookAdapter.kt b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookAdapter.kt index af566ed2c..afb865e24 100644 --- a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookAdapter.kt @@ -5,8 +5,8 @@ import android.view.View import android.view.ViewGroup import androidx.core.os.bundleOf import androidx.recyclerview.widget.RecyclerView +import io.legado.app.base.adapter.CommonRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookGroup import io.legado.app.databinding.ItemArrangeBookBinding @@ -18,7 +18,8 @@ import org.jetbrains.anko.sdk27.listeners.onClick import java.util.* class ArrangeBookAdapter(context: Context, val callBack: CallBack) : - SimpleRecyclerAdapter(context), + CommonRecyclerAdapter(context), + ItemTouchCallback.Callback { val groupRequestCode = 12 private val selectedBooks: HashSet = hashSetOf() diff --git a/app/src/main/java/io/legado/app/ui/book/cache/CacheAdapter.kt b/app/src/main/java/io/legado/app/ui/book/cache/CacheAdapter.kt index e28572e93..d936f0d17 100644 --- a/app/src/main/java/io/legado/app/ui/book/cache/CacheAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/cache/CacheAdapter.kt @@ -4,8 +4,8 @@ import android.content.Context import android.view.ViewGroup import android.widget.ImageView import io.legado.app.R +import io.legado.app.base.adapter.CommonRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter import io.legado.app.databinding.ItemDownloadBinding @@ -16,7 +16,7 @@ import java.util.concurrent.CopyOnWriteArraySet class CacheAdapter(context: Context, private val callBack: CallBack) : - SimpleRecyclerAdapter(context) { + CommonRecyclerAdapter(context) { val cacheChapters = hashMapOf>() var downloadMap: ConcurrentHashMap>? = null diff --git a/app/src/main/java/io/legado/app/ui/book/changecover/CoverAdapter.kt b/app/src/main/java/io/legado/app/ui/book/changecover/CoverAdapter.kt index 6132ca3dd..6801e0ebc 100644 --- a/app/src/main/java/io/legado/app/ui/book/changecover/CoverAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/changecover/CoverAdapter.kt @@ -3,14 +3,14 @@ package io.legado.app.ui.book.changecover import android.content.Context import android.view.ViewGroup import androidx.recyclerview.widget.DiffUtil +import io.legado.app.base.adapter.DiffRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.data.entities.SearchBook import io.legado.app.databinding.ItemCoverBinding import org.jetbrains.anko.sdk27.listeners.onClick class CoverAdapter(context: Context, val callBack: CallBack) : - SimpleRecyclerAdapter(context) { + DiffRecyclerAdapter(context) { override val diffItemCallback: DiffUtil.ItemCallback get() = object : DiffUtil.ItemCallback() { diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt index 48a9dfcc1..2db9cb239 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt @@ -7,8 +7,8 @@ import android.view.ViewGroup import androidx.appcompat.widget.PopupMenu import androidx.recyclerview.widget.DiffUtil import io.legado.app.R +import io.legado.app.base.adapter.DiffRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.data.entities.SearchBook import io.legado.app.databinding.ItemChangeSourceBinding import io.legado.app.utils.invisible @@ -18,7 +18,7 @@ import org.jetbrains.anko.sdk27.listeners.onLongClick class ChangeSourceAdapter(context: Context, val callBack: CallBack) : - SimpleRecyclerAdapter(context) { + DiffRecyclerAdapter(context) { override val diffItemCallback: DiffUtil.ItemCallback get() = object : DiffUtil.ItemCallback() { diff --git a/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt b/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt index d0d237f7d..0e93876d9 100644 --- a/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt @@ -16,8 +16,8 @@ import androidx.recyclerview.widget.RecyclerView import io.legado.app.App import io.legado.app.R import io.legado.app.base.BaseDialogFragment +import io.legado.app.base.adapter.DiffRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.data.entities.BookGroup import io.legado.app.databinding.DialogEditTextBinding import io.legado.app.databinding.DialogRecyclerViewBinding @@ -137,7 +137,7 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener } private inner class GroupAdapter(context: Context) : - SimpleRecyclerAdapter(context), + DiffRecyclerAdapter(context), ItemTouchCallback.Callback { private var isMoved = false diff --git a/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt b/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt index b341e6db9..23f4d6cb5 100644 --- a/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt @@ -15,8 +15,8 @@ import androidx.recyclerview.widget.RecyclerView import io.legado.app.App import io.legado.app.R import io.legado.app.base.BaseDialogFragment +import io.legado.app.base.adapter.CommonRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.data.entities.BookGroup import io.legado.app.databinding.DialogBookGroupPickerBinding import io.legado.app.databinding.DialogEditTextBinding @@ -152,7 +152,7 @@ class GroupSelectDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener } private inner class GroupAdapter(context: Context) : - SimpleRecyclerAdapter(context), + CommonRecyclerAdapter(context), ItemTouchCallback.Callback { private var isMoved: Boolean = false diff --git a/app/src/main/java/io/legado/app/ui/book/info/ChapterListAdapter.kt b/app/src/main/java/io/legado/app/ui/book/info/ChapterListAdapter.kt index 38a8c37e2..a7ad5ef6b 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/ChapterListAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/ChapterListAdapter.kt @@ -3,8 +3,8 @@ package io.legado.app.ui.book.info import android.content.Context import android.view.ViewGroup import io.legado.app.R +import io.legado.app.base.adapter.CommonRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.data.entities.BookChapter import io.legado.app.databinding.ItemChapterListBinding import io.legado.app.lib.theme.accentColor @@ -12,7 +12,7 @@ import org.jetbrains.anko.sdk27.listeners.onClick import org.jetbrains.anko.textColorResource class ChapterListAdapter(context: Context, var callBack: CallBack) : - SimpleRecyclerAdapter(context) { + CommonRecyclerAdapter(context) { override fun getViewBinding(parent: ViewGroup): ItemChapterListBinding { return ItemChapterListBinding.inflate(inflater, parent, false) diff --git a/app/src/main/java/io/legado/app/ui/book/read/TextActionMenu.kt b/app/src/main/java/io/legado/app/ui/book/read/TextActionMenu.kt index 5d0946903..48c74e2bd 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/TextActionMenu.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/TextActionMenu.kt @@ -19,8 +19,8 @@ import androidx.appcompat.view.menu.MenuBuilder import androidx.appcompat.view.menu.MenuItemImpl import androidx.core.view.isVisible import io.legado.app.R +import io.legado.app.base.adapter.CommonRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.databinding.ItemTextBinding import io.legado.app.databinding.PopupActionMenuBinding import io.legado.app.service.BaseReadAloudService @@ -89,7 +89,7 @@ class TextActionMenu(private val context: Context, private val callBack: CallBac } inner class Adapter(context: Context) : - SimpleRecyclerAdapter(context) { + CommonRecyclerAdapter(context) { override fun getViewBinding(parent: ViewGroup): ItemTextBinding { return ItemTextBinding.inflate(inflater, parent, false) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineDialog.kt index 43d09c391..92c857d99 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineDialog.kt @@ -13,8 +13,8 @@ import androidx.recyclerview.widget.LinearLayoutManager import io.legado.app.App import io.legado.app.R import io.legado.app.base.BaseDialogFragment +import io.legado.app.base.adapter.CommonRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.constant.PreferKey import io.legado.app.data.entities.HttpTTS import io.legado.app.databinding.DialogHttpTtsEditBinding @@ -128,7 +128,7 @@ class SpeakEngineDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener } inner class Adapter(context: Context) : - SimpleRecyclerAdapter(context) { + CommonRecyclerAdapter(context) { override fun getViewBinding(parent: ViewGroup): ItemHttpTtsBinding { return ItemHttpTtsBinding.inflate(inflater, parent, false) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt index 9899a5378..1c4252c3c 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt @@ -17,8 +17,8 @@ import com.google.android.material.snackbar.Snackbar import io.legado.app.App import io.legado.app.R import io.legado.app.base.BaseDialogFragment +import io.legado.app.base.adapter.CommonRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.data.entities.TxtTocRule import io.legado.app.databinding.DialogEditTextBinding import io.legado.app.databinding.DialogTocRegexBinding @@ -189,7 +189,7 @@ class TocRegexDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener { } inner class TocRegexAdapter(context: Context) : - SimpleRecyclerAdapter(context), + CommonRecyclerAdapter(context), ItemTouchCallback.Callback { override fun getViewBinding(parent: ViewGroup): ItemTocRegexBinding { diff --git a/app/src/main/java/io/legado/app/ui/book/search/HistoryKeyAdapter.kt b/app/src/main/java/io/legado/app/ui/book/search/HistoryKeyAdapter.kt index 5500573ac..7417c16c3 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/HistoryKeyAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/HistoryKeyAdapter.kt @@ -2,8 +2,8 @@ package io.legado.app.ui.book.search import android.view.ViewGroup import io.legado.app.App +import io.legado.app.base.adapter.CommonRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.data.entities.SearchKeyword import io.legado.app.databinding.ItemFilletTextBinding import io.legado.app.ui.widget.anima.explosion_field.ExplosionField @@ -15,7 +15,7 @@ import org.jetbrains.anko.sdk27.listeners.onLongClick class HistoryKeyAdapter(activity: SearchActivity, val callBack: CallBack) : - SimpleRecyclerAdapter(activity) { + CommonRecyclerAdapter(activity) { private val explosionField = ExplosionField.attach2Window(activity) diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt index c3d77b2fe..732a5de4e 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt @@ -5,8 +5,8 @@ import android.os.Bundle import android.view.ViewGroup import androidx.recyclerview.widget.DiffUtil import io.legado.app.R +import io.legado.app.base.adapter.DiffRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.data.entities.SearchBook import io.legado.app.databinding.ItemSearchBinding import io.legado.app.utils.gone @@ -14,7 +14,7 @@ import io.legado.app.utils.visible import org.jetbrains.anko.sdk27.listeners.onClick class SearchAdapter(context: Context, val callBack: CallBack) : - SimpleRecyclerAdapter(context) { + DiffRecyclerAdapter(context) { override val diffItemCallback: DiffUtil.ItemCallback get() = object : DiffUtil.ItemCallback() { 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 949a86516..41e5a1819 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,8 +11,8 @@ import androidx.core.os.bundleOf import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.RecyclerView import io.legado.app.R +import io.legado.app.base.adapter.DiffRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.data.entities.BookSource import io.legado.app.databinding.ItemBookSourceBinding import io.legado.app.lib.theme.backgroundColor @@ -23,11 +23,53 @@ import io.legado.app.utils.visible import org.jetbrains.anko.sdk27.listeners.onClick class BookSourceAdapter(context: Context, val callBack: CallBack) : - SimpleRecyclerAdapter(context), + DiffRecyclerAdapter(context), Callback { override val diffItemCallback: DiffUtil.ItemCallback - get() = DiffCallBack() + get() = object : DiffUtil.ItemCallback() { + + override fun areItemsTheSame(oldItem: BookSource, newItem: BookSource): Boolean { + return oldItem.bookSourceUrl == newItem.bookSourceUrl + } + + override fun areContentsTheSame(oldItem: BookSource, newItem: BookSource): Boolean { + if (oldItem.bookSourceName != newItem.bookSourceName) + return false + if (oldItem.bookSourceGroup != newItem.bookSourceGroup) + return false + if (oldItem.enabled != newItem.enabled) + return false + if (oldItem.enabledExplore != newItem.enabledExplore + || oldItem.exploreUrl != newItem.exploreUrl + ) { + return false + } + return true + } + + override fun getChangePayload(oldItem: BookSource, newItem: BookSource): Any? { + val payload = Bundle() + if (oldItem.bookSourceName != newItem.bookSourceName) { + payload.putString("name", newItem.bookSourceName) + } + if (oldItem.bookSourceGroup != newItem.bookSourceGroup) { + payload.putString("group", newItem.bookSourceGroup) + } + if (oldItem.enabled != newItem.enabled) { + payload.putBoolean("enabled", newItem.enabled) + } + if (oldItem.enabledExplore != newItem.enabledExplore + || oldItem.exploreUrl != newItem.exploreUrl + ) { + payload.putBoolean("showExplore", true) + } + if (payload.isEmpty) { + return null + } + return payload + } + } private val selected = linkedSetOf() 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 deleted file mode 100644 index 787e3a129..000000000 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/DiffCallBack.kt +++ /dev/null @@ -1,49 +0,0 @@ -package io.legado.app.ui.book.source.manage - -import android.os.Bundle -import androidx.recyclerview.widget.DiffUtil -import io.legado.app.data.entities.BookSource - -class DiffCallBack : DiffUtil.ItemCallback() { - - override fun areItemsTheSame(oldItem: BookSource, newItem: BookSource): Boolean { - return oldItem.bookSourceUrl == newItem.bookSourceUrl - } - - override fun areContentsTheSame(oldItem: BookSource, newItem: BookSource): Boolean { - if (oldItem.bookSourceName != newItem.bookSourceName) - return false - if (oldItem.bookSourceGroup != newItem.bookSourceGroup) - return false - if (oldItem.enabled != newItem.enabled) - return false - if (oldItem.enabledExplore != newItem.enabledExplore - || oldItem.exploreUrl != newItem.exploreUrl - ) { - return false - } - return true - } - - override fun getChangePayload(oldItem: BookSource, newItem: BookSource): Any? { - val payload = Bundle() - if (oldItem.bookSourceName != newItem.bookSourceName) { - payload.putString("name", newItem.bookSourceName) - } - if (oldItem.bookSourceGroup != newItem.bookSourceGroup) { - payload.putString("group", newItem.bookSourceGroup) - } - if (oldItem.enabled != newItem.enabled) { - payload.putBoolean("enabled", newItem.enabled) - } - if (oldItem.enabledExplore != newItem.enabledExplore - || oldItem.exploreUrl != newItem.exploreUrl - ) { - payload.putBoolean("showExplore", true) - } - if (payload.isEmpty) { - return null - } - return payload - } -} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/GroupManageDialog.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/GroupManageDialog.kt index 01483ad62..1a221453c 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/GroupManageDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/GroupManageDialog.kt @@ -12,8 +12,8 @@ import androidx.fragment.app.DialogFragment import androidx.recyclerview.widget.LinearLayoutManager import io.legado.app.App import io.legado.app.R +import io.legado.app.base.adapter.CommonRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.constant.AppPattern import io.legado.app.databinding.DialogEditTextBinding import io.legado.app.databinding.DialogRecyclerViewBinding @@ -109,7 +109,7 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener { } private inner class GroupAdapter(context: Context) : - SimpleRecyclerAdapter(context) { + CommonRecyclerAdapter(context) { override fun getViewBinding(parent: ViewGroup): ItemGroupManageBinding { return ItemGroupManageBinding.inflate(inflater, parent, false) diff --git a/app/src/main/java/io/legado/app/ui/book/toc/ChapterListAdapter.kt b/app/src/main/java/io/legado/app/ui/book/toc/ChapterListAdapter.kt index bb1c7c53a..f0409de61 100644 --- a/app/src/main/java/io/legado/app/ui/book/toc/ChapterListAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/toc/ChapterListAdapter.kt @@ -3,8 +3,8 @@ package io.legado.app.ui.book.toc import android.content.Context import android.view.ViewGroup import io.legado.app.R +import io.legado.app.base.adapter.CommonRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.data.entities.BookChapter import io.legado.app.databinding.ItemChapterListBinding import io.legado.app.lib.theme.accentColor @@ -13,7 +13,7 @@ import io.legado.app.utils.visible import org.jetbrains.anko.sdk27.listeners.onClick class ChapterListAdapter(context: Context, val callback: Callback) : - SimpleRecyclerAdapter(context) { + CommonRecyclerAdapter(context) { val cacheFileNames = hashSetOf() diff --git a/app/src/main/java/io/legado/app/ui/config/ThemeListDialog.kt b/app/src/main/java/io/legado/app/ui/config/ThemeListDialog.kt index 06cacaf1a..656490788 100644 --- a/app/src/main/java/io/legado/app/ui/config/ThemeListDialog.kt +++ b/app/src/main/java/io/legado/app/ui/config/ThemeListDialog.kt @@ -9,8 +9,8 @@ import androidx.appcompat.widget.Toolbar import androidx.recyclerview.widget.LinearLayoutManager import io.legado.app.R import io.legado.app.base.BaseDialogFragment +import io.legado.app.base.adapter.CommonRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.databinding.DialogRecyclerViewBinding import io.legado.app.databinding.ItemThemeConfigBinding import io.legado.app.help.ThemeConfig @@ -96,7 +96,7 @@ class ThemeListDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener { } inner class Adapter : - SimpleRecyclerAdapter(requireContext()) { + CommonRecyclerAdapter(requireContext()) { override fun getViewBinding(parent: ViewGroup): ItemThemeConfigBinding { return ItemThemeConfigBinding.inflate(inflater, parent, false) diff --git a/app/src/main/java/io/legado/app/ui/filepicker/adapter/FileAdapter.kt b/app/src/main/java/io/legado/app/ui/filepicker/adapter/FileAdapter.kt index 999157497..e59a59b9a 100644 --- a/app/src/main/java/io/legado/app/ui/filepicker/adapter/FileAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/filepicker/adapter/FileAdapter.kt @@ -3,8 +3,8 @@ package io.legado.app.ui.filepicker.adapter import android.content.Context import android.view.ViewGroup +import io.legado.app.base.adapter.CommonRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.databinding.ItemFileFilepickerBinding import io.legado.app.help.AppConfig import io.legado.app.lib.theme.getPrimaryDisabledTextColor @@ -19,7 +19,7 @@ import java.util.* class FileAdapter(context: Context, val callBack: CallBack) : - SimpleRecyclerAdapter(context) { + CommonRecyclerAdapter(context) { private var rootPath: String? = null var currentPath: String? = null private set diff --git a/app/src/main/java/io/legado/app/ui/filepicker/adapter/PathAdapter.kt b/app/src/main/java/io/legado/app/ui/filepicker/adapter/PathAdapter.kt index f0d9b300f..88c2d9a9f 100644 --- a/app/src/main/java/io/legado/app/ui/filepicker/adapter/PathAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/filepicker/adapter/PathAdapter.kt @@ -3,8 +3,8 @@ package io.legado.app.ui.filepicker.adapter import android.content.Context import android.os.Environment import android.view.ViewGroup +import io.legado.app.base.adapter.CommonRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.databinding.ItemPathFilepickerBinding import io.legado.app.ui.filepicker.utils.ConvertUtils import io.legado.app.ui.filepicker.utils.FilePickerIcon @@ -13,7 +13,7 @@ import java.util.* class PathAdapter(context: Context, val callBack: CallBack) : - SimpleRecyclerAdapter(context) { + CommonRecyclerAdapter(context) { private val paths = LinkedList() private val arrowIcon = ConvertUtils.toDrawable(FilePickerIcon.getArrow()) diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BaseBooksAdapter.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BaseBooksAdapter.kt index 034003538..538887c1c 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BaseBooksAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BaseBooksAdapter.kt @@ -4,14 +4,63 @@ import android.content.Context import androidx.core.os.bundleOf import androidx.recyclerview.widget.DiffUtil import androidx.viewbinding.ViewBinding -import io.legado.app.base.adapter.SimpleRecyclerAdapter +import io.legado.app.base.adapter.DiffRecyclerAdapter import io.legado.app.data.entities.Book abstract class BaseBooksAdapter(context: Context) : - SimpleRecyclerAdapter(context) { + DiffRecyclerAdapter(context) { override val diffItemCallback: DiffUtil.ItemCallback - get() = BooksDiffCallBack() + get() = object : DiffUtil.ItemCallback() { + + override fun areItemsTheSame(oldItem: Book, newItem: Book): Boolean { + return oldItem.name == newItem.name + && oldItem.author == newItem.author + } + + override fun areContentsTheSame(oldItem: Book, newItem: Book): Boolean { + return when { + oldItem.durChapterTime != newItem.durChapterTime -> false + oldItem.name != newItem.name -> false + oldItem.author != newItem.author -> false + oldItem.durChapterTitle != newItem.durChapterTitle -> false + oldItem.latestChapterTitle != newItem.latestChapterTitle -> false + oldItem.lastCheckCount != newItem.lastCheckCount -> false + oldItem.getDisplayCover() != newItem.getDisplayCover() -> false + oldItem.getUnreadChapterNum() != newItem.getUnreadChapterNum() -> false + else -> true + } + } + + override fun getChangePayload(oldItem: Book, newItem: Book): Any? { + val bundle = bundleOf() + if (oldItem.name != newItem.name) { + bundle.putString("name", newItem.name) + } + if (oldItem.author != newItem.author) { + bundle.putString("author", newItem.author) + } + if (oldItem.durChapterTitle != newItem.durChapterTitle) { + bundle.putString("dur", newItem.durChapterTitle) + } + if (oldItem.latestChapterTitle != newItem.latestChapterTitle) { + bundle.putString("last", newItem.latestChapterTitle) + } + if (oldItem.getDisplayCover() != newItem.getDisplayCover()) { + bundle.putString("cover", newItem.getDisplayCover()) + } + if (oldItem.lastCheckCount != newItem.lastCheckCount + || oldItem.durChapterTime != newItem.durChapterTime + || oldItem.getUnreadChapterNum() != newItem.getUnreadChapterNum() + || oldItem.lastCheckCount != newItem.lastCheckCount + ) { + bundle.putBoolean("refresh", true) + } + if (bundle.isEmpty) return null + return bundle + } + + } fun notification(bookUrl: String) { for (i in 0 until itemCount) { diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksDiffCallBack.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksDiffCallBack.kt deleted file mode 100644 index 5c5fcf62f..000000000 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksDiffCallBack.kt +++ /dev/null @@ -1,56 +0,0 @@ -package io.legado.app.ui.main.bookshelf.books - -import androidx.core.os.bundleOf -import androidx.recyclerview.widget.DiffUtil -import io.legado.app.data.entities.Book - -class BooksDiffCallBack() : DiffUtil.ItemCallback() { - - override fun areItemsTheSame(oldItem: Book, newItem: Book): Boolean { - return oldItem.name == newItem.name - && oldItem.author == newItem.author - } - - override fun areContentsTheSame(oldItem: Book, newItem: Book): Boolean { - return when { - oldItem.durChapterTime != newItem.durChapterTime -> false - oldItem.name != newItem.name -> false - oldItem.author != newItem.author -> false - oldItem.durChapterTitle != newItem.durChapterTitle -> false - oldItem.latestChapterTitle != newItem.latestChapterTitle -> false - oldItem.lastCheckCount != newItem.lastCheckCount -> false - oldItem.getDisplayCover() != newItem.getDisplayCover() -> false - oldItem.getUnreadChapterNum() != newItem.getUnreadChapterNum() -> false - else -> true - } - } - - override fun getChangePayload(oldItem: Book, newItem: Book): Any? { - val bundle = bundleOf() - if (oldItem.name != newItem.name) { - bundle.putString("name", newItem.name) - } - if (oldItem.author != newItem.author) { - bundle.putString("author", newItem.author) - } - if (oldItem.durChapterTitle != newItem.durChapterTitle) { - bundle.putString("dur", newItem.durChapterTitle) - } - if (oldItem.latestChapterTitle != newItem.latestChapterTitle) { - bundle.putString("last", newItem.latestChapterTitle) - } - if (oldItem.getDisplayCover() != newItem.getDisplayCover()) { - bundle.putString("cover", newItem.getDisplayCover()) - } - if (oldItem.lastCheckCount != newItem.lastCheckCount - || oldItem.durChapterTime != newItem.durChapterTime - || oldItem.getUnreadChapterNum() != newItem.getUnreadChapterNum() - || oldItem.lastCheckCount != newItem.lastCheckCount - ) { - bundle.putBoolean("refresh", true) - } - if (bundle.isEmpty) return null - return bundle - } - -} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt b/app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt index 6532b63fb..98b935638 100644 --- a/app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt @@ -7,8 +7,8 @@ import android.view.ViewGroup import android.widget.PopupMenu import io.legado.app.App import io.legado.app.R +import io.legado.app.base.adapter.CommonRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.data.entities.BookSource import io.legado.app.databinding.ItemFilletTextBinding import io.legado.app.databinding.ItemFindBookBinding @@ -24,7 +24,7 @@ import org.jetbrains.anko.sdk27.listeners.onLongClick class ExploreAdapter(context: Context, private val scope: CoroutineScope, val callBack: CallBack) : - SimpleRecyclerAdapter(context) { + CommonRecyclerAdapter(context) { private var exIndex = -1 private var scrollTo = -1 diff --git a/app/src/main/java/io/legado/app/ui/replace/GroupManageDialog.kt b/app/src/main/java/io/legado/app/ui/replace/GroupManageDialog.kt index 33dfd191e..c2b8941de 100644 --- a/app/src/main/java/io/legado/app/ui/replace/GroupManageDialog.kt +++ b/app/src/main/java/io/legado/app/ui/replace/GroupManageDialog.kt @@ -12,8 +12,8 @@ import androidx.fragment.app.DialogFragment import androidx.recyclerview.widget.LinearLayoutManager import io.legado.app.App import io.legado.app.R +import io.legado.app.base.adapter.CommonRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.constant.AppPattern import io.legado.app.databinding.DialogEditTextBinding import io.legado.app.databinding.DialogRecyclerViewBinding @@ -114,7 +114,7 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener { } private inner class GroupAdapter(context: Context) : - SimpleRecyclerAdapter(context) { + CommonRecyclerAdapter(context) { override fun getViewBinding(parent: ViewGroup): ItemGroupManageBinding { return ItemGroupManageBinding.inflate(inflater, parent, false) diff --git a/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleAdapter.kt b/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleAdapter.kt index 4de23aadc..48ac5eec1 100644 --- a/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleAdapter.kt @@ -8,8 +8,8 @@ import android.widget.PopupMenu import androidx.core.os.bundleOf import androidx.recyclerview.widget.RecyclerView import io.legado.app.R +import io.legado.app.base.adapter.CommonRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.data.entities.ReplaceRule import io.legado.app.databinding.ItemReplaceRuleBinding import io.legado.app.lib.theme.backgroundColor @@ -20,7 +20,7 @@ import java.util.* class ReplaceRuleAdapter(context: Context, var callBack: CallBack) : - SimpleRecyclerAdapter(context), + CommonRecyclerAdapter(context), ItemTouchCallback.Callback { private val selected = linkedSetOf() diff --git a/app/src/main/java/io/legado/app/ui/rss/favorites/RssFavoritesAdapter.kt b/app/src/main/java/io/legado/app/ui/rss/favorites/RssFavoritesAdapter.kt index b5c921ff7..f630ec25e 100644 --- a/app/src/main/java/io/legado/app/ui/rss/favorites/RssFavoritesAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/rss/favorites/RssFavoritesAdapter.kt @@ -7,8 +7,8 @@ import com.bumptech.glide.load.DataSource import com.bumptech.glide.load.engine.GlideException import com.bumptech.glide.request.RequestListener import com.bumptech.glide.request.target.Target +import io.legado.app.base.adapter.CommonRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.data.entities.RssStar import io.legado.app.databinding.ItemRssArticleBinding import io.legado.app.help.ImageLoader @@ -17,7 +17,7 @@ import io.legado.app.utils.visible import org.jetbrains.anko.sdk27.listeners.onClick class RssFavoritesAdapter(context: Context, val callBack: CallBack) : - SimpleRecyclerAdapter(context) { + CommonRecyclerAdapter(context) { override fun getViewBinding(parent: ViewGroup): ItemRssArticleBinding { return ItemRssArticleBinding.inflate(inflater, parent, false) diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/DiffCallBack.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/DiffCallBack.kt deleted file mode 100644 index 2945a9b95..000000000 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/DiffCallBack.kt +++ /dev/null @@ -1,35 +0,0 @@ -package io.legado.app.ui.rss.source.manage - -import android.os.Bundle -import androidx.recyclerview.widget.DiffUtil -import io.legado.app.data.entities.RssSource - -class DiffCallBack : DiffUtil.ItemCallback() { - - override fun areItemsTheSame(oldItem: RssSource, newItem: RssSource): Boolean { - return oldItem.sourceUrl == newItem.sourceUrl - } - - override fun areContentsTheSame(oldItem: RssSource, newItem: RssSource): Boolean { - return oldItem.sourceName == newItem.sourceName - && oldItem.sourceGroup == newItem.sourceGroup - && oldItem.enabled == newItem.enabled - } - - override fun getChangePayload(oldItem: RssSource, newItem: RssSource): Any? { - val payload = Bundle() - if (oldItem.sourceName != newItem.sourceName) { - payload.putString("name", newItem.sourceName) - } - if (oldItem.sourceGroup != newItem.sourceGroup) { - payload.putString("group", newItem.sourceGroup) - } - if (oldItem.enabled != newItem.enabled) { - payload.putBoolean("enabled", newItem.enabled) - } - if (payload.isEmpty) { - return null - } - return payload - } -} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/GroupManageDialog.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/GroupManageDialog.kt index e9d6cae62..b467131d4 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/GroupManageDialog.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/GroupManageDialog.kt @@ -12,8 +12,8 @@ import androidx.recyclerview.widget.LinearLayoutManager import io.legado.app.App import io.legado.app.R import io.legado.app.base.BaseDialogFragment +import io.legado.app.base.adapter.CommonRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.constant.AppPattern import io.legado.app.databinding.DialogEditTextBinding import io.legado.app.databinding.DialogRecyclerViewBinding @@ -113,7 +113,7 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener } private inner class GroupAdapter(context: Context) : - SimpleRecyclerAdapter(context) { + CommonRecyclerAdapter(context) { override fun getViewBinding(parent: ViewGroup): ItemGroupManageBinding { return ItemGroupManageBinding.inflate(inflater, parent, false) diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt index 952e814f4..284149d37 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt @@ -9,8 +9,8 @@ import androidx.core.os.bundleOf import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.RecyclerView import io.legado.app.R +import io.legado.app.base.adapter.DiffRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.data.entities.RssSource import io.legado.app.databinding.ItemRssSourceBinding import io.legado.app.lib.theme.backgroundColor @@ -19,11 +19,39 @@ import io.legado.app.ui.widget.recycler.ItemTouchCallback import org.jetbrains.anko.sdk27.listeners.onClick class RssSourceAdapter(context: Context, val callBack: CallBack) : - SimpleRecyclerAdapter(context), + DiffRecyclerAdapter(context), ItemTouchCallback.Callback { override val diffItemCallback: DiffUtil.ItemCallback - get() = DiffCallBack() + get() = object : DiffUtil.ItemCallback() { + + override fun areItemsTheSame(oldItem: RssSource, newItem: RssSource): Boolean { + return oldItem.sourceUrl == newItem.sourceUrl + } + + override fun areContentsTheSame(oldItem: RssSource, newItem: RssSource): Boolean { + return oldItem.sourceName == newItem.sourceName + && oldItem.sourceGroup == newItem.sourceGroup + && oldItem.enabled == newItem.enabled + } + + override fun getChangePayload(oldItem: RssSource, newItem: RssSource): Any? { + val payload = Bundle() + if (oldItem.sourceName != newItem.sourceName) { + payload.putString("name", newItem.sourceName) + } + if (oldItem.sourceGroup != newItem.sourceGroup) { + payload.putString("group", newItem.sourceGroup) + } + if (oldItem.enabled != newItem.enabled) { + payload.putBoolean("enabled", newItem.enabled) + } + if (payload.isEmpty) { + return null + } + return payload + } + } private val selected = linkedSetOf() diff --git a/app/src/main/java/io/legado/app/ui/rss/subscription/RuleSubAdapter.kt b/app/src/main/java/io/legado/app/ui/rss/subscription/RuleSubAdapter.kt index 520c27445..0efea8371 100644 --- a/app/src/main/java/io/legado/app/ui/rss/subscription/RuleSubAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/rss/subscription/RuleSubAdapter.kt @@ -6,15 +6,15 @@ import android.view.ViewGroup import android.widget.PopupMenu import androidx.recyclerview.widget.RecyclerView import io.legado.app.R +import io.legado.app.base.adapter.CommonRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.data.entities.RuleSub import io.legado.app.databinding.ItemRuleSubBinding import io.legado.app.ui.widget.recycler.ItemTouchCallback import org.jetbrains.anko.sdk27.listeners.onClick class RuleSubAdapter(context: Context, val callBack: Callback) : - SimpleRecyclerAdapter(context), + CommonRecyclerAdapter(context), ItemTouchCallback.Callback { private val typeArray = context.resources.getStringArray(R.array.rule_type) diff --git a/app/src/main/java/io/legado/app/ui/widget/KeyboardToolPop.kt b/app/src/main/java/io/legado/app/ui/widget/KeyboardToolPop.kt index aa8f71f04..e0b66934a 100644 --- a/app/src/main/java/io/legado/app/ui/widget/KeyboardToolPop.kt +++ b/app/src/main/java/io/legado/app/ui/widget/KeyboardToolPop.kt @@ -6,8 +6,8 @@ import android.view.ViewGroup import android.widget.PopupWindow import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView +import io.legado.app.base.adapter.CommonRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.databinding.ItemFilletTextBinding import io.legado.app.databinding.PopupKeyboardToolBinding import org.jetbrains.anko.sdk27.listeners.onClick @@ -40,7 +40,7 @@ class KeyboardToolPop( } inner class Adapter(context: Context) : - SimpleRecyclerAdapter(context) { + CommonRecyclerAdapter(context) { override fun getViewBinding(parent: ViewGroup): ItemFilletTextBinding { return ItemFilletTextBinding.inflate(inflater, parent, false) diff --git a/app/src/main/java/io/legado/app/ui/widget/dialog/TextListDialog.kt b/app/src/main/java/io/legado/app/ui/widget/dialog/TextListDialog.kt index 567f1687a..4c0643ba1 100644 --- a/app/src/main/java/io/legado/app/ui/widget/dialog/TextListDialog.kt +++ b/app/src/main/java/io/legado/app/ui/widget/dialog/TextListDialog.kt @@ -9,8 +9,8 @@ import androidx.fragment.app.FragmentManager import androidx.recyclerview.widget.LinearLayoutManager import io.legado.app.R import io.legado.app.base.BaseDialogFragment +import io.legado.app.base.adapter.CommonRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.databinding.DialogRecyclerViewBinding import io.legado.app.databinding.ItemLogBinding import io.legado.app.utils.getSize @@ -59,7 +59,7 @@ class TextListDialog : BaseDialogFragment() { } class TextAdapter(context: Context) : - SimpleRecyclerAdapter(context) { + CommonRecyclerAdapter(context) { override fun getViewBinding(parent: ViewGroup): ItemLogBinding { return ItemLogBinding.inflate(inflater, parent, false) diff --git a/app/src/main/java/io/legado/app/ui/widget/font/FontAdapter.kt b/app/src/main/java/io/legado/app/ui/widget/font/FontAdapter.kt index 53b812fa7..73559cd1f 100644 --- a/app/src/main/java/io/legado/app/ui/widget/font/FontAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/widget/font/FontAdapter.kt @@ -4,8 +4,8 @@ import android.content.Context import android.graphics.Typeface import android.os.Build import android.view.ViewGroup +import io.legado.app.base.adapter.CommonRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.databinding.ItemFontBinding import io.legado.app.utils.DocItem import io.legado.app.utils.RealPathUtil @@ -16,7 +16,7 @@ import org.jetbrains.anko.toast import java.io.File class FontAdapter(context: Context, val callBack: CallBack) : - SimpleRecyclerAdapter(context) { + CommonRecyclerAdapter(context) { override fun getViewBinding(parent: ViewGroup): ItemFontBinding { return ItemFontBinding.inflate(inflater, parent, false) diff --git a/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt b/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt index 8ed75bbd2..9cad1cdb7 100644 --- a/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt +++ b/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt @@ -15,8 +15,8 @@ import androidx.preference.PreferenceViewHolder import androidx.recyclerview.widget.LinearLayoutManager import io.legado.app.R import io.legado.app.base.BaseDialogFragment +import io.legado.app.base.adapter.CommonRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.databinding.DialogRecyclerViewBinding import io.legado.app.databinding.ItemIconPreferenceBinding import io.legado.app.lib.theme.primaryColor @@ -156,7 +156,7 @@ class IconListPreference(context: Context, attrs: AttributeSet) : ListPreference inner class Adapter(context: Context) : - SimpleRecyclerAdapter(context) { + CommonRecyclerAdapter(context) { override fun getViewBinding(parent: ViewGroup): ItemIconPreferenceBinding { return ItemIconPreferenceBinding.inflate(inflater, parent, false)