Skip to content

Commit

Permalink
upload 1.1.4 version
Browse files Browse the repository at this point in the history
  • Loading branch information
郑梓斌 committed May 12, 2018
1 parent f4c57ee commit da8adf0
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
30 changes: 25 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,37 @@
# 导入

```sh
compile 'top.zibin:Luban:1.1.3'
implementation 'top.zibin:Luban:1.1.4'
```

# 使用

### 方法列表

方法 | 描述
---- | ----
load | 传入原图
ignoreBy | 不压缩的阈值,单位为K
setTargetDir | 缓存压缩图片路径
filter | 设置开启压缩条件
setCompressListener | 压缩回调

### 异步调用

`Luban`内部采用`IO`线程进行图片压缩,外部调用只需设置好结果监听即可:

```java
Luban.with(this)
.load(photos) // 传人要压缩的图片列表
.ignoreBy(100) // 忽略不压缩图片的大小
.setTargetDir(getPath()) // 设置压缩后文件存储位置
.setCompressListener(new OnCompressListener() { //设置回调
.load(photos)
.ignoreBy(100)
.setTargetDir(getPath())
.filter(new CompressionPredicate() {
@Override
public boolean apply(String path) {
return !(TextUtils.isEmpty(path) || path.toLowerCase().endsWith(".gif"));
}
})
.setCompressListener(new OnCompressListener() {
@Override
public void onStart() {
// TODO 压缩开始前调用,可以在方法内启动 loading UI
Expand Down Expand Up @@ -81,6 +97,10 @@ Flowable.just(photos)
.subscribe();
```

### RELEASE NOTE

* **1.1.4**:load方法新增传入类型以兼容Uri图片地址

# License

Copyright 2016 Zheng Zibin
Expand Down
1 change: 1 addition & 0 deletions example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dependencies {

implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:exifinterface:27.1.1'

implementation 'com.nineoldandroids:library:2.4.0'

Expand Down
16 changes: 7 additions & 9 deletions example/src/main/java/top/zibin/luban/example/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,7 @@ private void compressWithRx(final List<String> photos) {
.map(new Function<List<String>, List<File>>() {
@Override
public List<File> apply(@NonNull List<String> list) throws Exception {
return Luban.with(MainActivity.this)
.load(list)
.filter(new CompressionPredicate() {
@Override
public boolean apply(String path) {
return !(TextUtils.isEmpty(path) || path.toLowerCase().endsWith(".gif"));
}
})
.get();
return Luban.with(MainActivity.this).load(list).get();
}
})
.observeOn(AndroidSchedulers.mainThread())
Expand All @@ -117,6 +109,12 @@ private void compressWithLs(final List<String> photos) {
.load(photos)
.ignoreBy(100)
.setTargetDir(getPath())
.filter(new CompressionPredicate() {
@Override
public boolean apply(String path) {
return !(TextUtils.isEmpty(path) || path.toLowerCase().endsWith(".gif"));
}
})
.setCompressListener(new OnCompressListener() {
@Override
public void onStart() {
Expand Down

0 comments on commit da8adf0

Please sign in to comment.