Skip to content

Commit

Permalink
add an exception thrown interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
郑晓勇 committed Oct 10, 2017
1 parent 4c09129 commit f123a5e
Show file tree
Hide file tree
Showing 26 changed files with 141 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ private void testFile() {
File[] files = new File[]{outfile1, outfile2, outfile3, outfile4};
Tiny.getInstance().source(files).batchAsBitmap().withOptions(compressOptions).batchCompress(new BitmapBatchCallback() {
@Override
public void callback(boolean isSuccess, Bitmap[] bitmaps) {
public void callback(boolean isSuccess, Bitmap[] bitmaps,Throwable t) {
if (!isSuccess) {
mCompressTv.setText("batch compress bitmap failed!");
return;
Expand Down Expand Up @@ -255,7 +255,7 @@ private void testBitmap() {
Bitmap[] bitmaps = new Bitmap[]{originBitmap1, originBitmap2, originBitmap3, originBitmap4};
Tiny.getInstance().source(bitmaps).batchAsBitmap().withOptions(compressOptions).batchCompress(new BitmapBatchCallback() {
@Override
public void callback(boolean isSuccess, Bitmap[] bitmaps) {
public void callback(boolean isSuccess, Bitmap[] bitmaps,Throwable t) {
if (!isSuccess) {
mCompressTv.setText("batch compress bitmap failed!");
return;
Expand Down Expand Up @@ -289,7 +289,7 @@ private void testResource() {
int[] resIds = new int[]{R.drawable.test_1, R.drawable.test_2, R.drawable.test_3, R.drawable.test};
Tiny.getInstance().source(resIds).batchAsBitmap().withOptions(compressOptions).batchCompress(new BitmapBatchCallback() {
@Override
public void callback(boolean isSuccess, Bitmap[] bitmaps) {
public void callback(boolean isSuccess, Bitmap[] bitmaps,Throwable t) {
if (!isSuccess) {
mCompressTv.setText("batch compress bitmap failed!");
return;
Expand Down Expand Up @@ -323,7 +323,7 @@ private void testUri() {
Uri[] uris = new Uri[]{Uri.parse(url1), Uri.parse(url2), Uri.parse(url3), Uri.parse(url4)};
Tiny.getInstance().source(uris).batchAsBitmap().withOptions(compressOptions).batchCompress(new BitmapBatchCallback() {
@Override
public void callback(boolean isSuccess, Bitmap[] bitmaps) {
public void callback(boolean isSuccess, Bitmap[] bitmaps,Throwable t) {
if (!isSuccess) {
mCompressTv.setText("batch compress bitmap failed!");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ private void testFile() {
File[] files = new File[]{outfile1, outfile2, outfile3, outfile4};
Tiny.getInstance().source(files).batchAsFile().withOptions(compressOptions).batchCompress(new FileBatchCallback() {
@Override
public void callback(boolean isSuccess, String[] outfile) {
public void callback(boolean isSuccess, String[] outfile, Throwable t) {
if (!isSuccess) {
mCompressTv.setText("batch compress file failed!");
return;
Expand Down Expand Up @@ -261,7 +261,7 @@ private void testBitmap() {

Tiny.getInstance().source(bitmaps).batchAsFile().withOptions(compressOptions).batchCompress(new FileBatchCallback() {
@Override
public void callback(boolean isSuccess, String[] outfile) {
public void callback(boolean isSuccess, String[] outfile, Throwable t) {
if (!isSuccess) {
mCompressTv.setText("batch compress file failed!");
return;
Expand Down Expand Up @@ -297,7 +297,7 @@ private void testResource() {

Tiny.getInstance().source(resIds).batchAsFile().withOptions(compressOptions).batchCompress(new FileBatchCallback() {
@Override
public void callback(boolean isSuccess, String[] outfile) {
public void callback(boolean isSuccess, String[] outfile, Throwable t) {
if (!isSuccess) {
mCompressTv.setText("batch compress file failed!");
return;
Expand Down Expand Up @@ -334,7 +334,7 @@ private void testUri() {

Tiny.getInstance().source(uris).batchAsFile().withOptions(compressOptions).batchCompress(new FileBatchCallback() {
@Override
public void callback(boolean isSuccess, String[] outfile) {
public void callback(boolean isSuccess, String[] outfile, Throwable t) {
if (!isSuccess) {
mCompressTv.setText("batch compress file failed!");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ private void testFile() {
File[] files = new File[]{outfile1, outfile2, outfile3, outfile4};
Tiny.getInstance().source(files).batchAsFile().withOptions(compressOptions).batchCompress(new FileWithBitmapBatchCallback() {
@Override
public void callback(boolean isSuccess, Bitmap[] bitmaps, String[] outfile) {
public void callback(boolean isSuccess, Bitmap[] bitmaps, String[] outfile, Throwable t) {
if (!isSuccess) {
mCompressTv.setText("batch compress file failed!");
return;
Expand Down Expand Up @@ -275,7 +275,7 @@ private void testBitmap() {

Tiny.getInstance().source(bitmaps).batchAsFile().withOptions(compressOptions).batchCompress(new FileWithBitmapBatchCallback() {
@Override
public void callback(boolean isSuccess, Bitmap[] bitmaps, String[] outfile) {
public void callback(boolean isSuccess, Bitmap[] bitmaps, String[] outfile, Throwable t) {
if (!isSuccess) {
mCompressTv.setText("batch compress file failed!");
return;
Expand Down Expand Up @@ -311,7 +311,7 @@ private void testResource() {

Tiny.getInstance().source(resIds).batchAsFile().withOptions(compressOptions).batchCompress(new FileWithBitmapBatchCallback() {
@Override
public void callback(boolean isSuccess, Bitmap[] bitmaps, String[] outfile) {
public void callback(boolean isSuccess, Bitmap[] bitmaps, String[] outfile, Throwable t) {
if (!isSuccess) {
mCompressTv.setText("batch compress file failed!");
return;
Expand Down Expand Up @@ -348,7 +348,7 @@ private void testUri() {

Tiny.getInstance().source(uris).batchAsFile().withOptions(compressOptions).batchCompress(new FileWithBitmapBatchCallback() {
@Override
public void callback(boolean isSuccess, Bitmap[] bitmaps, String[] outfile) {
public void callback(boolean isSuccess, Bitmap[] bitmaps, String[] outfile, Throwable t) {
if (!isSuccess) {
mCompressTv.setText("batch compress file failed!");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.net.Uri;
import android.os.Bundle;
import android.text.format.Formatter;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ImageView;
Expand Down Expand Up @@ -136,8 +137,9 @@ private void testBytes() {
compressOptions.config = mConfig;
Tiny.getInstance().source(bitmapBytes).asBitmap().withOptions(compressOptions).compress(new BitmapCallback() {
@Override
public void callback(boolean isSuccess, final Bitmap bitmap) {
public void callback(boolean isSuccess, final Bitmap bitmap, Throwable t) {
if (!isSuccess) {
Log.e("zxy", "error: " + t.getMessage());
mCompressTv.setText("compress bitmap failed!");
return;
}
Expand Down Expand Up @@ -173,8 +175,9 @@ private void testFile() {
compressOptions.config = mConfig;
Tiny.getInstance().source(outfile).asBitmap().withOptions(compressOptions).compress(new BitmapCallback() {
@Override
public void callback(boolean isSuccess, Bitmap bitmap) {
public void callback(boolean isSuccess, Bitmap bitmap, Throwable t) {
if (!isSuccess) {
Log.e("zxy", "error: " + t.getMessage());
mCompressTv.setText("compress bitmap failed!");
return;
}
Expand Down Expand Up @@ -202,8 +205,9 @@ private void testBitmap() {
compressOptions.config = mConfig;
Tiny.getInstance().source(originBitmap).asBitmap().withOptions(compressOptions).compress(new BitmapCallback() {
@Override
public void callback(boolean isSuccess, Bitmap bitmap) {
public void callback(boolean isSuccess, Bitmap bitmap, Throwable t) {
if (!isSuccess) {
Log.e("zxy", "error: " + t.getMessage());
mCompressTv.setText("compress bitmap failed!");
return;
}
Expand Down Expand Up @@ -241,8 +245,9 @@ private void testStream() {
compressOptions.config = mConfig;
Tiny.getInstance().source(is2).asBitmap().withOptions(compressOptions).compress(new BitmapCallback() {
@Override
public void callback(boolean isSuccess, Bitmap bitmap) {
public void callback(boolean isSuccess, Bitmap bitmap, Throwable t) {
if (!isSuccess) {
Log.e("zxy", "error: " + t.getMessage());
mCompressTv.setText("compress bitmap failed!");
return;
}
Expand All @@ -267,8 +272,9 @@ private void testResource() {
compressOptions.config = mConfig;
Tiny.getInstance().source(R.drawable.test).asBitmap().withOptions(compressOptions).compress(new BitmapCallback() {
@Override
public void callback(boolean isSuccess, Bitmap bitmap) {
public void callback(boolean isSuccess, Bitmap bitmap, Throwable t) {
if (!isSuccess) {
Log.e("zxy", "error: " + t.getMessage());
mCompressTv.setText("compress bitmap failed!");
return;
}
Expand Down Expand Up @@ -308,8 +314,9 @@ public void run() {
compressOptions.config = mConfig;
Tiny.getInstance().source(Uri.parse(url)).asBitmap().withOptions(compressOptions).compress(new BitmapCallback() {
@Override
public void callback(boolean isSuccess, Bitmap bitmap) {
public void callback(boolean isSuccess, Bitmap bitmap, Throwable t) {
if (!isSuccess) {
Log.e("zxy", "error: " + t.getMessage());
mCompressTv.setText("compress bitmap failed!");
return;
}
Expand Down
20 changes: 14 additions & 6 deletions app/src/main/java/com/zxy/tiny/test/FileCompressTestActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.net.Uri;
import android.os.Bundle;
import android.text.format.Formatter;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ImageView;
Expand Down Expand Up @@ -133,8 +134,9 @@ private void testBytes() {
compressOptions.config = mConfig;
Tiny.getInstance().source(bitmapBytes).asFile().withOptions(compressOptions).compress(new FileCallback() {
@Override
public void callback(boolean isSuccess, String outfile) {
public void callback(boolean isSuccess, String outfile, Throwable t) {
if (!isSuccess) {
Log.e("zxy", "error: " + t.getMessage());
mCompressTv.setText("compress file failed!");
return;
}
Expand Down Expand Up @@ -171,8 +173,9 @@ private void testFile() {
compressOptions.config = mConfig;
Tiny.getInstance().source(outfile).asFile().withOptions(compressOptions).compress(new FileCallback() {
@Override
public void callback(boolean isSuccess, String outfile) {
public void callback(boolean isSuccess, String outfile, Throwable t) {
if (!isSuccess) {
Log.e("zxy", "error: " + t.getMessage());
mCompressTv.setText("compress file failed!");
return;
}
Expand Down Expand Up @@ -200,11 +203,13 @@ private void testBitmap() {

Tiny.FileCompressOptions compressOptions = new Tiny.FileCompressOptions();
compressOptions.config = mConfig;
compressOptions.size = 200;

Tiny.getInstance().source(originBitmap).asFile().withOptions(compressOptions).compress(new FileCallback() {
@Override
public void callback(boolean isSuccess, String outfile) {
public void callback(boolean isSuccess, String outfile, Throwable t) {
if (!isSuccess) {
Log.e("zxy", "error: " + t.getMessage());
mCompressTv.setText("compress file failed!");
return;
}
Expand Down Expand Up @@ -243,8 +248,9 @@ private void testStream() {
compressOptions.config = mConfig;
Tiny.getInstance().source(is2).asFile().withOptions(compressOptions).compress(new FileCallback() {
@Override
public void callback(boolean isSuccess, String outfile) {
public void callback(boolean isSuccess, String outfile, Throwable t) {
if (!isSuccess) {
Log.e("zxy", "error: " + t.getMessage());
mCompressTv.setText("compress file failed!");
return;
}
Expand Down Expand Up @@ -275,8 +281,9 @@ private void testResource() {
compressOptions.config = mConfig;
Tiny.getInstance().source(R.drawable.test).asFile().withOptions(compressOptions).compress(new FileCallback() {
@Override
public void callback(boolean isSuccess, String outfile) {
public void callback(boolean isSuccess, String outfile, Throwable t) {
if (!isSuccess) {
Log.e("zxy", "error: " + t.getLocalizedMessage());
mCompressTv.setText("compress file failed!");
return;
}
Expand Down Expand Up @@ -330,8 +337,9 @@ public void run() {
compressOptions.config = mConfig;
Tiny.getInstance().source(Uri.parse(url)).asFile().withOptions(compressOptions).compress(new FileCallback() {
@Override
public void callback(boolean isSuccess, String outfile) {
public void callback(boolean isSuccess, String outfile, Throwable t) {
if (!isSuccess) {
Log.e("zxy", "error: " + t.getMessage());
mCompressTv.setText("compress file failed!");
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.net.Uri;
import android.os.Bundle;
import android.text.format.Formatter;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ImageView;
Expand Down Expand Up @@ -141,8 +142,9 @@ private void testBytes() {
compressOptions.config = mConfig;
Tiny.getInstance().source(bitmapBytes).asFile().withOptions(compressOptions).compress(new FileWithBitmapCallback() {
@Override
public void callback(boolean isSuccess, Bitmap bitmap, String outfile) {
public void callback(boolean isSuccess, Bitmap bitmap, String outfile, Throwable t) {
if (!isSuccess) {
Log.e("zxy", "error: " + t.getMessage());
mCompressTv.setText("compress file failed!");
return;
}
Expand Down Expand Up @@ -179,8 +181,9 @@ private void testFile() {
compressOptions.config = mConfig;
Tiny.getInstance().source(outfile).asFile().withOptions(compressOptions).compress(new FileWithBitmapCallback() {
@Override
public void callback(boolean isSuccess, Bitmap bitmap, String outfile) {
public void callback(boolean isSuccess, Bitmap bitmap, String outfile, Throwable t) {
if (!isSuccess) {
Log.e("zxy", "error: " + t.getMessage());
mCompressTv.setText("compress file failed!");
return;
}
Expand Down Expand Up @@ -211,8 +214,9 @@ private void testBitmap() {

Tiny.getInstance().source(originBitmap).asFile().withOptions(compressOptions).compress(new FileWithBitmapCallback() {
@Override
public void callback(boolean isSuccess, Bitmap bitmap, String outfile) {
public void callback(boolean isSuccess, Bitmap bitmap, String outfile, Throwable t) {
if (!isSuccess) {
Log.e("zxy", "error: " + t.getMessage());
mCompressTv.setText("compress file failed!");
return;
}
Expand Down Expand Up @@ -251,8 +255,9 @@ private void testStream() {
compressOptions.config = mConfig;
Tiny.getInstance().source(is2).asFile().withOptions(compressOptions).compress(new FileWithBitmapCallback() {
@Override
public void callback(boolean isSuccess, Bitmap bitmap, String outfile) {
public void callback(boolean isSuccess, Bitmap bitmap, String outfile, Throwable t) {
if (!isSuccess) {
Log.e("zxy", "error: " + t.getMessage());
mCompressTv.setText("compress file failed!");
return;
}
Expand Down Expand Up @@ -283,8 +288,9 @@ private void testResource() {
compressOptions.config = mConfig;
Tiny.getInstance().source(R.drawable.test).asFile().withOptions(compressOptions).compress(new FileWithBitmapCallback() {
@Override
public void callback(boolean isSuccess, Bitmap bitmap, String outfile) {
public void callback(boolean isSuccess, Bitmap bitmap, String outfile, Throwable t) {
if (!isSuccess) {
Log.e("zxy", "error: " + t.getMessage());
mCompressTv.setText("compress file failed!");
return;
}
Expand Down Expand Up @@ -338,8 +344,9 @@ public void run() {
compressOptions.config = mConfig;
Tiny.getInstance().source(Uri.parse(url)).asFile().withOptions(compressOptions).compress(new FileWithBitmapCallback() {
@Override
public void callback(boolean isSuccess, Bitmap bitmap, String outfile) {
public void callback(boolean isSuccess, Bitmap bitmap, String outfile, Throwable t) {
if (!isSuccess) {
Log.e("zxy", "error: " + t.getMessage());
mCompressTv.setText("compress file failed!");
return;
}
Expand Down
2 changes: 1 addition & 1 deletion tiny/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dependencies {

ext {
upload_group_id = 'com.zxy.android'
upload_version = '0.0.7'
upload_version = '0.1.0'

site_url = 'https://github.com/Sunzxyong/Tiny'
git_url = 'https://github.com/Sunzxyong/Tiny.git'
Expand Down
Loading

0 comments on commit f123a5e

Please sign in to comment.