parent
ea507382a7
commit
32f1025ce9
@ -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<BookSource>() { |
||||
|
||||
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 |
||||
} |
||||
} |
@ -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<Book>() { |
||||
|
||||
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 |
||||
} |
||||
|
||||
} |
@ -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<RssSource>() { |
||||
|
||||
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 |
||||
} |
||||
} |
Loading…
Reference in new issue