添加Umd格式支持

pull/1093/head
ag2s20150909 3 years ago
parent 950afc36d7
commit 2aeb7a4219
  1. 26
      app/src/main/java/io/legado/app/model/localBook/UmdFile.kt

@ -18,27 +18,27 @@ import java.util.ArrayList
class UmdFile(var book: Book) {
companion object {
private var eFile: UmdFile? = null
private var uFile: UmdFile? = null
@Synchronized
private fun getEFile(book: Book): UmdFile {
private fun getUFile(book: Book): UmdFile {
if (eFile == null || eFile?.book?.bookUrl != book.bookUrl) {
eFile = UmdFile(book)
return eFile!!
if (uFile == null || uFile?.book?.bookUrl != book.bookUrl) {
uFile = UmdFile(book)
return uFile!!
}
eFile?.book = book
return eFile!!
uFile?.book = book
return uFile!!
}
@Synchronized
fun getChapterList(book: Book): ArrayList<BookChapter> {
return getEFile(book).getChapterList()
return getUFile(book).getChapterList()
}
@Synchronized
fun getContent(book: Book, chapter: BookChapter): String? {
return getEFile(book).getContent(chapter)
return getUFile(book).getContent(chapter)
}
@Synchronized
@ -46,13 +46,13 @@ class UmdFile(var book: Book) {
book: Book,
href: String
): InputStream? {
return getEFile(book).getImage(href)
return getUFile(book).getImage(href)
}
@Synchronized
fun upBookInfo(book: Book) {
return getEFile(book).upBookInfo()
return getUFile(book).upBookInfo()
}
}
@ -100,7 +100,7 @@ class UmdFile(var book: Book) {
private fun upBookInfo() {
if(umdBook==null){
eFile = null
uFile = null
book.intro = "书籍导入异常"
}else{
val hd= umdBook!!.header
@ -115,7 +115,7 @@ class UmdFile(var book: Book) {
private fun getChapterList(): ArrayList<BookChapter> {
val chapterList = ArrayList<BookChapter>()
umdBook?.chapters?.titles?.forEachIndexed { index, bytes ->
umdBook?.chapters?.titles?.forEachIndexed { index, _ ->
val title = umdBook!!.chapters.getTitle(index)
val chapter = BookChapter()
chapter.title=title;

Loading…
Cancel
Save