Merge pull request #883 from hoodie13/local-gedoor-code

1.修复漫画崩溃问题;2.修复书签溢出屏幕问题;3.epub书籍增加本地cache,加速加载速度
pull/885/head^2
kunfei 4 years ago committed by GitHub
commit 638a10f649
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 19
      app/src/main/java/io/legado/app/help/BookHelp.kt
  2. 2
      app/src/main/java/io/legado/app/ui/book/read/page/provider/ImageProvider.kt
  3. 4
      app/src/main/java/io/legado/app/ui/book/toc/BookmarkFragment.kt

@ -148,7 +148,7 @@ object BookHelp {
fun getChapterFiles(book: Book): List<String> { fun getChapterFiles(book: Book): List<String> {
val fileNameList = arrayListOf<String>() val fileNameList = arrayListOf<String>()
if (book.isLocalBook()) { if (book.isLocalTxt()) {
return fileNameList return fileNameList
} }
FileUtils.createFolderIfNotExist( FileUtils.createFolderIfNotExist(
@ -162,7 +162,7 @@ object BookHelp {
// 检测该章节是否下载 // 检测该章节是否下载
fun hasContent(book: Book, bookChapter: BookChapter): Boolean { fun hasContent(book: Book, bookChapter: BookChapter): Boolean {
return if (book.isLocalBook()) { return if (book.isLocalTxt()) {
true true
} else { } else {
FileUtils.exists( FileUtils.exists(
@ -175,8 +175,19 @@ object BookHelp {
} }
fun getContent(book: Book, bookChapter: BookChapter): String? { fun getContent(book: Book, bookChapter: BookChapter): String? {
if (book.isLocalBook()) { if (book.isLocalTxt()) {
return LocalBook.getContext(book, bookChapter) return LocalBook.getContext(book, bookChapter)
} else if (book.isEpub() && !hasContent(book, bookChapter)) {
val string = LocalBook.getContext(book, bookChapter)
string?.let {
FileUtils.createFileIfNotExist(
downloadDir,
cacheFolderName,
book.getFolderName(),
bookChapter.getFileName(),
).writeText(it)
}
return string
} else { } else {
val file = FileUtils.getFile( val file = FileUtils.getFile(
downloadDir, downloadDir,
@ -211,7 +222,7 @@ object BookHelp {
} }
fun delContent(book: Book, bookChapter: BookChapter) { fun delContent(book: Book, bookChapter: BookChapter) {
if (book.isLocalBook()) { if (book.isLocalTxt()) {
return return
} else { } else {
FileUtils.createFileIfNotExist( FileUtils.createFileIfNotExist(

@ -61,6 +61,7 @@ object ImageProvider {
} }
} }
@Synchronized
fun clearAllCache() { fun clearAllCache() {
cache.forEach { indexCache -> cache.forEach { indexCache ->
indexCache.value.forEach { indexCache.value.forEach {
@ -70,6 +71,7 @@ object ImageProvider {
cache.clear() cache.clear()
} }
@Synchronized
fun clearOut(chapterIndex: Int) { fun clearOut(chapterIndex: Int) {
cache.forEach { indexCache -> cache.forEach { indexCache ->
if (indexCache.key !in chapterIndex - 1..chapterIndex + 1) { if (indexCache.key !in chapterIndex - 1..chapterIndex + 1) {

@ -88,6 +88,10 @@ class BookmarkFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragment_
val alertBinding = DialogBookmarkBinding.inflate(layoutInflater).apply { val alertBinding = DialogBookmarkBinding.inflate(layoutInflater).apply {
editBookText.setText(bookmark.bookText) editBookText.setText(bookmark.bookText)
editView.setText(bookmark.content) editView.setText(bookmark.content)
editBookText.textSize = 15f
editView.textSize = 15f
editBookText.maxLines= 6
editView.maxLines= 6
} }
customView { alertBinding.root } customView { alertBinding.root }
yesButton { yesButton {

Loading…
Cancel
Save