From fbe010a3bcb69e86e0a4806071752cce03a9dc79 Mon Sep 17 00:00:00 2001 From: ag2s20150909 Date: Thu, 13 May 2021 11:44:06 +0800 Subject: [PATCH 1/3] =?UTF-8?q?resource=E4=B8=BAnull=E6=97=B6=E4=B8=8D?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=A0=87=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/ag2s/epublib/domain/TitledResourceReference.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/epublib/src/main/java/me/ag2s/epublib/domain/TitledResourceReference.java b/epublib/src/main/java/me/ag2s/epublib/domain/TitledResourceReference.java index cba1ed83f..076b9952b 100644 --- a/epublib/src/main/java/me/ag2s/epublib/domain/TitledResourceReference.java +++ b/epublib/src/main/java/me/ag2s/epublib/domain/TitledResourceReference.java @@ -69,8 +69,11 @@ public class TitledResourceReference extends ResourceReference @Override public Resource getResource() { - //修复getTitle为null的bug - resource.setTitle(title); + //resource为null时不设置标题 + if(this.resource!=null&&this.title!=null){ + resource.setTitle(title); + } + return resource; } From f7ab4b71405f8c0455cbd15e7ea6470c340a5274 Mon Sep 17 00:00:00 2001 From: ag2s20150909 Date: Thu, 13 May 2021 11:59:57 +0800 Subject: [PATCH 2/3] =?UTF-8?q?resource=E4=B8=BAnull=E6=97=B6=E4=B8=8D?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=A0=87=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epublib/domain/FileResourceProvider.java | 18 ++++++++++++------ .../domain/TitledResourceReference.java | 4 ++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/epublib/src/main/java/me/ag2s/epublib/domain/FileResourceProvider.java b/epublib/src/main/java/me/ag2s/epublib/domain/FileResourceProvider.java index a9db2b5d9..e273712d6 100644 --- a/epublib/src/main/java/me/ag2s/epublib/domain/FileResourceProvider.java +++ b/epublib/src/main/java/me/ag2s/epublib/domain/FileResourceProvider.java @@ -16,21 +16,27 @@ public class FileResourceProvider implements LazyResourceProvider { /** * 创建一个文件夹里面文件夹的LazyResourceProvider,用于LazyResource。 - * @param dir 文件的目录 + * @param parentDir 文件的目录 */ - public FileResourceProvider(String dir) { - this.dir = dir; + public FileResourceProvider(String parentDir) { + this.dir = parentDir; } /** * 创建一个文件夹里面文件夹的LazyResourceProvider,用于LazyResource。 - * @param dirfile 文件夹 + * @param parentFile 文件夹 */ @SuppressWarnings("unused") - public FileResourceProvider(File dirfile) { - this.dir = dirfile.getPath(); + public FileResourceProvider(File parentFile) { + this.dir = parentFile.getPath(); } + /** + * 根据子文件名href,再父目录下读取文件获取FileInputStream + * @param href 子文件名href + * @return 对应href的FileInputStream + * @throws IOException 抛出IOException + */ @Override public InputStream getResourceStream(String href) throws IOException { return new FileInputStream(new File(dir, href)); diff --git a/epublib/src/main/java/me/ag2s/epublib/domain/TitledResourceReference.java b/epublib/src/main/java/me/ag2s/epublib/domain/TitledResourceReference.java index 076b9952b..6357bc489 100644 --- a/epublib/src/main/java/me/ag2s/epublib/domain/TitledResourceReference.java +++ b/epublib/src/main/java/me/ag2s/epublib/domain/TitledResourceReference.java @@ -1,5 +1,7 @@ package me.ag2s.epublib.domain; +import android.util.Log; + import me.ag2s.epublib.Constants; import me.ag2s.epublib.util.StringUtil; @@ -72,6 +74,8 @@ public class TitledResourceReference extends ResourceReference //resource为null时不设置标题 if(this.resource!=null&&this.title!=null){ resource.setTitle(title); + }else { + Log.e(TitledResourceReference.class.getSimpleName(),"警告:resource 为null,忽略设置标题。"); } return resource; From e40761740581c5b2111d0c2072e6b75020171b2f Mon Sep 17 00:00:00 2001 From: ag2s20150909 Date: Thu, 13 May 2021 12:09:56 +0800 Subject: [PATCH 3/3] =?UTF-8?q?resource=E4=B8=BAnull=E6=97=B6=E4=B8=8D?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=A0=87=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/ag2s/epublib/domain/TitledResourceReference.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/epublib/src/main/java/me/ag2s/epublib/domain/TitledResourceReference.java b/epublib/src/main/java/me/ag2s/epublib/domain/TitledResourceReference.java index 6357bc489..e7fe769ad 100644 --- a/epublib/src/main/java/me/ag2s/epublib/domain/TitledResourceReference.java +++ b/epublib/src/main/java/me/ag2s/epublib/domain/TitledResourceReference.java @@ -1,12 +1,10 @@ package me.ag2s.epublib.domain; -import android.util.Log; +import java.io.Serializable; import me.ag2s.epublib.Constants; import me.ag2s.epublib.util.StringUtil; -import java.io.Serializable; - public class TitledResourceReference extends ResourceReference implements Serializable { @@ -74,8 +72,6 @@ public class TitledResourceReference extends ResourceReference //resource为null时不设置标题 if(this.resource!=null&&this.title!=null){ resource.setTitle(title); - }else { - Log.e(TitledResourceReference.class.getSimpleName(),"警告:resource 为null,忽略设置标题。"); } return resource;