mirror of
https://github.com/gedoor/legado.git
synced 2024-07-06 23:47:49 +08:00
优化
This commit is contained in:
parent
2f49d09cd0
commit
d8cc932527
@ -101,13 +101,6 @@ public class LazyResource extends Resource {
|
|||||||
throw new IOException(
|
throw new IOException(
|
||||||
"Could not load the contents of resource: " + this.getHref());
|
"Could not load the contents of resource: " + this.getHref());
|
||||||
} else {
|
} else {
|
||||||
/*掌上书苑有很多自制书OPF的nameSpace格式不标准,强制修复成正确的格式*/
|
|
||||||
if (getHref().endsWith("opf")) {
|
|
||||||
String string = new String(readData)
|
|
||||||
.replace(" smlns=\"", " xmlns=\"")
|
|
||||||
.replace(" mlns=\"", " xmlns=\"");
|
|
||||||
readData = string.getBytes();
|
|
||||||
}
|
|
||||||
this.data = readData;
|
this.data = readData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +48,12 @@ public class PackageDocumentReader extends PackageDocumentBase {
|
|||||||
Resource packageResource, EpubReader epubReader, EpubBook book,
|
Resource packageResource, EpubReader epubReader, EpubBook book,
|
||||||
Resources resources)
|
Resources resources)
|
||||||
throws SAXException, IOException {
|
throws SAXException, IOException {
|
||||||
|
/*掌上书苑有很多自制书OPF的nameSpace格式不标准,强制修复成正确的格式*/
|
||||||
|
String string = new String(packageResource.getData())
|
||||||
|
.replace(" smlns=\"", " xmlns=\"")
|
||||||
|
.replace(" mlns=\"", " xmlns=\"");
|
||||||
|
packageResource.setData(string.getBytes());
|
||||||
|
|
||||||
Document packageDocument = ResourceUtil.getAsDocument(packageResource);
|
Document packageDocument = ResourceUtil.getAsDocument(packageResource);
|
||||||
String packageHref = packageResource.getHref();
|
String packageHref = packageResource.getHref();
|
||||||
resources = fixHrefs(packageHref, resources);
|
resources = fixHrefs(packageHref, resources);
|
||||||
|
@ -75,14 +75,6 @@ public class ResourcesLoader {
|
|||||||
} else {
|
} else {
|
||||||
resource = ResourceUtil
|
resource = ResourceUtil
|
||||||
.createResource(zipEntry.getName(), zipFileWrapper.getInputStream(zipEntry));
|
.createResource(zipEntry.getName(), zipFileWrapper.getInputStream(zipEntry));
|
||||||
/*掌上书苑有很多自制书OPF的nameSpace格式不标准,强制修复成正确的格式*/
|
|
||||||
if (href.endsWith("opf")) {
|
|
||||||
String string = new String(resource.getData())
|
|
||||||
.replace(" smlns=\"", " xmlns=\"")
|
|
||||||
.replace(" mlns=\"", " xmlns=\"");
|
|
||||||
resource.setData(string.getBytes());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resource.getMediaType() == MediaTypes.XHTML) {
|
if (resource.getMediaType() == MediaTypes.XHTML) {
|
||||||
@ -134,17 +126,10 @@ public class ResourcesLoader {
|
|||||||
if ((zipEntry == null) || zipEntry.isDirectory()) {
|
if ((zipEntry == null) || zipEntry.isDirectory()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String href = zipEntry.getName();
|
//String href = zipEntry.getName();
|
||||||
|
|
||||||
// store resource
|
// store resource
|
||||||
Resource resource = ResourceUtil.createResource(zipEntry.getName(), zipInputStream);
|
Resource resource = ResourceUtil.createResource(zipEntry.getName(), zipInputStream);
|
||||||
///*掌上书苑有很多自制书OPF的nameSpace格式不标准,强制修复成正确的格式*/
|
|
||||||
if (href.endsWith("opf")) {
|
|
||||||
String string = new String(resource.getData())
|
|
||||||
.replace(" smlns=\"", " xmlns=\"")
|
|
||||||
.replace(" mlns=\"", " xmlns=\"");
|
|
||||||
resource.setData(string.getBytes());
|
|
||||||
}
|
|
||||||
if (resource.getMediaType() == MediaTypes.XHTML) {
|
if (resource.getMediaType() == MediaTypes.XHTML) {
|
||||||
resource.setInputEncoding(defaultHtmlEncoding);
|
resource.setInputEncoding(defaultHtmlEncoding);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user