Skip to content

Commit

Permalink
add exception handle.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunzxyong committed Oct 23, 2018
1 parent 77a7ab9 commit 14aff4e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
*/
public interface FileBatchCallback extends Callback {

void callback(boolean isSuccess, String[] outfile, Throwable t);
void callback(boolean isSuccess, String[] outfiles, Throwable t);

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
*/
public interface FileWithBitmapBatchCallback extends Callback {

void callback(boolean isSuccess, Bitmap[] bitmaps, String[] outfile, Throwable t);
void callback(boolean isSuccess, Bitmap[] bitmaps, String[] outfiles, Throwable t);

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ public void batchCompress(BitmapBatchCallback callback) {
}

private void impl(Callback callback) {
if (mSource == null)
if (mSource == null) {
if (callback instanceof BitmapBatchCallback) {
((BitmapBatchCallback) callback).callback(false, null, new RuntimeException("the source is null!"));
}
return;
}

if (mCompressOptions == null)
mCompressOptions = new Tiny.BitmapCompressOptions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,14 @@ public void batchCompress(FileWithBitmapBatchCallback callback) {
}

private void impl(Callback callback) {
if (mSource == null)
if (mSource == null) {
if (callback instanceof FileBatchCallback) {
((FileBatchCallback) callback).callback(false, null, new RuntimeException("the source is null!"));
} else if (callback instanceof FileWithBitmapBatchCallback) {
((FileWithBitmapBatchCallback) callback).callback(false, null, null, new RuntimeException("the source is null!"));
}
return;
}

boolean shouldReturnBitmap = false;

Expand Down
8 changes: 7 additions & 1 deletion tiny/src/main/java/com/zxy/tiny/core/FileCompressEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,14 @@ public void compress(FileWithBitmapCallback callback) {
}

private void impl(Callback callback) {
if (mSource == null)
if (mSource == null) {
if (callback instanceof FileCallback) {
((FileCallback) callback).callback(false, null, new RuntimeException("the source is null!"));
} else if (callback instanceof FileWithBitmapCallback) {
((FileWithBitmapCallback) callback).callback(false, null, null, new RuntimeException("the source is null!"));
}
return;
}

boolean shouldReturnBitmap = false;

Expand Down

0 comments on commit 14aff4e

Please sign in to comment.