pull/737/head
Robot 4 years ago
commit 96c2e5e3e2
  1. 3
      app/src/main/assets/updateLog.md
  2. 58
      app/src/main/java/io/legado/app/base/adapter/SimpleRecyclerAdapter.kt
  3. 2
      app/src/main/java/io/legado/app/help/http/AjaxWebView.kt
  4. 3
      app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt
  5. 14
      app/src/main/java/io/legado/app/ui/book/changecover/CoverAdapter.kt
  6. 14
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt
  7. 3
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt
  8. 2
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt
  9. 4
      app/src/main/java/io/legado/app/ui/book/local/ImportBookAdapter.kt
  10. 4
      app/src/main/java/io/legado/app/ui/book/search/BookAdapter.kt
  11. 4
      app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentAdapter.kt
  12. 4
      app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugAdapter.kt
  13. 4
      app/src/main/java/io/legado/app/ui/rss/source/debug/RssSourceDebugAdapter.kt
  14. 58
      app/src/main/res/values-zh-rTW/strings.xml

@ -3,6 +3,9 @@
* 关注合作公众号 **[小说拾遗]** 获取好看的小说。
* 旧版数据导入教程:先在旧版阅读(2.x)中进行备份,然后在新版阅读(3.x)【我的】->【备份与恢复】,选择【导入旧版本数据】。
**2020/12/16**
* 修复上版本因更新组件引起的一些bug
**2020/12/15**
* 修复一些引起崩溃的bug
* 修复搜书和换源可能什么分组都没有的bug

