Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
29 changes: 29 additions & 0 deletions ImageLoaderDemo/.idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 1 addition & 14 deletions ImageLoaderDemo/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions ImageLoaderDemo/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.view.View;
import android.view.animation.Animation;

import com.bumptech.glide.load.Key;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.animation.ViewPropertyAnimation;

Expand Down Expand Up @@ -70,6 +71,8 @@ public class SingleConfig {
private int shapeMode;//默认矩形,可选直角矩形,圆形/椭圆
private int rectRoundRadius;//圆角矩形时圆角的半径
private DiskCacheStrategy diskCacheStrategy;//是否跳过磁盘存储
private boolean isSkipMemoryCache;//是否跳过内存缓存
private Key signature;
private int scaleMode;//填充模式,默认centercrop,可选fitXY,centerInside...

private BitmapListener bitmapListener;
Expand Down Expand Up @@ -101,6 +104,8 @@ public SingleConfig(ConfigBuilder builder) {
this.scaleMode = builder.scaleMode;

this.diskCacheStrategy = builder.diskCacheStrategy;
this.isSkipMemoryCache = builder.skipMemoryCache;
this.signature = builder.signature;

this.animationId = builder.animationId;
this.animationType = builder.animationType;
Expand Down Expand Up @@ -351,6 +356,22 @@ public boolean isNeedVignette() {
return isNeedVignette;
}

public boolean isSkipMemoryCache() {
return isSkipMemoryCache;
}

public void setSkipMemoryCache(boolean skipMemoryCache) {
isSkipMemoryCache = skipMemoryCache;
}

public Key getSignature() {
return signature;
}

public void setSignature(Key signature) {
this.signature = signature;
}

public interface BitmapListener {
void onSuccess(Bitmap bitmap);

Expand Down Expand Up @@ -423,6 +444,8 @@ public static class ConfigBuilder {
private int rectRoundRadius;//圆角矩形时圆角的半径

private DiskCacheStrategy diskCacheStrategy;
private boolean skipMemoryCache;
private Key signature;

private int scaleMode;//填充模式,默认centercrop,可选fitXY,centerInside...

Expand Down Expand Up @@ -669,6 +692,26 @@ public ConfigBuilder diskCacheStrategy(DiskCacheStrategy diskCacheStrategy) {
return this;
}

/**
* 内存缓存
* @param isSkipMemoryCache
* @return
*/
public ConfigBuilder skipMemoryCache(boolean isSkipMemoryCache){
this.skipMemoryCache = isSkipMemoryCache;
return this;
}

/**
* 图片签名
* @param signature
* @return
*/
public ConfigBuilder signature(Key signature){
this.signature = signature;
return this;
}

/**
* 拉伸/裁剪模式
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@ public void onResourceReady(Bitmap bitmap, GlideAnimation glideAnimation) {
request.diskCacheStrategy(config.getDiskCacheStrategy());
}

//是否跳过内存缓存
if(config.isSkipMemoryCache()){
request.skipMemoryCache(config.isSkipMemoryCache());
}

//添加图片签名
if(config.getSignature()!=null){
request.signature(config.getSignature());
}

//设置图片加载动画
setAnimator(config, request);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.animation.ViewPropertyAnimation;
import com.bumptech.glide.signature.StringSignature;

import java.io.File;

Expand Down Expand Up @@ -96,8 +97,11 @@ public void animate(View view) {
}
};

//TODO--修改图片签名,和跳过内存缓存
ImageLoader.with(this)
.url(URL1)
.signature(new StringSignature(System.currentTimeMillis()+""))
.skipMemoryCache(true)
.animate(animationObject)
.placeHolder(R.mipmap.ic_launcher)
.scale(ScaleMode.CENTER_CROP)
Expand Down