Skip to content

Commit

Permalink
除去内存泄漏问题
Browse files Browse the repository at this point in the history
  • Loading branch information
nanchen2251 committed Apr 15, 2017
1 parent f1590ec commit 06ade16
Showing 1 changed file with 0 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@
import android.graphics.Bitmap;
import android.net.Uri;


import java.io.File;

import rx.Observable;
import rx.functions.Func0;

/**
* 压缩方法工具类
*
Expand All @@ -19,7 +15,6 @@
*/

public class CompressHelper {
private static volatile CompressHelper INSTANCE;
private Context context;
/**
* 最大宽度,默认为720
Expand Down Expand Up @@ -61,17 +56,6 @@ private CompressHelper(Context context) {
destinationDirectoryPath = context.getCacheDir().getPath() + File.pathSeparator + FileUtil.FILES_PATH;
}

public static CompressHelper getDefault(Context context) {
if (INSTANCE == null) {
synchronized (CompressHelper.class) {
if (INSTANCE == null) {
INSTANCE = new CompressHelper(context);
}
}
}
return INSTANCE;
}

/**
* 压缩成文件
* @param file 原始文件
Expand All @@ -92,24 +76,6 @@ public Bitmap compressToBitmap(File file) {
return ImageUtil.getScaledBitmap(context, Uri.fromFile(file), maxWidth, maxHeight, bitmapConfig);
}

public Observable<File> compressToFileAsObservable(final File file) {
return Observable.defer(new Func0<Observable<File>>() {
@Override
public Observable<File> call() {
return Observable.just(compressToFile(file));
}
});
}

public Observable<Bitmap> compressToBitmapAsObservable(final File file) {
return Observable.defer(new Func0<Observable<Bitmap>>() {
@Override
public Observable<Bitmap> call() {
return Observable.just(compressToBitmap(file));
}
});
}


/**
* 采用建造者模式,设置Builder
Expand Down

0 comments on commit 06ade16

Please sign in to comment.