@ -35,7 +35,7 @@ abstract class SimpleRecyclerAdapter<ITEM, VB : ViewBinding>(protected val conte
object : DiffUtil.ItemCallback<ITEM>() {
override fun areItemsTheSame(oldItem: ITEM, newItem: ITEM): Boolean {
return oldItem == newItem
return false
}
override fun areContentsTheSame(oldItem: ITEM, newItem: ITEM): Boolean {
@ -70,57 +70,6 @@ abstract class SimpleRecyclerAdapter<ITEM, VB : ViewBinding>(protected val conte
}
}
fun addItem(item: ITEM) {
synchronized(lock) {
val list = ArrayList(asyncListDiffer.currentList)
list.add(item)
asyncListDiffer.submitList(list)
}
}
fun addItems(position: Int, newItems: List<ITEM>) {
synchronized(lock) {
val list = ArrayList(asyncListDiffer.currentList)
list.addAll(position, newItems)
asyncListDiffer.submitList(list)
}
}
fun addItems(newItems: List<ITEM>) {
synchronized(lock) {
val list = ArrayList(asyncListDiffer.currentList)
list.addAll(newItems)
asyncListDiffer.submitList(list)
}
}
fun removeItem(position: Int) {
synchronized(lock) {
val list = ArrayList(asyncListDiffer.currentList)
if (list.removeAt(position) != null) {
asyncListDiffer.submitList(list)
}
}
}
fun removeItem(item: ITEM) {
synchronized(lock) {
val list = ArrayList(asyncListDiffer.currentList)
if (list.remove(item)) {
asyncListDiffer.submitList(list)
}
}
}
fun removeItems(items: List<ITEM>) {
synchronized(lock) {
val list = ArrayList(asyncListDiffer.currentList)
if (list.removeAll(items)) {
asyncListDiffer.submitList(list)
}
}
}
fun swapItem(srcPosition: Int, targetPosition: Int) {
synchronized(lock) {
val list = ArrayList(getItems())
@ -158,11 +107,6 @@ abstract class SimpleRecyclerAdapter<ITEM, VB : ViewBinding>(protected val conte
}
}
fun clearItems() =
synchronized(lock) {
asyncListDiffer.submitList(arrayListOf())
}
fun isEmpty() = asyncListDiffer.currentList.isEmpty()
fun isNotEmpty() = asyncListDiffer.currentList.isNotEmpty()

@ -170,7 +170,7 @@ class AjaxWebView {
return@evaluateJavascript
}
if (retry > 30) {
handler.obtainMessage(MSG_ERROR, Exception("time out"))
handler.obtainMessage(MSG_ERROR, Exception("js执行超时"))
.sendToTarget()
handler.removeCallbacks(this)
return@evaluateJavascript

@ -7,7 +7,6 @@ import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.GridLayoutManager
import io.legado.app.R
import io.legado.app.base.BaseDialogFragment
@ -93,9 +92,7 @@ class ChangeCoverDialog : BaseDialogFragment(),
binding.toolBar.menu.applyTint(requireContext(), Theme.getTheme())
})
viewModel.searchBooksLiveData.observe(viewLifecycleOwner, {
val diffResult = DiffUtil.calculateDiff(DiffCallBack(adapter.getItems(), it))
adapter.setItems(it)
diffResult.dispatchUpdatesTo(adapter)
})
}

@ -2,6 +2,7 @@ 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.ItemViewHolder
import io.legado.app.base.adapter.SimpleRecyclerAdapter
import io.legado.app.data.entities.SearchBook
@ -11,6 +12,19 @@ import org.jetbrains.anko.sdk27.listeners.onClick
class CoverAdapter(context: Context, val callBack: CallBack) :
SimpleRecyclerAdapter<SearchBook, ItemCoverBinding>(context) {
override val diffItemCallback: DiffUtil.ItemCallback<SearchBook>
get() = object : DiffUtil.ItemCallback<SearchBook>() {
override fun areItemsTheSame(oldItem: SearchBook, newItem: SearchBook): Boolean {
return oldItem.bookUrl == newItem.bookUrl
}
override fun areContentsTheSame(oldItem: SearchBook, newItem: SearchBook): Boolean {
return oldItem.originName == newItem.originName
&& oldItem.coverUrl == newItem.coverUrl
}
}
override fun getViewBinding(parent: ViewGroup): ItemCoverBinding {
return ItemCoverBinding.inflate(inflater, parent, false)
}

@ -5,6 +5,7 @@ import android.os.Bundle
import android.view.View
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.ItemViewHolder
import io.legado.app.base.adapter.SimpleRecyclerAdapter
@ -19,6 +20,19 @@ import org.jetbrains.anko.sdk27.listeners.onLongClick
class ChangeSourceAdapter(context: Context, val callBack: CallBack) :
SimpleRecyclerAdapter<SearchBook, ItemChangeSourceBinding>(context) {
override val diffItemCallback: DiffUtil.ItemCallback<SearchBook>
get() = object : DiffUtil.ItemCallback<SearchBook>() {
override fun areItemsTheSame(oldItem: SearchBook, newItem: SearchBook): Boolean {
return oldItem.bookUrl == newItem.bookUrl
}
override fun areContentsTheSame(oldItem: SearchBook, newItem: SearchBook): Boolean {
return oldItem.originName == newItem.originName
&& oldItem.getDisplayLastChapterTitle() == newItem.getDisplayLastChapterTitle()
}
}
override fun getViewBinding(parent: ViewGroup): ItemChangeSourceBinding {
return ItemChangeSourceBinding.inflate(inflater, parent, false)
}

@ -5,7 +5,6 @@ import android.view.*
import androidx.appcompat.widget.SearchView
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import io.legado.app.App
@ -145,9 +144,7 @@ class ChangeSourceDialog : BaseDialogFragment(),
binding.toolBar.menu.applyTint(requireContext())
})
viewModel.searchBooksLiveData.observe(viewLifecycleOwner, {
val diffResult = DiffUtil.calculateDiff(DiffCallBack(adapter.getItems(), it))
adapter.setItems(it)
diffResult.dispatchUpdatesTo(adapter)
})
App.db.bookSourceDao.liveGroupEnabled().observe(this, {
groups.clear()

@ -102,7 +102,7 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio
private fun startSearch() {
execute {
bookSourceList.clear()
if (searchGroup.isNullOrBlank()) {
if (searchGroup.isBlank()) {
bookSourceList.addAll(App.db.bookSourceDao.allEnabled)
} else {
bookSourceList.addAll(App.db.bookSourceDao.getEnabledByGroup(searchGroup))

@ -4,8 +4,8 @@ import android.content.Context
import android.net.Uri
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.constant.AppConst
import io.legado.app.databinding.ItemImportBookBinding
import io.legado.app.utils.*
@ -13,7 +13,7 @@ import org.jetbrains.anko.sdk27.listeners.onClick
class ImportBookAdapter(context: Context, val callBack: CallBack) :
SimpleRecyclerAdapter<DocItem, ItemImportBookBinding>(context) {
CommonRecyclerAdapter<DocItem, ItemImportBookBinding>(context) {
var selectedUris = hashSetOf<String>()
var checkableCount = 0
private var bookFileNames = arrayListOf<String>()

@ -2,14 +2,14 @@ package io.legado.app.ui.book.search
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.data.entities.Book
import io.legado.app.databinding.ItemFilletTextBinding
import org.jetbrains.anko.sdk27.listeners.onClick
class BookAdapter(context: Context, val callBack: CallBack) :
SimpleRecyclerAdapter<Book, ItemFilletTextBinding>(context) {
CommonRecyclerAdapter<Book, ItemFilletTextBinding>(context) {
override fun getViewBinding(parent: ViewGroup): ItemFilletTextBinding {
return ItemFilletTextBinding.inflate(inflater, parent, false)

@ -3,8 +3,8 @@ package io.legado.app.ui.book.searchContent
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.databinding.ItemSearchListBinding
import io.legado.app.lib.theme.accentColor
import io.legado.app.utils.getCompatColor
@ -12,7 +12,7 @@ import io.legado.app.utils.hexString
import org.jetbrains.anko.sdk27.listeners.onClick
class SearchContentAdapter(context: Context, val callback: Callback) :
SimpleRecyclerAdapter<SearchResult, ItemSearchListBinding>(context) {
CommonRecyclerAdapter<SearchResult, ItemSearchListBinding>(context) {
val cacheFileNames = hashSetOf<String>()
val textColor = context.getCompatColor(R.color.primaryText).hexString.substring(2)

@ -4,12 +4,12 @@ import android.content.Context
import android.view.View
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.databinding.ItemLogBinding
class BookSourceDebugAdapter(context: Context) :
SimpleRecyclerAdapter<String, ItemLogBinding>(context) {
CommonRecyclerAdapter<String, ItemLogBinding>(context) {
override fun getViewBinding(parent: ViewGroup): ItemLogBinding {
return ItemLogBinding.inflate(inflater, parent, false)

@ -4,12 +4,12 @@ import android.content.Context
import android.view.View
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.databinding.ItemLogBinding
class RssSourceDebugAdapter(context: Context) :
SimpleRecyclerAdapter<String, ItemLogBinding>(context) {
CommonRecyclerAdapter<String, ItemLogBinding>(context) {
override fun getViewBinding(parent: ViewGroup): ItemLogBinding {
return ItemLogBinding.inflate(inflater, parent, false)

@ -362,8 +362,8 @@
<string name="finish_book">完結書籍</string>
<string name="local_book">本機書籍</string>
<string name="status_bar_immersion">狀態欄顏色透明</string>
<string name="imm_navigation_bar">沉浸式导航栏</string>
<string name="imm_navigation_bar_s">导航栏颜色透明</string>
<string name="imm_navigation_bar">沉浸式導航欄</string>
<string name="imm_navigation_bar_s">導航欄顏色透明</string>
<string name="add_to_shelf">放入書架</string>
<string name="continue_read">繼續閱讀</string>
<string name="cover_path">封面地址</string>
@ -405,7 +405,7 @@
<string name="book_url_pattern">書籍URL正則(bookUrlPattern)</string>
<string name="rule_book_info_init">預處理規則(bookInfoInit)</string>
<string name="rule_toc_url">目錄URL規則(tocUrl)</string>
<string name="rule_can_re_name">许修改书名作者(canReName)</string>
<string name="rule_can_re_name">許修改書名作者(canReName)</string>
<string name="rule_next_toc_url">目錄下一頁規則(nextTocUrl)</string>
<string name="rule_chapter_list">目錄列表規則(chapterList)</string>
<string name="rule_chapter_name">章節名稱規則(ChapterName)</string>
@ -715,7 +715,7 @@
<string name="already_in_download">該書已在下載列表</string>
<string name="click_to_open">點擊打開</string>
<string name="follow_public_account_summary">關注[legado-top]點擊廣告支持我</string>
<string name="weChat_appreciation_code">微信賞碼</string>
<string name="weChat_appreciation_code">微信賞碼</string>
<string name="alipay">支付寶</string>
<string name="alipay_red_envelope_search_code">支付寶紅包搜尋碼</string>
<string name="alipay_red_envelope_copy">537954522 點擊複製</string>
@ -758,8 +758,8 @@
<string name="import_str">匯入</string>
<string name="export_str">匯出</string>
<string name="save_theme_config">儲存主題配置</string>
<string name="save_day_theme_summary">儲存白天主題配置以供調用和分享</string>
<string name="save_night_theme_summary">儲存夜間主題配置以供調用和分享</string>
<string name="save_day_theme_summary">儲存白天主題配置以供呼叫和分享</string>
<string name="save_night_theme_summary">儲存夜間主題配置以供呼叫和分享</string>
<string name="theme_list">主題列表</string>
<string name="theme_list_summary">使用儲存主題,匯入,分享主題</string>
<string name="select_theme">切換預設主題</string>
@ -768,30 +768,30 @@
<string name="search_content">全文搜尋</string>
<string name="rss_source_empty">關注公眾號[开源阅读]獲取訂閱源!</string>
<string name="explore_empty">目前沒有發現源,關注公眾號[开源阅读]添加包含發現的書源!</string>
<string name="page_key_set_help">将焦点放到输入框按下物理按键会自动录入键值,多个按键会自动用英文逗号隔开.</string>
<string name="theme_name">题名称</string>
<string name="auto_clear_expired">动清除过期搜索数据</string>
<string name="auto_clear_expired_summary">过一天的搜索数据</string>
<string name="page_key_set_help">將焦點放到輸入框按下物理按鍵會自動輸入鍵值,多個按鍵會自動用英文逗號隔開.</string>
<string name="theme_name">題名稱</string>
<string name="auto_clear_expired">動清除過期搜尋資料</string>
<string name="auto_clear_expired_summary">過一天的搜尋資料</string>
<string name="re_segment">重新分段</string>
<string name="style_name">样式名称:</string>
<string name="empty_msg_import_book">点击右上角文件夹图标,选择文件夹</string>
<string name="scan_folder">能扫</string>
<string name="copy_url">拷贝URL</string>
<string name="no_book">没有书</string>
<string name="style_name">樣式名稱:</string>
<string name="empty_msg_import_book">點擊右上角資料夾圖示,選擇資料夾</string>
<string name="scan_folder">慧掃</string>
<string name="copy_url">複製URL</string>
<string name="no_book">沒有書</string>
<string name="keep_original_name">保留原名</string>
<string name="click_regional_config">点击区域设置</string>
<string name="colse">关闭</string>
<string name="next_page">下一</string>
<string name="prev_page">上一</string>
<string name="non_action">操作</string>
<string name="body_title">正文标题</string>
<string name="show_hide">显示/隐</string>
<string name="header_footer">页眉<![CDATA[&]]>页脚</string>
<string name="rule_subscription">规则订阅</string>
<string name="rule_sub_empty_msg">添加大佬们提供的规则导入地址\n添加后点击可导入规则</string>
<string name="get_book_progress">拉取云端进</string>
<string name="current_progress_exceeds_cloud">当前进度超过云端进度,是否同步?</string>
<string name="sync_book_progress_t">同步阅读进</string>
<string name="sync_book_progress_s">进入退出阅读界面时同步阅读进</string>
<string name="click_regional_config">點擊區域設定</string>
<string name="colse">關閉</string>
<string name="next_page">下一</string>
<string name="prev_page">上一</string>
<string name="non_action">操作</string>
<string name="body_title">正文標題</string>
<string name="show_hide">顯示/隱</string>
<string name="header_footer">頁首<![CDATA[&]]>頁尾</string>
<string name="rule_subscription">規則訂閱</string>
<string name="rule_sub_empty_msg">添加大佬們提供的規則匯入地址\n添加後點擊可匯入規則</string>
<string name="get_book_progress">拉取雲端進</string>
<string name="current_progress_exceeds_cloud">目前進度超過雲端進度,是否同步?</string>
<string name="sync_book_progress_t">同步閱讀進</string>
<string name="sync_book_progress_s">進入退出閱讀介面時同步閱讀進</string>
</resources>

Loading…
Cancel
Save