diff --git a/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDevAssetsLoader.java b/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDevAssetsLoader.java index fb53ba1f..c57ffd16 100644 --- a/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDevAssetsLoader.java +++ b/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDevAssetsLoader.java @@ -33,8 +33,8 @@ public class DoricDevAssetsLoader extends DoricAssetsLoader { return new DoricRemoteResource(doricContext, String.format("http://%s:7778/assets/%s", DoricDev.getInstance().getIP(), - identifier - )); + identifier), + false); } return super.load(doricContext, identifier); } 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 98f4f037..e0954beb 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 @@ -16,7 +16,9 @@ package pub.doric.resource; import com.bumptech.glide.Glide; +import com.bumptech.glide.RequestBuilder; import com.bumptech.glide.load.DataSource; +import com.bumptech.glide.load.engine.DiskCacheStrategy; import com.bumptech.glide.load.engine.GlideException; import com.bumptech.glide.request.RequestListener; import com.bumptech.glide.request.target.Target; @@ -35,15 +37,26 @@ import pub.doric.async.AsyncResult; * @CreateDate: 2021/10/20 */ public class DoricRemoteResource extends DoricResource { + private final boolean needCache; + + public DoricRemoteResource(DoricContext doricContext, String identifier, boolean needCache) { + super(doricContext, identifier); + this.needCache = needCache; + } public DoricRemoteResource(DoricContext doricContext, String identifier) { - super(doricContext, identifier); + this(doricContext, identifier, true); } @Override public AsyncResult fetchRaw() { final AsyncResult result = new AsyncResult<>(); - Glide.with(doricContext.getContext()).download(identifier) + RequestBuilder requestBuilder = Glide.with(doricContext.getContext()).download(identifier); + if (!this.needCache) { + requestBuilder = requestBuilder.diskCacheStrategy(DiskCacheStrategy.NONE) + .skipMemoryCache(true); + } + requestBuilder .listener(new RequestListener() { @Override public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {