mirror of
https://github.com/gedoor/legado.git
synced 2024-07-04 23:36:56 +08:00
优化
This commit is contained in:
parent
071a348962
commit
99fcd6956b
|
@ -134,16 +134,6 @@ class EpubFile(var book: Book) {
|
|||
}
|
||||
|
||||
private fun getContent(chapter: BookChapter): String? {
|
||||
/**
|
||||
* <image width="1038" height="670" xlink:href="..."/>
|
||||
* ...titlepage.xhtml
|
||||
* 大多数epub文件的封面页都会带有cover,可以一定程度上解决封面读取问题
|
||||
*/
|
||||
if (chapter.url.contains("titlepage.xhtml") ||
|
||||
chapter.url.contains("cover")
|
||||
) {
|
||||
return "<img src=\"cover.jpeg\" />"
|
||||
}
|
||||
/*获取当前章节文本*/
|
||||
val contents = epubBookContents ?: return null
|
||||
val nextChapterFirstResourceHref = chapter.getVariable("nextUrl").substringBeforeLast("#")
|
||||
|
@ -201,6 +191,17 @@ class EpubFile(var book: Book) {
|
|||
}
|
||||
|
||||
private fun getBody(res: Resource, startFragmentId: String?, endFragmentId: String?): Element {
|
||||
/**
|
||||
* <image width="1038" height="670" xlink:href="..."/>
|
||||
* ...titlepage.xhtml
|
||||
* 大多数epub文件的封面页都会带有cover,可以一定程度上解决封面读取问题
|
||||
*/
|
||||
if (res.href.contains("titlepage.xhtml") ||
|
||||
res.href.contains("cover")
|
||||
) {
|
||||
return Jsoup.parseBodyFragment("<img src=\"cover.jpeg\" />")
|
||||
}
|
||||
|
||||
// Jsoup可能会修复不规范的xhtml文件 解析处理后再获取
|
||||
var bodyElement = Jsoup.parse(String(res.data, mCharset)).body()
|
||||
bodyElement.children().run {
|
||||
|
|
|
@ -136,18 +136,18 @@ public class NCXDocumentV3 {
|
|||
}
|
||||
|
||||
private static List<TOCReference> doToc(Node n, EpubBook book) {
|
||||
List<TOCReference> result = new ArrayList<>();
|
||||
|
||||
if (n == null || n.getNodeType() != Document.ELEMENT_NODE) {
|
||||
return result;
|
||||
} else {
|
||||
Element el = (Element) n;
|
||||
NodeList nodeList = el.getElementsByTagName(XHTMLTgs.li);
|
||||
for (int i = 0; i < nodeList.getLength(); i++) {
|
||||
result.add(readTOCReference((Element) nodeList.item(i), book));
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return result;
|
||||
|
||||
Element el = (Element) n;
|
||||
Node node = el.getElementsByTagName(XHTMLTgs.ol).item(0);
|
||||
|
||||
if (node == null || node.getNodeType() != Document.ELEMENT_NODE) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
return readTOCReferences(node.getChildNodes(), book);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user