本文整理汇总了Java中com.zxy.tiny.callback.FileBatchCallback类的典型用法代码示例。如果您正苦于以下问题:Java FileBatchCallback类的具体用法?Java FileBatchCallback怎么用?Java FileBatchCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileBatchCallback类属于com.zxy.tiny.callback包,在下文中一共展示了FileBatchCallback类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testResource
import com.zxy.tiny.callback.FileBatchCallback; //导入依赖的package包/类
private void testResource() {
try {
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = mConfig;
Bitmap originBitmap1 = BitmapFactory.decodeResource(getResources(), R.drawable.test_1, options);
Bitmap originBitmap2 = BitmapFactory.decodeResource(getResources(), R.drawable.test_2, options);
Bitmap originBitmap3 = BitmapFactory.decodeResource(getResources(), R.drawable.test_3, options);
Bitmap originBitmap4 = BitmapFactory.decodeResource(getResources(), R.drawable.test, options);
setupOriginInfo(originBitmap1, originBitmap2, originBitmap3, originBitmap4
, (long) (1.65 * 1024), (long) (2.28 * 1024), 371 * 1024, 226 * 1024);
int[] resIds = new int[]{R.drawable.test_1, R.drawable.test_2, R.drawable.test_3, R.drawable.test};
Tiny.FileCompressOptions compressOptions = new Tiny.FileCompressOptions();
compressOptions.config = mConfig;
Tiny.getInstance().source(resIds).batchAsFile().withOptions(compressOptions).batchCompress(new FileBatchCallback() {
@Override
public void callback(boolean isSuccess, String[] outfile) {
if (!isSuccess) {
mCompressTv.setText("batch compress file failed!");
return;
}
setupCompressInfo(outfile[0], outfile[1], outfile[2], outfile[3]
, new File(outfile[0]).length(), new File(outfile[1]).length()
, new File(outfile[2]).length(), new File(outfile[3]).length());
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
示例2: testUri
import com.zxy.tiny.callback.FileBatchCallback; //导入依赖的package包/类
private void testUri() {
String url1 = "http://7xswxf.com2.z0.glb.qiniucdn.com//blog/deec2ac0373d08eb85a.jpg";
String url2 = "http://7xswxf.com2.z0.glb.qiniucdn.com/IMG_1439.JPG";
String url3 = "http://7xswxf.com2.z0.glb.qiniucdn.com/IMG_1698.JPG";
String url4 = "http://7xswxf.com2.z0.glb.qiniucdn.com/IMG_1694.JPG";
try {
final InputStream is = getResources().getAssets()
.open("enjoy.JPG");
Bitmap enjoyBitmap = BitmapFactory.decodeStream(is);
mOriginImg1.setImageBitmap(enjoyBitmap);
mOriginImg2.setImageBitmap(enjoyBitmap);
mOriginImg3.setImageBitmap(enjoyBitmap);
mOriginImg4.setImageBitmap(enjoyBitmap);
mOriginTv.setText("省略一万字~");
Uri[] uris = new Uri[]{Uri.parse(url1), Uri.parse(url2), Uri.parse(url3), Uri.parse(url4)};
Tiny.FileCompressOptions compressOptions = new Tiny.FileCompressOptions();
compressOptions.config = mConfig;
Tiny.getInstance().source(uris).batchAsFile().withOptions(compressOptions).batchCompress(new FileBatchCallback() {
@Override
public void callback(boolean isSuccess, String[] outfile) {
if (!isSuccess) {
mCompressTv.setText("batch compress file failed!");
return;
}
setupCompressInfo(outfile[0], outfile[1], outfile[2], outfile[3]
, new File(outfile[0]).length(), new File(outfile[1]).length()
, new File(outfile[2]).length(), new File(outfile[3]).length());
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
示例3: compressByTiny
import com.zxy.tiny.callback.FileBatchCallback; //导入依赖的package包/类
private void compressByTiny(List<String> path) {
Tiny.FileCompressOptions options = new Tiny.FileCompressOptions();
Tiny.getInstance().debug(true);
Tiny.getInstance().source(path.toArray(new String[path.size()])).batchAsFile().withOptions(options).batchCompress(new FileBatchCallback() {
@Override
public void callback(boolean isSuccess, String[] outfile) {
toast("压缩完成");
setupResultInfo(Arrays.asList(outfile));
}
});
}
示例4: testResource
import com.zxy.tiny.callback.FileBatchCallback; //导入依赖的package包/类
private void testResource() {
try {
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = mConfig;
Bitmap originBitmap1 = BitmapFactory.decodeResource(getResources(), R.drawable.test_1, options);
Bitmap originBitmap2 = BitmapFactory.decodeResource(getResources(), R.drawable.test_2, options);
Bitmap originBitmap3 = BitmapFactory.decodeResource(getResources(), R.drawable.test_3, options);
Bitmap originBitmap4 = BitmapFactory.decodeResource(getResources(), R.drawable.test, options);
setupOriginInfo(originBitmap1, originBitmap2, originBitmap3, originBitmap4
, (long) (1.65 * 1024), (long) (2.28 * 1024), 371 * 1024, 226 * 1024);
int[] resIds = new int[]{R.drawable.test_1, R.drawable.test_2, R.drawable.test_3, R.drawable.test};
Tiny.FileCompressOptions compressOptions = new Tiny.FileCompressOptions();
compressOptions.config = mConfig;
Tiny.getInstance().source(resIds).batchAsFile().withOptions(compressOptions).batchCompress(new FileBatchCallback() {
@Override
public void callback(boolean isSuccess, String[] outfile, Throwable t) {
if (!isSuccess) {
mCompressTv.setText("batch compress file failed!");
return;
}
setupCompressInfo(outfile[0], outfile[1], outfile[2], outfile[3]
, new File(outfile[0]).length(), new File(outfile[1]).length()
, new File(outfile[2]).length(), new File(outfile[3]).length());
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
示例5: testUri
import com.zxy.tiny.callback.FileBatchCallback; //导入依赖的package包/类
private void testUri() {
String url1 = "http://7xswxf.com2.z0.glb.qiniucdn.com//blog/deec2ac0373d08eb85a.jpg";
String url2 = "http://7xswxf.com2.z0.glb.qiniucdn.com/IMG_1439.JPG";
String url3 = "http://7xswxf.com2.z0.glb.qiniucdn.com/IMG_1698.JPG";
String url4 = "http://7xswxf.com2.z0.glb.qiniucdn.com/IMG_1694.JPG";
try {
final InputStream is = getResources().getAssets()
.open("enjoy.JPG");
Bitmap enjoyBitmap = BitmapFactory.decodeStream(is);
mOriginImg1.setImageBitmap(enjoyBitmap);
mOriginImg2.setImageBitmap(enjoyBitmap);
mOriginImg3.setImageBitmap(enjoyBitmap);
mOriginImg4.setImageBitmap(enjoyBitmap);
mOriginTv.setText("省略一万字~");
Uri[] uris = new Uri[]{Uri.parse(url1), Uri.parse(url2), Uri.parse(url3), Uri.parse(url4)};
Tiny.FileCompressOptions compressOptions = new Tiny.FileCompressOptions();
compressOptions.config = mConfig;
Tiny.getInstance().source(uris).batchAsFile().withOptions(compressOptions).batchCompress(new FileBatchCallback() {
@Override
public void callback(boolean isSuccess, String[] outfile, Throwable t) {
if (!isSuccess) {
mCompressTv.setText("batch compress file failed!");
return;
}
setupCompressInfo(outfile[0], outfile[1], outfile[2], outfile[3]
, new File(outfile[0]).length(), new File(outfile[1]).length()
, new File(outfile[2]).length(), new File(outfile[3]).length());
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
示例6: batchCompress
import com.zxy.tiny.callback.FileBatchCallback; //导入依赖的package包/类
public void batchCompress(FileBatchCallback callback) {
impl(callback);
}
示例7: testBitmap
import com.zxy.tiny.callback.FileBatchCallback; //导入依赖的package包/类
private void testBitmap() {
try {
final InputStream is1 = getResources().getAssets()
.open("test-2.jpg");
final InputStream is2 = getResources().getAssets()
.open("test_1.png");
final InputStream is3 = getResources().getAssets()
.open("test_3.png");
final InputStream is4 = getResources().getAssets()
.open("test_4.png");
long fileSize1 = is1.available();
long fileSize2 = is2.available();
long fileSize3 = is3.available();
long fileSize4 = is4.available();
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = mConfig;
Bitmap originBitmap1 = BitmapFactory.decodeStream(is1, null, options);
Bitmap originBitmap2 = BitmapFactory.decodeStream(is2, null, options);
Bitmap originBitmap3 = BitmapFactory.decodeStream(is3, null, options);
Bitmap originBitmap4 = BitmapFactory.decodeStream(is4, null, options);
setupOriginInfo(originBitmap1, originBitmap2, originBitmap3, originBitmap4
, fileSize1, fileSize2, fileSize3, fileSize4);
Bitmap[] bitmaps = new Bitmap[]{originBitmap1, originBitmap2, originBitmap3, originBitmap4};
Tiny.FileCompressOptions compressOptions = new Tiny.FileCompressOptions();
compressOptions.config = mConfig;
Tiny.getInstance().source(bitmaps).batchAsFile().withOptions(compressOptions).batchCompress(new FileBatchCallback() {
@Override
public void callback(boolean isSuccess, String[] outfile) {
if (!isSuccess) {
mCompressTv.setText("batch compress file failed!");
return;
}
setupCompressInfo(outfile[0], outfile[1], outfile[2], outfile[3]
, new File(outfile[0]).length(), new File(outfile[1]).length()
, new File(outfile[2]).length(), new File(outfile[3]).length());
}
});
is1.close();
is2.close();
is3.close();
is4.close();
} catch (Exception e) {
e.printStackTrace();
}
}
示例8: testBitmap
import com.zxy.tiny.callback.FileBatchCallback; //导入依赖的package包/类
private void testBitmap() {
try {
final InputStream is1 = getResources().getAssets()
.open("test-2.jpg");
final InputStream is2 = getResources().getAssets()
.open("test_1.png");
final InputStream is3 = getResources().getAssets()
.open("test_3.png");
final InputStream is4 = getResources().getAssets()
.open("test_4.png");
long fileSize1 = is1.available();
long fileSize2 = is2.available();
long fileSize3 = is3.available();
long fileSize4 = is4.available();
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = mConfig;
Bitmap originBitmap1 = BitmapFactory.decodeStream(is1, null, options);
Bitmap originBitmap2 = BitmapFactory.decodeStream(is2, null, options);
Bitmap originBitmap3 = BitmapFactory.decodeStream(is3, null, options);
Bitmap originBitmap4 = BitmapFactory.decodeStream(is4, null, options);
setupOriginInfo(originBitmap1, originBitmap2, originBitmap3, originBitmap4
, fileSize1, fileSize2, fileSize3, fileSize4);
Bitmap[] bitmaps = new Bitmap[]{originBitmap1, originBitmap2, originBitmap3, originBitmap4};
Tiny.FileCompressOptions compressOptions = new Tiny.FileCompressOptions();
compressOptions.config = mConfig;
Tiny.getInstance().source(bitmaps).batchAsFile().withOptions(compressOptions).batchCompress(new FileBatchCallback() {
@Override
public void callback(boolean isSuccess, String[] outfile, Throwable t) {
if (!isSuccess) {
mCompressTv.setText("batch compress file failed!");
return;
}
setupCompressInfo(outfile[0], outfile[1], outfile[2], outfile[3]
, new File(outfile[0]).length(), new File(outfile[1]).length()
, new File(outfile[2]).length(), new File(outfile[3]).length());
}
});
is1.close();
is2.close();
is3.close();
is4.close();
} catch (Exception e) {
e.printStackTrace();
}
}