Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
aLittleGreens committed Sep 7, 2018
2 parents 2a7edac + f70d85f commit a9e74e2
Showing 1 changed file with 28 additions and 11 deletions.
39 changes: 28 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ImageLoadSample
Bitmap三级缓存,用面向对象六大原则书写,重点是理解设计模式

作者主要是以学习为主,并不是为了造轮子
作者主要是以学习为主,并不是为了造轮子,不作项目使用

## Download
Add the following dependencies in project's gradle.
Expand All @@ -14,29 +14,46 @@ allprojects {
}
dependencies {
implementation 'com.github.cai784921129:ImageLoadSample:1.0'
}
implementation 'com.github.cai784921129:ImageLoadSample:1.1'
}
```

## Useage
1. init The ImageLoad with ImageLoaderConfig
```java
public class BaseApp extends Application{
public class BaseApp extends Application {

@Override
public void onCreate() {
super.onCreate();
ImageLoader.init(this);
ImageLoadConfig imageLoadConfig = new ImageLoadConfig().
setLoadPolicy(new SerialPolicy()). //设置队列顺序,默认是顺序
setCache(DoubleCache.getInstance(this)). //设置缓存策略,默认内存缓存
setLoadingPlaceholder(R.drawable.loading).
setNotFoundPlaceholder(R.drawable.not_found).
setThreadCount(5); //设置线程数量,默认cpu核数+1
ImageLoader.getInstance().init(imageLoadConfig);
}
}
```
2、load bitmap
## load bitmap
a、加载网络图片
```java
ImageLoader.getInstance().
setImageCache(DoubleCache.getInstance(context)).
setDefaultImg(R.mipmap.ic_launcher).
setErrorImg(R.mipmap.ic_launcher_round).
displayImage(url, imageView);
ImageLoader.getInstance().
setLoadingRedId(R.mipmap.ic_launcher).
setErrorResId(R.mipmap.ic_launcher_round).
displayImage(imageView,imgUrl);

```
b、加载sdcard图片(加载本地图片没有缓存,只是对bitmap做个2次采样)
```java
ImageLoader.getInstance().
displayImage(imageView,"file://sdcard/xxx/image.jpg");
```
c、加载resID资源
```java
ImageLoader.getInstance().
displayImage(imageView, "res://"+R.mipmap.ic_launcher_round);
```

0 comments on commit a9e74e2

Please sign in to comment.