Skip to content

Commit

Permalink
rename method,fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Gru110110110 committed Aug 4, 2017
1 parent f45834c commit 5218e5b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

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

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ Step 1. Add it in your root build.gradle at the end of repositories:
Step 2. Add the dependency
```gradle
dependencies {
       compile 'com.github.pruas:Biscuit:v1.1.0'
       compile 'com.github.pruas:Biscuit:v1.1.1'
}
```
Step 3. Use it wherever you need
Expand Down Expand Up @@ -197,7 +197,7 @@ Or you can customize like this
```

rxjava executor:
```
```java
Biscuit.with(this)
.path(photos) //可以传入一张图片路径,也可以传入一个图片路径列表
.loggingEnabled(true)//是否输出log 默认输出
Expand All @@ -220,7 +220,7 @@ rxjava executor:
```

rxjava execute:
```
```java
Observable.just(photos).map(new Function<ArrayList<String>, ArrayList<String>>() {
@Override
public ArrayList<String> apply(@NonNull ArrayList<String> strings) throws Exception {
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/java/com/seek/sample/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.util.DisplayMetrics;
import android.util.Log;
Expand All @@ -19,6 +18,7 @@

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Consumer;
import io.reactivex.functions.Function;
import io.reactivex.schedulers.Schedulers;
Expand Down Expand Up @@ -92,12 +92,12 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//// .compressType(Biscuit.SAMPLE)//采用采样率压缩方式,默认是使用缩放压缩方式,也就是和微信的一样。
// .ignoreLessThan(100)//忽略小于100kb的图片不压缩,返回原图路径
// .build().asyncCompress();
//// }else {
//// mBiscuit.addPaths(photos);//传入压缩列表
//// mBiscuit.asyncCompress();//开始压缩
//// }
// }else {
// mBiscuit.addPaths(photos);//传入压缩列表
// mBiscuit.asyncCompress();//开始压缩
// }

// //使用rxjava自定义异步
//使用rxjava自定义异步
// Biscuit.with(this)
// .path(photos) //可以传入一张图片路径,也可以传入一个图片路径列表
// .loggingEnabled(true)//是否输出log 默认输出
Expand Down
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android {
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.1.0"
versionName "1.1.1"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

Expand Down
5 changes: 2 additions & 3 deletions library/src/main/java/com/seek/biscuit/ImageCompressor.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public boolean compress() {
}
options.inJustDecodeBounds = false;
options.inPreferredConfig = ignoreAlpha ? Bitmap.Config.RGB_565 : Bitmap.Config.ARGB_8888;
if (!havePass(options.outWidth / inSampleSize, options.outHeight / inSampleSize)) {
if (!noOutOfMemory(options.outWidth / inSampleSize, options.outHeight / inSampleSize)) {
return false;
}
Bitmap scrBitmap = BitmapFactory.decodeFile(sourcePath.path, options);
Expand Down Expand Up @@ -129,7 +129,7 @@ private void close(ByteArrayOutputStream stream, FileChannel outputChannel) {
}
}

private boolean havePass(int w, int h) {
private boolean noOutOfMemory(int w, int h) {
boolean canScale = checkMemory(w, h);
if (!canScale) {
generateException("no enough memory!");
Expand Down Expand Up @@ -171,7 +171,6 @@ private void generateException(String msg) {
log(TAG, msg);
String path = sourcePath.path;
exception = new CompressException(msg, path);
dispatchError();
}

private boolean checkMemory(int width, int height) {
Expand Down

0 comments on commit 5218e5b

Please sign in to comment.