Skip to content

Commit

Permalink
Add instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanqilong committed Nov 28, 2016
1 parent 1c76416 commit 98830ac
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 26 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ GitHub地址: [https://github.com/crazycodeboy/TakePhoto](https://github.com/c
- [API](#api)
- [兼容性](#兼容性)
- [贡献](#贡献)
- [更新说明](#更新说明)
- [最后](#混淆)

## 安装说明
Expand Down Expand Up @@ -440,6 +441,13 @@ eg:
## 贡献
如果你在使用TakePhoto中遇到任何问题可以提[Issues](https://github.com/crazycodeboy/TakePhoto/issues)出来。另外欢迎大家为TakePhoto贡献智慧,欢迎大家[Fork and Pull requests](https://github.com/crazycodeboy/TakePhoto)

## 更新说明
**2016/11/28**
1、压缩成功后返回原图路径(originalPath), 以便用户可以自行处理原图。
2、压缩成功后压缩路径path改为compressPath。
2、压缩成功后返回图片来源类型,现在分CAMERA, OTHER两种。
3、用户可以配置CompressConfig.enableReserveRaw(boolean)方法,ture保留原图,false删除原图,当且仅当类型为CAMERA此配置才有效

## 最后

### 关于代码混淆
Expand Down
6 changes: 3 additions & 3 deletions simple/src/main/java/com/jph/simple/ResultActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ private void showImg() {
View view = LayoutInflater.from(this).inflate(R.layout.image_show, null);
ImageView imageView1 = (ImageView) view.findViewById(R.id.imgShow1);
ImageView imageView2 = (ImageView) view.findViewById(R.id.imgShow2);
Glide.with(this).load(new File(images.get(i).getPath())).into(imageView1);
Glide.with(this).load(new File(images.get(i + 1).getPath())).into(imageView2);
Glide.with(this).load(new File(images.get(i).getCompressPath())).into(imageView1);
Glide.with(this).load(new File(images.get(i + 1).getCompressPath())).into(imageView2);
linearLayout.addView(view);
}
if (images.size() % 2 == 1) {
View view = LayoutInflater.from(this).inflate(R.layout.image_show, null);
ImageView imageView1 = (ImageView) view.findViewById(R.id.imgShow1);
Glide.with(this).load(new File(images.get(images.size() - 1).getPath())).into(imageView1);
Glide.with(this).load(new File(images.get(images.size() - 1).getCompressPath())).into(imageView1);
linearLayout.addView(view);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public TakePhoto getTakePhoto(){
}
@Override
public void takeSuccess(TResult result) {
Log.i(TAG,"takeSuccess:" + result.getImage().getPath());
Log.i(TAG,"takeSuccess:" + result.getImage().getCompressPath());
}
@Override
public void takeFail(TResult result,String msg) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public TakePhoto getTakePhoto(){
}
@Override
public void takeSuccess(TResult result) {
Log.i(TAG,"takeSuccess:" + result.getImage().getPath());
Log.i(TAG,"takeSuccess:" + result.getImage().getCompressPath());
}
@Override
public void takeFail(TResult result,String msg) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public TakePhoto getTakePhoto(){
}
@Override
public void takeSuccess(TResult result) {
Log.i(TAG,"takeSuccess:" + result.getImage().getPath());
Log.i(TAG,"takeSuccess:" + result.getImage().getCompressPath());
}
@Override
public void takeFail(TResult result,String msg) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ public void onCompressFailed(ArrayList<TImage> images, String msg) {
if(!compressConfig.isEnableReserveRaw()) {
deleteRawFile(images);
}
handleTakeCallBack(TResult.of(images), String.format(contextWrap.getActivity().getResources().getString(R.string.tip_compress_failed), message.length > 0 ? message[0] : "", msg, result.getImage().getPath()));
handleTakeCallBack(TResult.of(images), String.format(contextWrap.getActivity().getResources().getString(R.string.tip_compress_failed), message.length > 0 ? message[0] : "", msg, result.getImage().getCompressPath()));
if (wailLoadDialog != null && !contextWrap.getActivity().isFinishing())
wailLoadDialog.dismiss();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,20 @@ public void compress() {
}

private void compress(final TImage image) {
if (TextUtils.isEmpty(image.getPath())){
if (TextUtils.isEmpty(image.getOriginalPath())){
continueCompress(image,false);
return;
}

File file = new File(image.getPath());
File file = new File(image.getOriginalPath());
if (file == null || !file.exists() || !file.isFile()){
continueCompress(image,false);
return;
}

compressImageUtil.compress(image.getPath(), new CompressImageUtil.CompressListener() {
compressImageUtil.compress(image.getOriginalPath(), new CompressImageUtil.CompressListener() {
@Override
public void onCompressSuccess(String imgPath) {
image.setPath(imgPath);
image.setCompressPath(imgPath);
continueCompress(image,true);
}
Expand Down Expand Up @@ -90,7 +89,7 @@ private void handleCompressCallBack(String...message){

for(TImage image:images){
if(!image.isCompressed()){
listener.onCompressFailed(images,image.getPath()+" is compress failures");
listener.onCompressFailed(images,image.getCompressPath()+" is compress failures");
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void compress() {
listener.onCompressFailed(images, " There are pictures of compress is null.");
return;
}
files.add(new File(image.getPath()));
files.add(new File(image.getOriginalPath()));
}
if (images.size() == 1) {
compressOne();
Expand All @@ -70,7 +70,6 @@ public void onStart() {
@Override
public void onSuccess(File file) {
TImage image=images.get(0);
image.setPath(file.getPath());
image.setCompressPath(file.getPath());
image.setCompressed(true);
listener.onCompressSuccess(images);
Expand Down Expand Up @@ -111,7 +110,7 @@ private void handleCompressCallBack(List<File> files) {
for (int i = 0, j = images.size(); i < j; i++) {
TImage image=images.get(i);
image.setCompressed(true);
image.setPath(files.get(i).getPath());
image.setCompressPath(files.get(i).getPath());
}
listener.onCompressSuccess(images);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

/**
* TakePhoto 操作成功返回的处理结果
*
* Author: JPH
* Date: 2016/8/11 17:01
*/
public class TImage implements Serializable{
private String path;
private String originalPath;
private String compressPath;
private FromType fromType;
Expand All @@ -23,24 +23,14 @@ public static TImage of(Uri uri, FromType fromType){
return new TImage(uri, fromType);
}
private TImage(String path, FromType fromType) {
this.path = path;
this.originalPath = path;
this.fromType = fromType;
}
private TImage(Uri uri, FromType fromType) {
this.path = uri.getPath();
this.originalPath = uri.getPath();
this.fromType = fromType;
}

public String getPath() {
return path;
}

public void setPath(String path) {
this.path = path;
}

public String getOriginalPath() {
return originalPath;
}
Expand Down

0 comments on commit 98830ac

Please sign in to comment.