diff --git a/doric-android/doric/src/main/java/pub/doric/resource/DoricAndroidLoader.java b/doric-android/doric/src/main/java/pub/doric/resource/DoricAndroidLoader.java index 08552800..6cb92334 100644 --- a/doric-android/doric/src/main/java/pub/doric/resource/DoricAndroidLoader.java +++ b/doric-android/doric/src/main/java/pub/doric/resource/DoricAndroidLoader.java @@ -37,6 +37,6 @@ public class DoricAndroidLoader implements DoricResourceLoader { @Override public DoricResource load(DoricContext doricContext, String identifier) { - return new DoricAndroidResource(this.defType, identifier, doricContext); + return new DoricAndroidResource(this.defType, doricContext, identifier); } } diff --git a/doric-android/doric/src/main/java/pub/doric/resource/DoricAndroidResource.java b/doric-android/doric/src/main/java/pub/doric/resource/DoricAndroidResource.java index 375b09e0..11ef4223 100644 --- a/doric-android/doric/src/main/java/pub/doric/resource/DoricAndroidResource.java +++ b/doric-android/doric/src/main/java/pub/doric/resource/DoricAndroidResource.java @@ -27,12 +27,10 @@ import pub.doric.async.AsyncResult; */ public class DoricAndroidResource extends DoricResource { private final String defType; - private final String identifier; - public DoricAndroidResource(String defType, String identifier, DoricContext doricContext) { - super(doricContext); + public DoricAndroidResource(String defType, DoricContext doricContext, String identifier) { + super(doricContext, identifier); this.defType = defType; - this.identifier = identifier; } @Override diff --git a/doric-android/doric/src/main/java/pub/doric/resource/DoricAssetsLoader.java b/doric-android/doric/src/main/java/pub/doric/resource/DoricAssetsLoader.java index 03083a0a..73cacd62 100644 --- a/doric-android/doric/src/main/java/pub/doric/resource/DoricAssetsLoader.java +++ b/doric-android/doric/src/main/java/pub/doric/resource/DoricAssetsLoader.java @@ -30,6 +30,6 @@ public class DoricAssetsLoader implements DoricResourceLoader { @Override public DoricResource load(DoricContext doricContext, String identifier) { - return new DoricAssetsResource(identifier, doricContext); + return new DoricAssetsResource(doricContext, identifier); } } diff --git a/doric-android/doric/src/main/java/pub/doric/resource/DoricAssetsResource.java b/doric-android/doric/src/main/java/pub/doric/resource/DoricAssetsResource.java index 8dd3063a..e4f7172d 100644 --- a/doric-android/doric/src/main/java/pub/doric/resource/DoricAssetsResource.java +++ b/doric-android/doric/src/main/java/pub/doric/resource/DoricAssetsResource.java @@ -27,18 +27,15 @@ import pub.doric.async.AsyncResult; * @CreateDate: 2021/10/20 */ public class DoricAssetsResource extends DoricResource { - private final String path; - - public DoricAssetsResource(String path, DoricContext doricContext) { - super(doricContext); - this.path = path; + public DoricAssetsResource(DoricContext doricContext, String identifier) { + super(doricContext, identifier); } @Override public AsyncResult asInputStream() { AsyncResult result = new AsyncResult<>(); try { - InputStream inputStream = doricContext.getContext().getAssets().open(path); + InputStream inputStream = doricContext.getContext().getAssets().open(identifier); result.setResult(inputStream); } catch (IOException e) { result.setError(e); diff --git a/doric-android/doric/src/main/java/pub/doric/resource/DoricBase64Resource.java b/doric-android/doric/src/main/java/pub/doric/resource/DoricBase64Resource.java index d6d82e8c..d7608db6 100644 --- a/doric-android/doric/src/main/java/pub/doric/resource/DoricBase64Resource.java +++ b/doric-android/doric/src/main/java/pub/doric/resource/DoricBase64Resource.java @@ -32,11 +32,9 @@ import pub.doric.utils.DoricUtils; * @CreateDate: 2021/10/22 */ class DoricBase64Resource extends DoricResource { - private final String identifier; public DoricBase64Resource(DoricContext doricContext, String identifier) { - super(doricContext); - this.identifier = identifier; + super(doricContext, identifier); } @Override diff --git a/doric-android/doric/src/main/java/pub/doric/resource/DoricLocalResource.java b/doric-android/doric/src/main/java/pub/doric/resource/DoricLocalResource.java index 40c53b12..5e54504e 100644 --- a/doric-android/doric/src/main/java/pub/doric/resource/DoricLocalResource.java +++ b/doric-android/doric/src/main/java/pub/doric/resource/DoricLocalResource.java @@ -28,18 +28,16 @@ import pub.doric.async.AsyncResult; * @CreateDate: 2021/10/20 */ public class DoricLocalResource extends DoricResource { - private final String filePath; public DoricLocalResource(DoricContext doricContext, String identifier) { - super(doricContext); - this.filePath = identifier; + super(doricContext, identifier); } @Override public AsyncResult asInputStream() { AsyncResult result = new AsyncResult<>(); try { - result.setResult(new FileInputStream(filePath)); + result.setResult(new FileInputStream(identifier)); } catch (FileNotFoundException e) { result.setError(e); } diff --git a/doric-android/doric/src/main/java/pub/doric/resource/DoricRemoteResource.java b/doric-android/doric/src/main/java/pub/doric/resource/DoricRemoteResource.java index f44d7523..d1ef71bf 100644 --- a/doric-android/doric/src/main/java/pub/doric/resource/DoricRemoteResource.java +++ b/doric-android/doric/src/main/java/pub/doric/resource/DoricRemoteResource.java @@ -37,17 +37,14 @@ import pub.doric.async.AsyncResult; */ public class DoricRemoteResource extends DoricResource { - private final String url; - public DoricRemoteResource(DoricContext doricContext, String identifier) { - super(doricContext); - this.url = identifier; + super(doricContext, identifier); } @Override public AsyncResult asInputStream() { final AsyncResult result = new AsyncResult<>(); - Glide.with(doricContext.getContext()).download(url) + Glide.with(doricContext.getContext()).download(identifier) .listener(new RequestListener() { @Override public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { diff --git a/doric-android/doric/src/main/java/pub/doric/resource/DoricResource.java b/doric-android/doric/src/main/java/pub/doric/resource/DoricResource.java index 6449067d..98fa4596 100644 --- a/doric-android/doric/src/main/java/pub/doric/resource/DoricResource.java +++ b/doric-android/doric/src/main/java/pub/doric/resource/DoricResource.java @@ -28,9 +28,11 @@ import pub.doric.async.AsyncResult; */ public abstract class DoricResource { protected final DoricContext doricContext; + protected final String identifier; - public DoricResource(DoricContext doricContext) { + public DoricResource(DoricContext doricContext, String identifier) { this.doricContext = doricContext; + this.identifier = identifier; } public abstract AsyncResult asInputStream();