diff --git a/app/src/main/java/io/legado/app/model/localBook/BaseLocalBookParse.kt b/app/src/main/java/io/legado/app/model/localBook/BaseLocalBookParse.kt new file mode 100644 index 000000000..8d59bfc23 --- /dev/null +++ b/app/src/main/java/io/legado/app/model/localBook/BaseLocalBookParse.kt @@ -0,0 +1,21 @@ +package io.legado.app.model.localBook + +import io.legado.app.data.entities.Book +import io.legado.app.data.entities.BookChapter +import java.io.InputStream + +/** + *companion object interface + *see EpubFile.kt + */ +interface BaseLocalBookParse { + + fun upBookInfo(book: Book) + + fun getChapterList(book: Book): ArrayList + + fun getContent(book: Book, chapter: BookChapter): String? + + fun getImage(book: Book, href: String): InputStream? + +} diff --git a/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt b/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt index 36be77a05..ffdaf89e0 100644 --- a/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt +++ b/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt @@ -25,7 +25,7 @@ import java.util.zip.ZipFile class EpubFile(var book: Book) { - companion object { + companion object : BaseLocalBookParse { private var eFile: EpubFile? = null @Synchronized @@ -41,17 +41,17 @@ class EpubFile(var book: Book) { } @Synchronized - fun getChapterList(book: Book): ArrayList { + override fun getChapterList(book: Book): ArrayList { return getEFile(book).getChapterList() } @Synchronized - fun getContent(book: Book, chapter: BookChapter): String? { + override fun getContent(book: Book, chapter: BookChapter): String? { return getEFile(book).getContent(chapter) } @Synchronized - fun getImage( + override fun getImage( book: Book, href: String ): InputStream? { @@ -59,7 +59,7 @@ class EpubFile(var book: Book) { } @Synchronized - fun upBookInfo(book: Book) { + override fun upBookInfo(book: Book) { return getEFile(book).upBookInfo() } } diff --git a/app/src/main/java/io/legado/app/model/localBook/README.md b/app/src/main/java/io/legado/app/model/localBook/README.md new file mode 100644 index 000000000..8f080b25e --- /dev/null +++ b/app/src/main/java/io/legado/app/model/localBook/README.md @@ -0,0 +1,7 @@ +# 本地书籍解析 + +* BaseLocalBookParse.kt 本地书籍解析接口 +* LocalBook.kt 总入口 +* TextFile.kt 解析txt +* EpubFile.kt 解析epub +* UmdFile.kt 解析umd \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/model/localBook/UmdFile.kt b/app/src/main/java/io/legado/app/model/localBook/UmdFile.kt index 811e65d71..9e1a38b48 100644 --- a/app/src/main/java/io/legado/app/model/localBook/UmdFile.kt +++ b/app/src/main/java/io/legado/app/model/localBook/UmdFile.kt @@ -11,7 +11,7 @@ import java.io.File import java.io.InputStream class UmdFile(var book: Book) { - companion object { + companion object : BaseLocalBookParse { private var uFile: UmdFile? = null @Synchronized @@ -25,17 +25,17 @@ class UmdFile(var book: Book) { } @Synchronized - fun getChapterList(book: Book): ArrayList { + override fun getChapterList(book: Book): ArrayList { return getUFile(book).getChapterList() } @Synchronized - fun getContent(book: Book, chapter: BookChapter): String? { + override fun getContent(book: Book, chapter: BookChapter): String? { return getUFile(book).getContent(chapter) } @Synchronized - fun getImage( + override fun getImage( book: Book, href: String ): InputStream? { @@ -44,7 +44,7 @@ class UmdFile(var book: Book) { @Synchronized - fun upBookInfo(book: Book) { + override fun upBookInfo(book: Book) { return getUFile(book).upBookInfo() } }